mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:11:03 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- align permissions to gecko (2b5293932d)
- Bug 1214759 - backport SkDashPathEffect::asPoints fix from upstream Skia. r=jmuizelaar (4f58a0ef9a)
- Bug 1216020 - Comment all ALLOW_COMPILER_WARNINGS lines. r=glandium. (30a485d631)
- bug 1174747 - Fix sqlite3 build on iOS. r=glandium (ad59695677)
- Bug 1229615 - Conditionalize mp4parse.h export. r=kinetik (f7e95a1afa)
- Bug 1211741 - Remove libstagefright ID3 files. r=k17e (016da13fed)
- Bug 1202266 - Suppress '-Wformat-security' in libstagefright CXXFLAGS. r=kentuckyfriedtakahe Bug 1143336 - Fix and suppress -Wunreachable-code-return warnings in media code. r=cajbir (f8f58de405)
- Bug 1225923 - part 1 - convert all needs-to-copy instances of AppendElement(nsDependentString(...)); r=erahm (e061f9cb53)
- Bug 1225923 - part 2 - fix AppendElement(nsDependentString(...)) call in HTMLInputElement.cpp; r=baku (69d4b4c288)
- Bug 1179089 - Let TelephonyRequestParent hold the callback objects. r=hsinyi (05a6d68415)
- Bug 1225923 - part 3 - fix AppendElement(nsDependentString(...)) calls in dom/telephony/; r=btseng (31cb1e8cb0)
- Bug 1225923 - part 4 - fix AppendElement(nsDependentCString(...)) call in nsClipboardProxy.cpp; r=roc (978e7bfe19)
- Bug 1225923 - part 5 - fix AppendElement(nsDependentAtomString(...)) calls; r=bz (82c93922bb)
- fix (761e252105)
- Bug 1187114 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in dom/xul/ with iterators. r=mccr8. (12b2947f5b)
- Bug 1187114 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in dom/xul/ with iterators. r=mccr8. (db1ad0cd0f)
- Bug 1187114 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in dom/xul/ with iterators. r=mccr8. (0b46fdbb38)
- Bug 1137009 - Do not persist xul window attributes when in fullscreen. r=enndeakin (6bef2373dc)
- Bug 1206958 - Use channel->asyncOpen2() in dom/xul/XULDocument.cpp (r=sicking) (21b1a90678)
- Bug 1216945 - Uninitialised value use in nsXULWindow::SizeShellTo. r=bzbarsky. (989ce9ff88)
- Bug 1189132 - Skip unmap during window destruction on GTK, working around talos hang with GL layers. r=karlt (34f29cb72b)
- Bug 1206964 - Use channel->AsyncOpen2() in netwerk/base/nsNetUtil.cpp (r=sicking) (fbb5158a68)
- Bug 1225682 - Don't use nsAuto{,C}String as class member variables in xpfe/. r=neil (bd453fc5f5)
- Bug 1221992 - Prevent ServiceWorkerClients.OpenWindow from opening tabs in private mode windows. r=smaug (f7da0cf34c)
- Bug 1034922 - Make nsSiteWindow's destructor private, and expose it to nsContentTreeOwner via friend class. r=Enn (87d8dfa052)
- Bug 1214174 - Windowless WebBrowserChrome2Stub should implement nsIEmbeddingSiteWindow GetDimensions. r=billm (4f4b44532d)
- Bug 1214174 - Add windowless browser test case. r=billm (2ece018afd)
- Bug 1160770 - Unnecessary return in tabScrolling property in XPFE autocomplete.xml NPOTB r=Neil DONTBUILD (7fe5f13994)
- Bug 1192943 - Use channel->asycnOpen2 in xpfe/components/directory/nsDirectoryViewer.cpp (r=sicking) (79c2f93134)
- Bug 1186790 - Replace nsBaseHashtable::EnumerateRead() calls in xpfe/with iterators. r=neil. (ee73ea015d)
- Bug 1232450 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in xulrunner/; r=Yoric (ffa7a84864)
- Bug 1174011, fix xulrunner-stub compile, r=gladium DONTBUILD (bb9381a707)
- Bug 1216723 - Add a new -forbid- Safe Browsing list type. r=gcp,r=smaug (9f164a56d8)
- cleanup, do not run PP (0d7c0cd4c0)
- Bug 1204338 Followup to Bug 403800 Refactor netError.dtd/netErrorApp.dtd to simplify per-application overrides r=Pike (5e1bbcb45c)
- Bug 1154347 - Don't set -fomit-frame-pointer on all of skia. r=glandium, r=gw280 (af8db2b7b9)
- Bug 1136958 - Remove duplicate SkDiscardableMemory_none.cpp from gfx/skia/moz.build. r=gps (9bbebeecc4)
- bits of Bug 1188462 - Rename gfx/skia/trun (d839e73b23)
- Bug 1215899 - Suppress clang and gcc warnings in gfx/skia. r=gw280 (e7859525d0)
- Bug 1222166 - use gcc/clang warning flags for clang-cl in moz.build files; r=glandium (b885ca1dff)
- Bug 1082598 - Part 1: Update Skia to master revision 53c5d5fb795fe04bec050c0583223027c25b839b. r=jrmuizel (4baf696313)
- Bug 1082598 - Part 2: Fix Moz2D Skia usage for Skia update. r=jrmuizel (d6192e1b0d)
- Bug 1082598 - Part 3: Fix thebes gfxPlatform shutdown for Skia. r=jrmuizel (ecaf498adf)
- Bug 1082598 - Part 6: Fix layers for Skia update. r=jrmuizel (e80b4e204c)
- Bug 1082598 - Part 7: Update moz.build for Skia update. r=jrmuizel (121c4c6e21)
- Bug 1082598 - Part 8: Fix OpenGL interface glue for Skia update. r=jrmuizel (327cebb260)
- Bug 1082598 - Part 9: Fix test failures for Skia update. r=jrmuizel (1d0a6a6a9a)
- missing bit of Bug 1082598 - Part 1: Update Skia (559cb5a38a)
- cleanup strange misspatch (5d759aadaf)
This commit is contained in:
@@ -291,6 +291,8 @@
|
||||
<h1 id="et_nssFailure2">&nssFailure2.title;</h1>
|
||||
<h1 id="et_nssBadCert">&nssBadCert.title;</h1>
|
||||
<h1 id="et_malwareBlocked">&malwareBlocked.title;</h1>
|
||||
<h1 id="et_unwantedBlocked">&unwantedBlocked.title;</h1>
|
||||
<h1 id="et_forbiddenBlocked">&forbiddenBlocked.title;</h1>
|
||||
<h1 id="et_cspBlocked">&cspBlocked.title;</h1>
|
||||
<h1 id="et_remoteXUL">&remoteXUL.title;</h1>
|
||||
<h1 id="et_corruptedContentError">&corruptedContentError.title;</h1>
|
||||
@@ -317,6 +319,8 @@
|
||||
<div id="ed_nssFailure2">&nssFailure2.longDesc2;</div>
|
||||
<div id="ed_nssBadCert">&nssBadCert.longDesc2;</div>
|
||||
<div id="ed_malwareBlocked">&malwareBlocked.longDesc;</div>
|
||||
<div id="ed_unwantedBlocked">&unwantedBlocked.longDesc;</div>
|
||||
<div id="ed_forbiddenBlocked">&forbiddenBlocked.longDesc;</div>
|
||||
<div id="ed_cspBlocked">&cspBlocked.longDesc;</div>
|
||||
<div id="ed_remoteXUL">&remoteXUL.longDesc;</div>
|
||||
<div id="ed_corruptedContentError">&corruptedContentError.longDesc;</div>
|
||||
|
||||
@@ -30,7 +30,9 @@ externalProtocolUnknown=<Unknown>
|
||||
externalProtocolChkMsg=Remember my choice for all links of this type.
|
||||
externalProtocolLaunchBtn=Launch application
|
||||
malwareBlocked=The site at %S has been reported as an attack site and has been blocked based on your security preferences.
|
||||
unwantedBlocked=The site at %S has been reported as serving unwanted software and has been blocked based on your security preferences.
|
||||
phishingBlocked=The website at %S has been reported as a web forgery designed to trick users into sharing personal or financial information.
|
||||
forbiddenBlocked=The site at %S has been blocked by your browser configuration.
|
||||
cspBlocked=This page has a content security policy that prevents it from being embedded in this way.
|
||||
xssBlockMode=This page contains an XSS attack that has been blocked for your security.
|
||||
corruptedContentError=The page you are trying to view cannot be shown because an error in the data transmission was detected.
|
||||
|
||||
@@ -164,12 +164,21 @@ be temporary, and you can try again later.</li>
|
||||
<p>Website owners who believe their site has been reported as an attack site in error may <a href='https://www.stopbadware.org/request-review' >request a review</a>.</p>
|
||||
">
|
||||
|
||||
<!ENTITY unwantedBlocked.title "Suspected Unwanted Software Site!">
|
||||
<!ENTITY unwantedBlocked.longDesc "
|
||||
<p>Unwanted software pages try to install software that can be deceptive and affect your system in unexpected ways.</p>
|
||||
">
|
||||
|
||||
<!ENTITY phishingBlocked.title "Suspected Web Forgery!">
|
||||
<!ENTITY phishingBlocked.longDesc "
|
||||
<p>Entering any personal information on this page may result in identity theft or other fraud.</p>
|
||||
<p>These types of web forgeries are used in scams known as phishing attacks, in which fraudulent web pages and emails are used to imitate sources you may trust.</p>
|
||||
">
|
||||
|
||||
<!ENTITY forbiddenBlocked.title "Forbidden Site">
|
||||
<!ENTITY forbiddenBlocked.longDesc "<p>&brandShortName; prevented this page from loading because it is configured to block it.</p>
|
||||
">
|
||||
|
||||
<!ENTITY cspBlocked.title "Blocked by Content Security Policy">
|
||||
<!ENTITY cspBlocked.longDesc "<p>&brandShortName; prevented this page from loading in this way because the page has a content security policy that disallows it.</p>">
|
||||
|
||||
|
||||
@@ -57,6 +57,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
DEFINES['SQLITE_ENABLE_LOCKING_STYLE'] = 1
|
||||
|
||||
# sqlite defaults this to on on __APPLE_ but it breaks on newer iOS SDKs
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
|
||||
DEFINES['SQLITE_ENABLE_LOCKING_STYLE'] = 0
|
||||
|
||||
# Turn on SQLite's assertions in debug builds.
|
||||
if CONFIG['MOZ_DEBUG']:
|
||||
DEFINES['SQLITE_DEBUG'] = 1
|
||||
|
||||
@@ -4882,7 +4882,9 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
}
|
||||
}
|
||||
} else if (NS_ERROR_PHISHING_URI == aError ||
|
||||
NS_ERROR_MALWARE_URI == aError) {
|
||||
NS_ERROR_MALWARE_URI == aError ||
|
||||
NS_ERROR_UNWANTED_URI == aError ||
|
||||
NS_ERROR_FORBIDDEN_URI == aError) {
|
||||
nsAutoCString host;
|
||||
aURI->GetHost(host);
|
||||
CopyUTF8toUTF16(host, formatStrs[0]);
|
||||
@@ -7687,6 +7689,8 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
||||
aStatus == NS_ERROR_OFFLINE ||
|
||||
aStatus == NS_ERROR_MALWARE_URI ||
|
||||
aStatus == NS_ERROR_PHISHING_URI ||
|
||||
aStatus == NS_ERROR_UNWANTED_URI ||
|
||||
aStatus == NS_ERROR_FORBIDDEN_URI ||
|
||||
aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE ||
|
||||
aStatus == NS_ERROR_REMOTE_XUL ||
|
||||
aStatus == NS_ERROR_INTERCEPTION_FAILED ||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"DTD/xhtml1-strict.dtd">
|
||||
%htmlDTD;
|
||||
<!ENTITY % netErrorAppDTD
|
||||
SYSTEM "chrome://global/locale/netErrorApp.dtd">
|
||||
%netErrorAppDTD;
|
||||
<!ENTITY % netErrorDTD
|
||||
SYSTEM "chrome://global/locale/netError.dtd">
|
||||
%netErrorDTD;
|
||||
@@ -291,6 +294,8 @@
|
||||
<h1 id="et_nssFailure2">&nssFailure2.title;</h1>
|
||||
<h1 id="et_nssBadCert">&nssBadCert.title;</h1>
|
||||
<h1 id="et_malwareBlocked">&malwareBlocked.title;</h1>
|
||||
<h1 id="et_unwantedBlocked">&unwantedBlocked.title;</h1>
|
||||
<h1 id="et_forbiddenBlocked">&forbiddenBlocked.title;</h1>
|
||||
<h1 id="et_cspBlocked">&cspBlocked.title;</h1>
|
||||
<h1 id="et_remoteXUL">&remoteXUL.title;</h1>
|
||||
<h1 id="et_corruptedContentError">&corruptedContentError.title;</h1>
|
||||
@@ -317,6 +322,8 @@
|
||||
<div id="ed_nssFailure2">&nssFailure2.longDesc2;</div>
|
||||
<div id="ed_nssBadCert">&nssBadCert.longDesc2;</div>
|
||||
<div id="ed_malwareBlocked">&malwareBlocked.longDesc;</div>
|
||||
<div id="ed_unwantedBlocked">&unwantedBlocked.longDesc;</div>
|
||||
<div id="ed_forbiddenBlocked">&forbiddenBlocked.longDesc;</div>
|
||||
<div id="ed_cspBlocked">&cspBlocked.longDesc;</div>
|
||||
<div id="ed_remoteXUL">&remoteXUL.longDesc;</div>
|
||||
<div id="ed_corruptedContentError">&corruptedContentError.longDesc;</div>
|
||||
|
||||
@@ -579,9 +579,10 @@ nsContentList::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
|
||||
}
|
||||
}
|
||||
|
||||
aNames.SetCapacity(atoms.Length());
|
||||
for (uint32_t i = 0; i < atoms.Length(); ++i) {
|
||||
aNames.AppendElement(nsDependentAtomString(atoms[i]));
|
||||
uint32_t atomsLen = atoms.Length();
|
||||
nsString* names = aNames.AppendElements(atomsLen);
|
||||
for (uint32_t i = 0; i < atomsLen; ++i) {
|
||||
atoms[i]->ToString(names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
#include "nsIURIWithPrincipal.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIWordBreaker.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsJSUtils.h"
|
||||
@@ -5172,6 +5173,23 @@ nsContentUtils::GetWindowProviderForContentProcess()
|
||||
return ContentChild::GetSingleton();
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsPIDOMWindow>
|
||||
nsContentUtils::GetMostRecentNonPBWindow()
|
||||
{
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator =
|
||||
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
||||
nsCOMPtr<nsIWindowMediator_44> wm = do_QueryInterface(windowMediator);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
wm->GetMostRecentNonPBWindow(MOZ_UTF16("navigator:browser"),
|
||||
getter_AddRefs(window));
|
||||
nsCOMPtr<nsPIDOMWindow> pwindow;
|
||||
pwindow = do_QueryInterface(window);
|
||||
|
||||
return pwindow.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsContentUtils::WarnScriptWasIgnored(nsIDocument* aDocument)
|
||||
|
||||
@@ -1653,6 +1653,11 @@ public:
|
||||
static nsIWindowProvider*
|
||||
GetWindowProviderForContentProcess();
|
||||
|
||||
// Returns the browser window with the most recent time stamp that is
|
||||
// not in private browsing mode.
|
||||
static already_AddRefed<nsPIDOMWindow>
|
||||
GetMostRecentNonPBWindow();
|
||||
|
||||
/**
|
||||
* Call this function if !IsSafeToRunScript() and we fail to run the script
|
||||
* (rather than using AddScriptRunner as we usually do). |aDocument| is
|
||||
|
||||
@@ -759,12 +759,14 @@ nsDOMMutationObserver::GetObservingInfo(
|
||||
info.mAttributeFilter.Construct();
|
||||
mozilla::dom::Sequence<nsString>& filtersAsStrings =
|
||||
info.mAttributeFilter.Value();
|
||||
nsString* strings = filtersAsStrings.AppendElements(filters.Count(),
|
||||
mozilla::fallible);
|
||||
if (!strings) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
for (int32_t j = 0; j < filters.Count(); ++j) {
|
||||
if (!filtersAsStrings.AppendElement(nsDependentAtomString(filters[j]),
|
||||
mozilla::fallible)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
filters[j]->ToString(strings[j]);
|
||||
}
|
||||
}
|
||||
info.mObservedNode = mr->Target();
|
||||
|
||||
@@ -2000,6 +2000,12 @@ BrowserElementChild.prototype = {
|
||||
case Cr.NS_ERROR_MALWARE_URI :
|
||||
sendAsyncMsg('error', { type: 'malwareBlocked' });
|
||||
return;
|
||||
case Cr.NS_ERROR_UNWANTED_URI :
|
||||
sendAsyncMsg('error', { type: 'unwantedBlocked' });
|
||||
return;
|
||||
case Cr.NS_ERROR_FORBIDDEN_URI :
|
||||
sendAsyncMsg('error', { type: 'forbiddenBlocked' });
|
||||
return;
|
||||
|
||||
case Cr.NS_ERROR_OFFLINE :
|
||||
sendAsyncMsg('error', { type: 'offline' });
|
||||
|
||||
@@ -14457,12 +14457,7 @@ ctx.moveTo(50, 25);
|
||||
ctx.bezierCurveTo(50, 25, 50, 25, 50, 25);
|
||||
ctx.stroke();
|
||||
|
||||
if (IsAzureSkia()) {
|
||||
isPixel(ctx, 50,25, 0,255,0,255, 0);
|
||||
} else {
|
||||
todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
|
||||
}
|
||||
|
||||
todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -14494,11 +14489,7 @@ ctx.moveTo(50, 25);
|
||||
ctx.lineTo(50, 25);
|
||||
ctx.stroke();
|
||||
|
||||
if (IsAzureSkia()) {
|
||||
isPixel(ctx, 50,25, 0,255,0,255, 0);
|
||||
} else {
|
||||
todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
|
||||
}
|
||||
todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -202,9 +202,10 @@ HTMLAllCollection::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames
|
||||
}
|
||||
}
|
||||
|
||||
aNames.SetCapacity(atoms.Length());
|
||||
for (uint32_t i = 0; i < atoms.Length(); ++i) {
|
||||
aNames.AppendElement(nsDependentAtomString(atoms[i]));
|
||||
uint32_t atomsLen = atoms.Length();
|
||||
nsString* names = aNames.AppendElements(atomsLen);
|
||||
for (uint32_t i = 0; i < atomsLen; ++i) {
|
||||
atoms[i]->ToString(names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2157,10 +2157,13 @@ HTMLInputElement::MozSetFileNameArray(const char16_t** aFileNames, uint32_t aLen
|
||||
}
|
||||
|
||||
Sequence<nsString> list;
|
||||
nsString* names = list.AppendElements(aLength, fallible);
|
||||
if (!names) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
for (uint32_t i = 0; i < aLength; ++i) {
|
||||
if (!list.AppendElement(nsDependentString(aFileNames[i]), fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
const char16_t* filename = aFileNames[i];
|
||||
names[i].Rebind(filename, nsCharTraits<char16_t>::length(filename));
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
|
||||
@@ -309,9 +309,10 @@ HTMLOptionsCollection::GetSupportedNames(unsigned aFlags,
|
||||
}
|
||||
}
|
||||
|
||||
aNames.SetCapacity(atoms.Length());
|
||||
for (uint32_t i = 0; i < atoms.Length(); ++i) {
|
||||
aNames.AppendElement(nsDependentAtomString(atoms[i]));
|
||||
uint32_t atomsLen = atoms.Length();
|
||||
nsString* names = aNames.AppendElements(atomsLen);
|
||||
for (uint32_t i = 0; i < atomsLen; ++i) {
|
||||
atoms[i]->ToString(names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,6 @@
|
||||
#include "nsISystemMessagesInternal.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIURIFixup.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIDOMChromeWindow.h"
|
||||
@@ -5373,38 +5372,6 @@ ContentParent::DeallocPContentPermissionRequestParent(PContentPermissionRequestP
|
||||
return true;
|
||||
}
|
||||
|
||||
static already_AddRefed<nsPIDOMWindow>
|
||||
FindMostRecentOpenWindow()
|
||||
{
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator =
|
||||
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||
windowMediator->GetEnumerator(MOZ_UTF16("navigator:browser"),
|
||||
getter_AddRefs(windowEnumerator));
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> latest;
|
||||
|
||||
bool hasMore = false;
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->HasMoreElements(&hasMore)));
|
||||
while (hasMore) {
|
||||
nsCOMPtr<nsISupports> item;
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->GetNext(getter_AddRefs(item))));
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(item);
|
||||
|
||||
if (window) {
|
||||
bool closed = false;
|
||||
window->GetClosed(&closed);
|
||||
if (!closed) {
|
||||
latest = window;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->HasMoreElements(&hasMore)));
|
||||
}
|
||||
|
||||
return latest.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
|
||||
PBrowserParent* aNewTab,
|
||||
@@ -5482,7 +5449,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
|
||||
// If we haven't found a chrome window to open in, just use the most recently
|
||||
// opened one.
|
||||
if (!parent) {
|
||||
parent = FindMostRecentOpenWindow();
|
||||
parent = nsContentUtils::GetMostRecentNonPBWindow();
|
||||
if (NS_WARN_IF(!parent)) {
|
||||
*aResult = NS_ERROR_FAILURE;
|
||||
return true;
|
||||
|
||||
@@ -29,7 +29,9 @@ externalProtocolUnknown=<Unknown>
|
||||
externalProtocolChkMsg=Remember my choice for all links of this type.
|
||||
externalProtocolLaunchBtn=Launch application
|
||||
malwareBlocked=The site at %S has been reported as an attack site and has been blocked based on your security preferences.
|
||||
unwantedBlocked=The site at %S has been reported as serving unwanted software and has been blocked based on your security preferences.
|
||||
phishingBlocked=The website at %S has been reported as a web forgery designed to trick users into sharing personal or financial information.
|
||||
forbiddenBlocked=The site at %S has been blocked by your browser configuration.
|
||||
cspBlocked=This page has a content security policy that prevents it from being loaded in this way.
|
||||
corruptedContentError=The page you are trying to view cannot be shown because an error in the data transmission was detected.
|
||||
remoteXUL=This page uses an unsupported technology that is no longer available by default.
|
||||
|
||||
@@ -87,6 +87,16 @@
|
||||
<p>These types of web forgeries are used in scams known as phishing attacks, in which fraudulent web pages and emails are used to imitate sources you may trust.</p>
|
||||
">
|
||||
|
||||
<!ENTITY forbiddenBlocked.title "Forbidden Site">
|
||||
<!ENTITY forbiddenBlocked.longDesc "<p>The browser prevented this page from loading because it is configured to block it.</p>
|
||||
">
|
||||
|
||||
<!ENTITY securityOverride.linkText "Or you can add an exception…">
|
||||
<!ENTITY securityOverride.warningContent "
|
||||
<p>You should not add an exception if you are using an internet connection that you do not trust completely or if you are not used to seeing a warning for this server.</p>
|
||||
<p>If you still wish to add an exception for this site, you can do so in your advanced encryption settings.</p>
|
||||
">
|
||||
|
||||
<!ENTITY cspBlocked.title "Blocked by Content Security Policy">
|
||||
<!ENTITY cspBlocked.longDesc "<p>The browser prevented this page from loading in this way because the page has a content security policy that disallows it.</p>">
|
||||
|
||||
@@ -95,10 +105,3 @@
|
||||
|
||||
<!ENTITY remoteXUL.title "Remote XUL">
|
||||
<!ENTITY remoteXUL.longDesc "<p><ul><li>Please contact the website owners to inform them of this problem.</li></ul></p>">
|
||||
|
||||
<!-- Include app-specific error messages - do not change this in localization!
|
||||
Some applications might override netErrorApp.dtd with their specific version,
|
||||
this inclusion needs to be intact for that approach to work correctly.
|
||||
Please, try to keep this at the end of the file. -->
|
||||
<!ENTITY % netErrorAppDTD SYSTEM "chrome://global/locale/netErrorApp.dtd">
|
||||
%netErrorAppDTD;
|
||||
|
||||
@@ -2,12 +2,22 @@
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!-- Error messages that are likely to be overridden by applications go in this
|
||||
file, all messages that likely don't need to tie into app-specific UI
|
||||
should go into netError.dtd -->
|
||||
<!-- This file exists to allow applications to override one or more messages
|
||||
from netError.dtd; Applications which want to do this should override
|
||||
this file with their own version of netErrorApp.dtd -->
|
||||
|
||||
<!-- An example (from Firefox):
|
||||
|
||||
<!ENTITY securityOverride.linkText "Or you can add an exception…">
|
||||
<!ENTITY securityOverride.getMeOutOfHereButton "Get me out of here!">
|
||||
<!ENTITY securityOverride.exceptionButtonLabel "Add Exception…">
|
||||
|
||||
<!ENTITY securityOverride.warningContent "
|
||||
<p>You should not add an exception if you are using an internet connection that you do not trust completely or if you are not used to seeing a warning for this server.</p>
|
||||
<p>If you still wish to add an exception for this site, you can do so in your advanced encryption settings.</p>
|
||||
|
||||
<button id='getMeOutOfHereButton'>&securityOverride.getMeOutOfHereButton;</button>
|
||||
<button id='exceptionDialogButton'>&securityOverride.exceptionButtonLabel;</button>
|
||||
">
|
||||
|
||||
-->
|
||||
|
||||
@@ -121,8 +121,10 @@ TelephonyDialCallback::NotifyDialMMISuccessWithStrings(const nsAString& aStatusM
|
||||
result.mStatusMessage.Assign(aStatusMessage);
|
||||
|
||||
nsTArray<nsString> additionalInformation;
|
||||
nsString* infos = additionalInformation.AppendElements(aCount);
|
||||
for (uint32_t i = 0; i < aCount; i++) {
|
||||
additionalInformation.AppendElement(nsDependentString(aAdditionalInformation[i]));
|
||||
infos[i].Rebind(aAdditionalInformation[i],
|
||||
nsCharTraits<char16_t>::length(aAdditionalInformation[i]));
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> jsAdditionalInformation(cx);
|
||||
|
||||
@@ -41,7 +41,7 @@ TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActo
|
||||
nsCOMPtr<nsITelephonyService> service = do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
||||
|
||||
if (!service) {
|
||||
return NS_SUCCEEDED(actor->NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
||||
return NS_SUCCEEDED(actor->GetCallback()->NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
||||
}
|
||||
|
||||
switch (aRequest.type()) {
|
||||
@@ -57,79 +57,79 @@ TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActo
|
||||
case IPCTelephonyRequest::TDialRequest: {
|
||||
const DialRequest& request = aRequest.get_DialRequest();
|
||||
service->Dial(request.clientId(), request.number(),
|
||||
request.isEmergency(), actor);
|
||||
request.isEmergency(), actor->GetDialCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TSendUSSDRequest: {
|
||||
const SendUSSDRequest& request = aRequest.get_SendUSSDRequest();
|
||||
service->SendUSSD(request.clientId(), request.ussd(), actor);
|
||||
service->SendUSSD(request.clientId(), request.ussd(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TCancelUSSDRequest: {
|
||||
const CancelUSSDRequest& request = aRequest.get_CancelUSSDRequest();
|
||||
service->CancelUSSD(request.clientId(), actor);
|
||||
service->CancelUSSD(request.clientId(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TConferenceCallRequest: {
|
||||
const ConferenceCallRequest& request = aRequest.get_ConferenceCallRequest();
|
||||
service->ConferenceCall(request.clientId(), actor);
|
||||
service->ConferenceCall(request.clientId(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TSeparateCallRequest: {
|
||||
const SeparateCallRequest& request = aRequest.get_SeparateCallRequest();
|
||||
service->SeparateCall(request.clientId(), request.callIndex(), actor);
|
||||
service->SeparateCall(request.clientId(), request.callIndex(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::THangUpConferenceRequest: {
|
||||
const HangUpConferenceRequest& request = aRequest.get_HangUpConferenceRequest();
|
||||
service->HangUpConference(request.clientId(), actor);
|
||||
service->HangUpConference(request.clientId(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::THoldConferenceRequest: {
|
||||
const HoldConferenceRequest& request = aRequest.get_HoldConferenceRequest();
|
||||
service->HoldConference(request.clientId(), actor);
|
||||
service->HoldConference(request.clientId(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TResumeConferenceRequest: {
|
||||
const ResumeConferenceRequest& request = aRequest.get_ResumeConferenceRequest();
|
||||
service->ResumeConference(request.clientId(), actor);
|
||||
service->ResumeConference(request.clientId(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TAnswerCallRequest: {
|
||||
const AnswerCallRequest& request = aRequest.get_AnswerCallRequest();
|
||||
service->AnswerCall(request.clientId(), request.callIndex(), actor);
|
||||
service->AnswerCall(request.clientId(), request.callIndex(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::THangUpCallRequest: {
|
||||
const HangUpCallRequest& request = aRequest.get_HangUpCallRequest();
|
||||
service->HangUpCall(request.clientId(), request.callIndex(), actor);
|
||||
service->HangUpCall(request.clientId(), request.callIndex(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TRejectCallRequest: {
|
||||
const RejectCallRequest& request = aRequest.get_RejectCallRequest();
|
||||
service->RejectCall(request.clientId(), request.callIndex(), actor);
|
||||
service->RejectCall(request.clientId(), request.callIndex(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::THoldCallRequest: {
|
||||
const HoldCallRequest& request = aRequest.get_HoldCallRequest();
|
||||
service->HoldCall(request.clientId(), request.callIndex(), actor);
|
||||
service->HoldCall(request.clientId(), request.callIndex(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
case IPCTelephonyRequest::TResumeCallRequest: {
|
||||
const ResumeCallRequest& request = aRequest.get_ResumeCallRequest();
|
||||
service->ResumeCall(request.clientId(), request.callIndex(), actor);
|
||||
service->ResumeCall(request.clientId(), request.callIndex(), actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActo
|
||||
request.dtmfChars(),
|
||||
request.pauseDuration(),
|
||||
request.toneDuration(),
|
||||
actor);
|
||||
actor->GetCallback());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -338,12 +338,12 @@ TelephonyParent::SupplementaryServiceNotification(uint32_t aClientId,
|
||||
******************************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS(TelephonyRequestParent,
|
||||
nsITelephonyListener,
|
||||
nsITelephonyCallback,
|
||||
nsITelephonyDialCallback)
|
||||
nsITelephonyListener)
|
||||
|
||||
TelephonyRequestParent::TelephonyRequestParent()
|
||||
: mActorDestroyed(false)
|
||||
: mActorDestroyed(false),
|
||||
mCallback(new Callback(*this)),
|
||||
mDialCallback(new DialCallback(*this))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -413,60 +413,80 @@ TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId,
|
||||
MOZ_CRASH("Not a TelephonyParent!");
|
||||
}
|
||||
|
||||
// nsITelephonyDialCallback
|
||||
/*******************************************************************************
|
||||
* TelephonyRequestParent::Callback
|
||||
******************************************************************************/
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMI(const nsAString& aServiceCode)
|
||||
NS_IMPL_ISUPPORTS(TelephonyRequestParent::Callback,
|
||||
nsITelephonyCallback)
|
||||
|
||||
nsresult TelephonyRequestParent::Callback::SendResponse(const IPCTelephonyResponse& aResponse)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
return SendNotifyDialMMI(nsAutoString(aServiceCode)) ? NS_OK : NS_ERROR_FAILURE;
|
||||
return mParent.SendResponse(aResponse);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifySuccess()
|
||||
TelephonyRequestParent::Callback::NotifySuccess()
|
||||
{
|
||||
return SendResponse(SuccessResponse());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyError(const nsAString& aError)
|
||||
TelephonyRequestParent::Callback::NotifyError(const nsAString& aError)
|
||||
{
|
||||
return SendResponse(ErrorResponse(nsAutoString(aError)));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* TelephonyRequestParent::DialCallback
|
||||
******************************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(TelephonyRequestParent::DialCallback,
|
||||
TelephonyRequestParent::Callback,
|
||||
nsITelephonyDialCallback)
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialCallSuccess(uint32_t aClientId,
|
||||
uint32_t aCallIndex,
|
||||
const nsAString& aNumber)
|
||||
TelephonyRequestParent::DialCallback::NotifyDialMMI(const nsAString& aServiceCode)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mParent.mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
return mParent.SendNotifyDialMMI(nsAutoString(aServiceCode)) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::DialCallback::NotifyDialCallSuccess(uint32_t aClientId,
|
||||
uint32_t aCallIndex,
|
||||
const nsAString& aNumber)
|
||||
{
|
||||
return SendResponse(DialResponseCallSuccess(aClientId, aCallIndex,
|
||||
nsAutoString(aNumber)));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMISuccess(const nsAString& aStatusMessage)
|
||||
TelephonyRequestParent::DialCallback::NotifyDialMMISuccess(const nsAString& aStatusMessage)
|
||||
{
|
||||
return SendResponse(DialResponseMMISuccess(nsAutoString(aStatusMessage),
|
||||
AdditionalInformation(mozilla::void_t())));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMISuccessWithInteger(const nsAString& aStatusMessage,
|
||||
uint16_t aAdditionalInformation)
|
||||
TelephonyRequestParent::DialCallback::NotifyDialMMISuccessWithInteger(const nsAString& aStatusMessage,
|
||||
uint16_t aAdditionalInformation)
|
||||
{
|
||||
return SendResponse(DialResponseMMISuccess(nsAutoString(aStatusMessage),
|
||||
AdditionalInformation(aAdditionalInformation)));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMISuccessWithStrings(const nsAString& aStatusMessage,
|
||||
uint32_t aCount,
|
||||
const char16_t** aAdditionalInformation)
|
||||
TelephonyRequestParent::DialCallback::NotifyDialMMISuccessWithStrings(const nsAString& aStatusMessage,
|
||||
uint32_t aCount,
|
||||
const char16_t** aAdditionalInformation)
|
||||
{
|
||||
nsTArray<nsString> additionalInformation;
|
||||
nsString* infos = additionalInformation.AppendElements(aCount);
|
||||
for (uint32_t i = 0; i < aCount; i++) {
|
||||
additionalInformation.AppendElement(nsDependentString(aAdditionalInformation[i]));
|
||||
infos[i].Rebind(aAdditionalInformation[i],
|
||||
nsCharTraits<char16_t>::length(aAdditionalInformation[i]));
|
||||
}
|
||||
|
||||
return SendResponse(DialResponseMMISuccess(nsAutoString(aStatusMessage),
|
||||
@@ -474,9 +494,9 @@ TelephonyRequestParent::NotifyDialMMISuccessWithStrings(const nsAString& aStatus
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMISuccessWithCallForwardingOptions(const nsAString& aStatusMessage,
|
||||
uint32_t aCount,
|
||||
nsIMobileCallForwardingOptions** aAdditionalInformation)
|
||||
TelephonyRequestParent::DialCallback::NotifyDialMMISuccessWithCallForwardingOptions(const nsAString& aStatusMessage,
|
||||
uint32_t aCount,
|
||||
nsIMobileCallForwardingOptions** aAdditionalInformation)
|
||||
{
|
||||
nsTArray<nsIMobileCallForwardingOptions*> additionalInformation;
|
||||
for (uint32_t i = 0; i < aCount; i++) {
|
||||
@@ -488,15 +508,15 @@ TelephonyRequestParent::NotifyDialMMISuccessWithCallForwardingOptions(const nsAS
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMIError(const nsAString& aError)
|
||||
TelephonyRequestParent::DialCallback::NotifyDialMMIError(const nsAString& aError)
|
||||
{
|
||||
return SendResponse(DialResponseMMIError(nsAutoString(aError),
|
||||
AdditionalInformation(mozilla::void_t())));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialMMIErrorWithInfo(const nsAString& aError,
|
||||
uint16_t aInfo)
|
||||
TelephonyRequestParent::DialCallback::NotifyDialMMIErrorWithInfo(const nsAString& aError,
|
||||
uint16_t aInfo)
|
||||
{
|
||||
return SendResponse(DialResponseMMIError(nsAutoString(aError),
|
||||
AdditionalInformation(aInfo)));
|
||||
|
||||
@@ -72,15 +72,42 @@ private:
|
||||
|
||||
class TelephonyRequestParent : public PTelephonyRequestParent
|
||||
, public nsITelephonyListener
|
||||
, public nsITelephonyDialCallback
|
||||
{
|
||||
friend class TelephonyParent;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITELEPHONYLISTENER
|
||||
NS_DECL_NSITELEPHONYCALLBACK
|
||||
NS_DECL_NSITELEPHONYDIALCALLBACK
|
||||
|
||||
class Callback : public nsITelephonyCallback {
|
||||
friend class TelephonyRequestParent;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITELEPHONYCALLBACK
|
||||
|
||||
protected:
|
||||
explicit Callback(TelephonyRequestParent& aParent): mParent(aParent) {}
|
||||
virtual ~Callback() {}
|
||||
|
||||
private:
|
||||
nsresult SendResponse(const IPCTelephonyResponse& aResponse);
|
||||
TelephonyRequestParent& mParent;
|
||||
};
|
||||
|
||||
class DialCallback final : public Callback
|
||||
, public nsITelephonyDialCallback {
|
||||
friend class TelephonyRequestParent;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSITELEPHONYDIALCALLBACK
|
||||
NS_FORWARD_NSITELEPHONYCALLBACK(Callback::)
|
||||
|
||||
private:
|
||||
explicit DialCallback(TelephonyRequestParent& aParent): Callback(aParent) {}
|
||||
~DialCallback() {}
|
||||
};
|
||||
|
||||
protected:
|
||||
TelephonyRequestParent();
|
||||
@@ -92,8 +119,20 @@ protected:
|
||||
nsresult
|
||||
SendResponse(const IPCTelephonyResponse& aResponse);
|
||||
|
||||
Callback*
|
||||
GetCallback() {
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
DialCallback*
|
||||
GetDialCallback() {
|
||||
return mDialCallback;
|
||||
}
|
||||
|
||||
private:
|
||||
bool mActorDestroyed;
|
||||
RefPtr<Callback> mCallback;
|
||||
RefPtr<DialCallback> mDialCallback;
|
||||
};
|
||||
|
||||
END_TELEPHONY_NAMESPACE
|
||||
|
||||
@@ -615,10 +615,9 @@ private:
|
||||
}
|
||||
|
||||
// Find the most recent browser window and open a new tab in it.
|
||||
nsCOMPtr<nsIDOMWindow> browserWindow;
|
||||
rv = wm->GetMostRecentWindow(MOZ_UTF16("navigator:browser"),
|
||||
getter_AddRefs(browserWindow));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)) || !browserWindow) {
|
||||
nsCOMPtr<nsPIDOMWindow> browserWindow =
|
||||
nsContentUtils::GetMostRecentNonPBWindow();
|
||||
if (!browserWindow) {
|
||||
// It is possible to be running without a browser window on Mac OS, so
|
||||
// we need to open a new chrome window.
|
||||
// TODO(catalinb): open new chrome window. Bug 1218080
|
||||
|
||||
+53
-71
@@ -259,33 +259,6 @@ namespace dom {
|
||||
// nsISupports interface
|
||||
//
|
||||
|
||||
static PLDHashOperator
|
||||
TraverseTemplateBuilders(nsISupports* aKey, nsIXULTemplateBuilder* aData,
|
||||
void* aContext)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(aContext);
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mTemplateBuilderTable key");
|
||||
cb->NoteXPCOMChild(aKey);
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mTemplateBuilderTable value");
|
||||
cb->NoteXPCOMChild(aData);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
TraverseObservers(nsIURI* aKey, nsIObserver* aData, void* aContext)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(aContext);
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mOverlayLoadObservers/mPendingOverlayLoadNotifications value");
|
||||
cb->NoteXPCOMChild(aData);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(XULDocument)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XULDocument, XMLDocument)
|
||||
@@ -296,20 +269,38 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XULDocument, XMLDocument)
|
||||
|
||||
// An element will only have a template builder as long as it's in the
|
||||
// document, so we'll traverse the table here instead of from the element.
|
||||
if (tmp->mTemplateBuilderTable)
|
||||
tmp->mTemplateBuilderTable->EnumerateRead(TraverseTemplateBuilders, &cb);
|
||||
if (tmp->mTemplateBuilderTable) {
|
||||
for (auto iter = tmp->mTemplateBuilderTable->Iter();
|
||||
!iter.Done();
|
||||
iter.Next()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mTemplateBuilderTable key");
|
||||
cb.NoteXPCOMChild(iter.Key());
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mTemplateBuilderTable value");
|
||||
cb.NoteXPCOMChild(iter.UserData());
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCurrentPrototype)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMasterPrototype)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCommandDispatcher)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrototypes);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrototypes)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocalStore)
|
||||
|
||||
if (tmp->mOverlayLoadObservers) {
|
||||
tmp->mOverlayLoadObservers->EnumerateRead(TraverseObservers, &cb);
|
||||
for (auto iter = tmp->mOverlayLoadObservers->Iter();
|
||||
!iter.Done();
|
||||
iter.Next()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mOverlayLoadObservers value");
|
||||
cb.NoteXPCOMChild(iter.Data());
|
||||
}
|
||||
}
|
||||
if (tmp->mPendingOverlayLoadNotifications) {
|
||||
tmp->mPendingOverlayLoadNotifications->EnumerateRead(TraverseObservers, &cb);
|
||||
for (auto iter = tmp->mPendingOverlayLoadNotifications->Iter();
|
||||
!iter.Done();
|
||||
iter.Next()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mPendingOverlayLoadNotifications value");
|
||||
cb.NoteXPCOMChild(iter.Data());
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
@@ -916,6 +907,23 @@ XULDocument::AttributeWillChange(nsIDocument* aDocument,
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
ShouldPersistAttribute(Element* aElement, nsIAtom* aAttribute)
|
||||
{
|
||||
if (aElement->IsXULElement(nsGkAtoms::window)) {
|
||||
// The following attributes of xul:window should be handled in
|
||||
// nsXULWindow::SavePersistentAttributes instead of here.
|
||||
if (aAttribute == nsGkAtoms::screenX ||
|
||||
aAttribute == nsGkAtoms::screenY ||
|
||||
aAttribute == nsGkAtoms::width ||
|
||||
aAttribute == nsGkAtoms::height ||
|
||||
aAttribute == nsGkAtoms::sizemode) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
XULDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement, int32_t aNameSpaceID,
|
||||
@@ -995,14 +1003,14 @@ XULDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
// XXX Namespace handling broken :-(
|
||||
nsAutoString persist;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist);
|
||||
if (!persist.IsEmpty()) {
|
||||
// Persistence of attributes of xul:window is handled in nsXULWindow.
|
||||
if (ShouldPersistAttribute(aElement, aAttribute) && !persist.IsEmpty() &&
|
||||
// XXXldb This should check that it's a token, not just a substring.
|
||||
if (persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
|
||||
nsContentUtils::AddScriptRunner(NS_NewRunnableMethodWithArgs
|
||||
<nsIContent*, int32_t, nsIAtom*>
|
||||
(this, &XULDocument::DoPersist, aElement, kNameSpaceID_None,
|
||||
aAttribute));
|
||||
}
|
||||
persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
|
||||
nsContentUtils::AddScriptRunner(NS_NewRunnableMethodWithArgs
|
||||
<nsIContent*, int32_t, nsIAtom*>
|
||||
(this, &XULDocument::DoPersist, aElement, kNameSpaceID_None,
|
||||
aAttribute));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2534,25 +2542,12 @@ XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
|
||||
if (aIsDynamic)
|
||||
mResolutionPhase = nsForwardReference::eStart;
|
||||
|
||||
// Chrome documents are allowed to load overlays from anywhere.
|
||||
// In all other cases, the overlay is only allowed to load if
|
||||
// the master document and prototype document have the same origin.
|
||||
|
||||
bool documentIsChrome = IsChromeURI(mDocumentURI);
|
||||
if (!documentIsChrome) {
|
||||
// Make sure we're allowed to load this overlay.
|
||||
rv = NodePrincipal()->CheckMayLoad(aURI, true, false);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aFailureFromContent = true;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Look in the prototype cache for the prototype document with
|
||||
// the specified overlay URI. Only use the cache if the containing
|
||||
// document is chrome otherwise it may not have a system principal and
|
||||
// the cached document will, see bug 565610.
|
||||
bool overlayIsChrome = IsChromeURI(aURI);
|
||||
bool documentIsChrome = IsChromeURI(mDocumentURI);
|
||||
mCurrentPrototype = overlayIsChrome && documentIsChrome ?
|
||||
nsXULPrototypeCache::GetInstance()->GetPrototype(aURI) : nullptr;
|
||||
|
||||
@@ -2636,12 +2631,13 @@ XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
aURI,
|
||||
NodePrincipal(),
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS |
|
||||
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
group);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = channel->AsyncOpen(listener, nullptr);
|
||||
rv = channel->AsyncOpen2(listener);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
@@ -3236,19 +3232,6 @@ XULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, bool* aBlock)
|
||||
}
|
||||
}
|
||||
|
||||
// Allow security manager and content policies to veto the load. Note that
|
||||
// at this point we already lost context information of the script.
|
||||
rv = nsScriptLoader::ShouldLoadScript(
|
||||
this,
|
||||
static_cast<nsIDocument*>(this),
|
||||
aScriptProto->mSrcURI,
|
||||
NS_LITERAL_STRING("application/x-javascript"),
|
||||
false);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aBlock = false;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Release script objects from FastLoad since we decided against using them
|
||||
aScriptProto->UnlinkJSObjects();
|
||||
|
||||
@@ -3258,7 +3241,7 @@ XULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, bool* aBlock)
|
||||
"still loading a script when starting another load?");
|
||||
mCurrentScriptProto = aScriptProto;
|
||||
|
||||
if (aScriptProto->mSrcLoading) {
|
||||
if (isChromeDoc && aScriptProto->mSrcLoading) {
|
||||
// Another XULDocument load has started, which is still in progress.
|
||||
// Remember to ResumeWalk this document when the load completes.
|
||||
mNextSrcLoadWaiter = aScriptProto->mSrcLoadWaiters;
|
||||
@@ -3274,9 +3257,8 @@ XULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, bool* aBlock)
|
||||
aScriptProto->mSrcURI,
|
||||
this, // aObserver
|
||||
this, // aRequestingContext
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // aContext
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS,
|
||||
nsIContentPolicy::TYPE_INTERNAL_SCRIPT,
|
||||
group);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
||||
@@ -222,23 +222,6 @@ nsXULTemplateBuilder::Uninit(bool aIsFinal)
|
||||
mQueriesCompiled = false;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
TraverseMatchList(nsISupports* aKey, nsTemplateMatch* aMatch, void* aContext)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(aContext);
|
||||
|
||||
cb->NoteXPCOMChild(aKey);
|
||||
nsTemplateMatch* match = aMatch;
|
||||
while (match) {
|
||||
cb->NoteXPCOMChild(match->GetContainer());
|
||||
cb->NoteXPCOMChild(match->mResult);
|
||||
match = match->mNext;
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTemplateBuilder)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateBuilder)
|
||||
@@ -269,7 +252,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateBuilder)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRootResult)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListeners)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueryProcessor)
|
||||
tmp->mMatchMap.EnumerateRead(TraverseMatchList, &cb);
|
||||
|
||||
for (auto iter = tmp->mMatchMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
cb.NoteXPCOMChild(iter.Key());
|
||||
nsTemplateMatch* match = iter.UserData();
|
||||
while (match) {
|
||||
cb.NoteXPCOMChild(match->GetContainer());
|
||||
cb.NoteXPCOMChild(match->mResult);
|
||||
match = match->mNext;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t i, count = tmp->mQuerySets.Length();
|
||||
for (i = 0; i < count; ++i) {
|
||||
|
||||
@@ -51,57 +51,32 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateQueryProcessorRDF)
|
||||
tmp->Done();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
static PLDHashOperator
|
||||
BindingDependenciesTraverser(nsISupports* key,
|
||||
nsXULTemplateQueryProcessorRDF::ResultArray* array,
|
||||
void* userArg)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(userArg);
|
||||
|
||||
int32_t i, count = array->Length();
|
||||
for (i = 0; i < count; ++i) {
|
||||
cb->NoteXPCOMChild(array->ElementAt(i));
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
MemoryElementTraverser(const uint32_t& key,
|
||||
nsCOMArray<nsXULTemplateResultRDF>* array,
|
||||
void* userArg)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(userArg);
|
||||
|
||||
int32_t i, count = array->Count();
|
||||
for (i = 0; i < count; ++i) {
|
||||
cb->NoteXPCOMChild(array->ObjectAt(i));
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
RuleToBindingTraverser(nsISupports* key, RDFBindingSet* binding, void* userArg)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(userArg);
|
||||
|
||||
cb->NoteXPCOMChild(key);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateQueryProcessorRDF)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDB)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLastRef)
|
||||
tmp->mBindingDependencies.EnumerateRead(BindingDependenciesTraverser,
|
||||
&cb);
|
||||
tmp->mMemoryElementToResultMap.EnumerateRead(MemoryElementTraverser,
|
||||
&cb);
|
||||
tmp->mRuleToBindingsMap.EnumerateRead(RuleToBindingTraverser, &cb);
|
||||
|
||||
for (auto it = tmp->mBindingDependencies.Iter(); !it.Done(); it.Next()) {
|
||||
nsXULTemplateQueryProcessorRDF::ResultArray* array = it.UserData();
|
||||
int32_t count = array->Length();
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
cb.NoteXPCOMChild(array->ElementAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = tmp->mMemoryElementToResultMap.Iter();
|
||||
!it.Done();
|
||||
it.Next()) {
|
||||
nsCOMArray<nsXULTemplateResultRDF>* array = it.UserData();
|
||||
int32_t count = array->Count();
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
cb.NoteXPCOMChild(array->ObjectAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = tmp->mRuleToBindingsMap.Iter(); !it.Done(); it.Next()) {
|
||||
cb.NoteXPCOMChild(it.Key());
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueries)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
|
||||
@@ -73,16 +73,6 @@ nsXULTemplateResultSetXML::GetNext(nsISupports **aResult)
|
||||
// nsXULTemplateQueryProcessorXML
|
||||
//
|
||||
|
||||
static PLDHashOperator
|
||||
TraverseRuleToBindingsMap(nsISupports* aKey, nsXMLBindingSet* aMatch, void* aContext)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(aContext);
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mRuleToBindingsMap key");
|
||||
cb->NoteXPCOMChild(aKey);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTemplateQueryProcessorXML)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateQueryProcessorXML)
|
||||
@@ -93,7 +83,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateQueryProcessorXML)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRequest)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateQueryProcessorXML)
|
||||
tmp->mRuleToBindingsMap.EnumerateRead(TraverseRuleToBindingsMap, &cb);
|
||||
for (auto it = tmp->mRuleToBindingsMap.Iter(); !it.Done(); it.Next()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRuleToBindingsMap key");
|
||||
cb.NoteXPCOMChild(it.Key());
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEvaluator)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTemplateBuilder)
|
||||
|
||||
@@ -27,9 +27,7 @@ LOCAL_INCLUDES += [
|
||||
'../glue',
|
||||
]
|
||||
|
||||
# XXX: This directory is a mix of Mozilla code and third-party code. We should
|
||||
# put the Mozilla code in a separate directory and disallow compiler warnings
|
||||
# there (bug 1200065). Until then, allow warnings for all of the code.
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
@@ -375,9 +375,11 @@ NS_IMETHODIMP mozPersonalDictionary::Save()
|
||||
return res;
|
||||
}
|
||||
|
||||
nsTArray<nsString> array(mDictionaryTable.Count());
|
||||
nsTArray<nsString> array;
|
||||
nsString* elems = array.AppendElements(mDictionaryTable.Count());
|
||||
for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) {
|
||||
array.AppendElement(nsDependentString(iter.Get()->GetKey()));
|
||||
elems->Assign(iter.Get()->GetKey());
|
||||
elems++;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
@@ -396,9 +398,11 @@ NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator **aWords)
|
||||
|
||||
WaitForLoad();
|
||||
|
||||
nsTArray<nsString> *array = new nsTArray<nsString>(mDictionaryTable.Count());
|
||||
nsTArray<nsString> *array = new nsTArray<nsString>();
|
||||
nsString* elems = array->AppendElements(mDictionaryTable.Count());
|
||||
for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) {
|
||||
array->AppendElement(nsDependentString(iter.Get()->GetKey()));
|
||||
elems->Assign(iter.Get()->GetKey());
|
||||
elems++;
|
||||
}
|
||||
|
||||
array->Sort();
|
||||
|
||||
@@ -153,9 +153,10 @@ mozSpellChecker::CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray
|
||||
char16_t **words;
|
||||
|
||||
result = mSpellCheckingEngine->Suggest(PromiseFlatString(aWord).get(), &words, &count);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
nsString* suggestions = aSuggestions->AppendElements(count);
|
||||
for(i=0;i<count;i++){
|
||||
aSuggestions->AppendElement(nsDependentString(words[i]));
|
||||
suggestions[i].Assign(words[i]);
|
||||
}
|
||||
|
||||
if (count)
|
||||
|
||||
+33
-32
@@ -12,11 +12,7 @@
|
||||
#include "FilterNodeSoftware.h"
|
||||
#include "HelpersSkia.h"
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
#include "skia/include/gpu/SkGpuDevice.h"
|
||||
#include "skia/include/gpu/gl/GrGLInterface.h"
|
||||
#endif
|
||||
|
||||
#include "skia/include/core/SkSurface.h"
|
||||
#include "skia/include/core/SkTypeface.h"
|
||||
#include "skia/include/effects/SkGradientShader.h"
|
||||
#include "skia/include/core/SkColorFilter.h"
|
||||
@@ -148,29 +144,32 @@ bool
|
||||
DrawTargetSkia::LockBits(uint8_t** aData, IntSize* aSize,
|
||||
int32_t* aStride, SurfaceFormat* aFormat)
|
||||
{
|
||||
const SkBitmap &bitmap = mCanvas->getDevice()->accessBitmap(false);
|
||||
if (!bitmap.lockPixelsAreWritable()) {
|
||||
/* Test if the canvas' device has accessible pixels first, as actually
|
||||
* accessing the pixels may trigger side-effects, even if it fails.
|
||||
*/
|
||||
if (!mCanvas->peekPixels(nullptr, nullptr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkImageInfo info;
|
||||
size_t rowBytes;
|
||||
void* pixels = mCanvas->accessTopLayerPixels(&info, &rowBytes);
|
||||
if (!pixels) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MarkChanged();
|
||||
|
||||
bitmap.lockPixels();
|
||||
*aData = reinterpret_cast<uint8_t*>(bitmap.getPixels());
|
||||
*aSize = IntSize(bitmap.width(), bitmap.height());
|
||||
*aStride = int32_t(bitmap.rowBytes());
|
||||
*aFormat = SkiaColorTypeToGfxFormat(bitmap.colorType());
|
||||
*aData = reinterpret_cast<uint8_t*>(pixels);
|
||||
*aSize = IntSize(info.width(), info.height());
|
||||
*aStride = int32_t(rowBytes);
|
||||
*aFormat = SkiaColorTypeToGfxFormat(info.colorType());
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
DrawTargetSkia::ReleaseBits(uint8_t* aData)
|
||||
{
|
||||
const SkBitmap &bitmap = mCanvas->getDevice()->accessBitmap(false);
|
||||
MOZ_ASSERT(bitmap.lockPixelsAreWritable());
|
||||
|
||||
bitmap.unlockPixels();
|
||||
bitmap.notifyPixelsChanged();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -265,7 +264,7 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, TempBitmap& aTmpBitmap
|
||||
SkSafeUnref(shader);
|
||||
SkSafeUnref(aPaint.setShader(matrixShader));
|
||||
if (pat.mFilter == Filter::POINT) {
|
||||
aPaint.setFilterLevel(SkPaint::kNone_FilterLevel);
|
||||
aPaint.setFilterQuality(kNone_SkFilterQuality);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -332,7 +331,7 @@ struct AutoPaintSetup {
|
||||
mPaint.setAlpha(ColorFloatToByte(aOptions.mAlpha));
|
||||
mAlpha = aOptions.mAlpha;
|
||||
}
|
||||
mPaint.setFilterLevel(SkPaint::kLow_FilterLevel);
|
||||
mPaint.setFilterQuality(kLow_SkFilterQuality);
|
||||
}
|
||||
|
||||
// TODO: Maybe add an operator overload to access this easier?
|
||||
@@ -380,10 +379,10 @@ DrawTargetSkia::DrawSurface(SourceSurface *aSurface,
|
||||
|
||||
AutoPaintSetup paint(mCanvas.get(), aOptions, &aDest);
|
||||
if (aSurfOptions.mFilter == Filter::POINT) {
|
||||
paint.mPaint.setFilterLevel(SkPaint::kNone_FilterLevel);
|
||||
paint.mPaint.setFilterQuality(kNone_SkFilterQuality);
|
||||
}
|
||||
|
||||
mCanvas->drawBitmapRectToRect(bitmap.mBitmap, &sourceRect, destRect, &paint.mPaint);
|
||||
mCanvas->drawBitmapRect(bitmap.mBitmap, sourceRect, destRect, &paint.mPaint);
|
||||
}
|
||||
|
||||
DrawTargetType
|
||||
@@ -791,9 +790,7 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
|
||||
SkBitmap bm(bitmap.mBitmap);
|
||||
bm.lockPixels();
|
||||
if (bm.getPixels()) {
|
||||
SkImageInfo info = bm.info();
|
||||
info.fWidth = aSourceRect.width;
|
||||
info.fHeight = aSourceRect.height;
|
||||
SkImageInfo info = bm.info().makeWH(aSourceRect.width, aSourceRect.height);
|
||||
uint8_t* pixels = static_cast<uint8_t*>(bm.getPixels());
|
||||
// adjust pixels for the source offset
|
||||
pixels += aSourceRect.x + aSourceRect.y*bm.rowBytes();
|
||||
@@ -825,7 +822,7 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
|
||||
clearPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
mCanvas->drawPaint(clearPaint);
|
||||
}
|
||||
mCanvas->drawBitmapRect(bitmap.mBitmap, &source, dest, &paint);
|
||||
mCanvas->drawBitmapRect(bitmap.mBitmap, source, dest, &paint);
|
||||
mCanvas->restore();
|
||||
}
|
||||
|
||||
@@ -848,7 +845,7 @@ DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
|
||||
|
||||
SkBitmap bitmap;
|
||||
bitmap.setInfo(skiInfo, stride);
|
||||
if (!bitmap.allocPixels()) {
|
||||
if (!bitmap.tryAllocPixels()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -877,24 +874,28 @@ DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
|
||||
mSize = aSize;
|
||||
mFormat = aFormat;
|
||||
|
||||
GrTextureDesc targetDescriptor;
|
||||
GrSurfaceDesc targetDescriptor;
|
||||
|
||||
targetDescriptor.fFlags = kRenderTarget_GrTextureFlagBit;
|
||||
targetDescriptor.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
targetDescriptor.fWidth = mSize.width;
|
||||
targetDescriptor.fHeight = mSize.height;
|
||||
targetDescriptor.fConfig = GfxFormatToGrConfig(mFormat);
|
||||
targetDescriptor.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
targetDescriptor.fSampleCnt = 0;
|
||||
|
||||
SkAutoTUnref<GrTexture> skiaTexture(mGrContext->createUncachedTexture(targetDescriptor, NULL, 0));
|
||||
SkAutoTUnref<GrTexture> skiaTexture(mGrContext->textureProvider()->createTexture(targetDescriptor, SkSurface::kNo_Budgeted, nullptr, 0));
|
||||
if (!skiaTexture) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mTexture = (uint32_t)skiaTexture->getTextureHandle();
|
||||
SkAutoTUnref<SkSurface> gpuSurface(SkSurface::NewRenderTargetDirect(skiaTexture->asRenderTarget()));
|
||||
if (!gpuSurface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(mGrContext.get(), skiaTexture->asRenderTarget()));
|
||||
mCanvas.adopt(new SkCanvas(device.get()));
|
||||
mTexture = reinterpret_cast<GrGLTextureInfo *>(skiaTexture->getTextureHandle())->fID;
|
||||
|
||||
mCanvas = gpuSurface->getCanvas();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ private:
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
RefPtrSkia<GrContext> mGrContext;
|
||||
uint32_t mTexture;
|
||||
GrGLuint mTexture;
|
||||
#endif
|
||||
|
||||
IntSize mSize;
|
||||
|
||||
@@ -41,20 +41,20 @@ SkTypeface* ScaledFontCairo::GetSkTypeface()
|
||||
{
|
||||
if (!mTypeface) {
|
||||
cairo_font_face_t* fontFace = cairo_scaled_font_get_font_face(mScaledFont);
|
||||
MOZ_ASSERT(cairo_font_face_status(fontFace) == CAIRO_STATUS_SUCCESS);
|
||||
|
||||
FT_Face face = cairo_ft_scaled_font_lock_face(mScaledFont);
|
||||
|
||||
int style = SkTypeface::kNormal;
|
||||
|
||||
if (face->style_flags & FT_STYLE_FLAG_ITALIC)
|
||||
style |= SkTypeface::kItalic;
|
||||
|
||||
if (face->style_flags & FT_STYLE_FLAG_BOLD)
|
||||
style |= SkTypeface::kBold;
|
||||
SkFontStyle style(face->style_flags & FT_STYLE_FLAG_BOLD ?
|
||||
SkFontStyle::kBold_Weight : SkFontStyle::kNormal_Weight,
|
||||
SkFontStyle::kNormal_Width,
|
||||
face->style_flags & FT_STYLE_FLAG_ITALIC ?
|
||||
SkFontStyle::kItalic_Slant : SkFontStyle::kUpright_Slant);
|
||||
|
||||
bool isFixedWidth = face->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
|
||||
cairo_ft_scaled_font_unlock_face(mScaledFont);
|
||||
|
||||
mTypeface = SkCreateTypefaceFromCairoFont(fontFace, (SkTypeface::Style)style, isFixedWidth);
|
||||
mTypeface = SkCreateTypefaceFromCairoFont(fontFace, style, isFixedWidth);
|
||||
}
|
||||
|
||||
return mTypeface;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "DataSurfaceHelpers.h"
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
#include "GLDefs.h"
|
||||
#include "skia/include/gpu/SkGrPixelRef.h"
|
||||
#endif
|
||||
|
||||
@@ -50,13 +51,11 @@ SourceSurfaceSkia::InitFromCanvas(SkCanvas* aCanvas,
|
||||
SurfaceFormat aFormat,
|
||||
DrawTargetSkia* aOwner)
|
||||
{
|
||||
SkISize size = aCanvas->getDeviceSize();
|
||||
|
||||
mBitmap = (SkBitmap)aCanvas->getDevice()->accessBitmap(false);
|
||||
mBitmap = aCanvas->getDevice()->accessBitmap(false);
|
||||
|
||||
mFormat = aFormat;
|
||||
|
||||
mSize = IntSize(size.fWidth, size.fHeight);
|
||||
mSize = IntSize(mBitmap.width(), mBitmap.height());
|
||||
mStride = mBitmap.rowBytes();
|
||||
mDrawTarget = aOwner;
|
||||
|
||||
@@ -84,10 +83,6 @@ SourceSurfaceSkia::InitFromData(unsigned char* aData,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aFormat == SurfaceFormat::B8G8R8X8) {
|
||||
mBitmap.setAlphaType(kIgnore_SkAlphaType);
|
||||
}
|
||||
|
||||
mSize = aSize;
|
||||
mFormat = aFormat;
|
||||
mStride = mBitmap.rowBytes();
|
||||
@@ -109,11 +104,15 @@ SourceSurfaceSkia::InitFromTexture(DrawTargetSkia* aOwner,
|
||||
skiaTexGlue.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
skiaTexGlue.fConfig = GfxFormatToGrConfig(aFormat);
|
||||
skiaTexGlue.fSampleCnt = 0;
|
||||
skiaTexGlue.fTextureHandle = aTexture;
|
||||
|
||||
GrTexture *skiaTexture = aOwner->mGrContext->wrapBackendTexture(skiaTexGlue);
|
||||
GrGLTextureInfo texInfo;
|
||||
texInfo.fTarget = LOCAL_GL_TEXTURE_2D;
|
||||
texInfo.fID = aTexture;
|
||||
skiaTexGlue.fTextureHandle = reinterpret_cast<GrBackendObject>(&texInfo);
|
||||
|
||||
GrTexture *skiaTexture = aOwner->mGrContext->textureProvider()->wrapBackendTexture(skiaTexGlue);
|
||||
SkImageInfo imgInfo = SkImageInfo::Make(aSize.width, aSize.height, GfxFormatToSkiaColorType(aFormat), kOpaque_SkAlphaType);
|
||||
SkGrPixelRef *texRef = new SkGrPixelRef(imgInfo, skiaTexture, false);
|
||||
SkGrPixelRef *texRef = new SkGrPixelRef(imgInfo, skiaTexture);
|
||||
mBitmap.setInfo(imgInfo);
|
||||
mBitmap.setPixelRef(texRef);
|
||||
mFormat = aFormat;
|
||||
|
||||
+11
-12
@@ -108,8 +108,7 @@ SOURCES += [
|
||||
'src/compiler/translator/glslang_tab.cpp',
|
||||
]
|
||||
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
if CONFIG['GNU_CXX'] or CONFIG['CLANG_CL']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-attributes',
|
||||
'-Wno-shadow',
|
||||
@@ -117,16 +116,16 @@ if CONFIG['GNU_CXX']:
|
||||
'-Wno-unknown-pragmas',
|
||||
'-Wno-unreachable-code',
|
||||
]
|
||||
if CONFIG['CLANG_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-inconsistent-missing-override',
|
||||
'-Wno-unused-private-field',
|
||||
]
|
||||
else:
|
||||
CXXFLAGS += [
|
||||
'-Wno-shadow-compatible-local',
|
||||
'-Wno-shadow-local',
|
||||
]
|
||||
if CONFIG['GNU_CXX'] and not CONFIG['CLANG_CXX'] and not CONFIG['CLANG_CL']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-shadow-compatible-local',
|
||||
'-Wno-shadow-local',
|
||||
]
|
||||
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-inconsistent-missing-override',
|
||||
'-Wno-unused-private-field',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_DIRECTX_SDK_PATH'] and not CONFIG['MOZ_HAS_WINSDK_WITH_D3D']:
|
||||
LOCAL_INCLUDES += ['%' + '%s/include/' % CONFIG['MOZ_DIRECTX_SDK_PATH']]
|
||||
|
||||
@@ -328,5 +328,5 @@ if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']:
|
||||
SOURCES['renderer/d3d/d3d11/SwapChain11.cpp'].flags += ['-DANGLE_RESOURCE_SHARE_TYPE=D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX']
|
||||
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
# ALLOW_COMPILER_WARNINGS = True
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ UNIFIED_SOURCES += [
|
||||
'cairo.c',
|
||||
]
|
||||
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
FINAL_LIBRARY = 'gkmedias'
|
||||
@@ -207,7 +208,7 @@ if CONFIG['MOZ_TREE_FREETYPE']:
|
||||
DEFINES['FT_LCD_FILTER_H'] = '%s/modules/freetype2/include/freetype/ftlcdfil.h' % TOPSRCDIR
|
||||
|
||||
# Suppress warnings in third-party code.
|
||||
if CONFIG['GNU_CC']:
|
||||
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
|
||||
CFLAGS += [
|
||||
'-Wno-enum-compare',
|
||||
'-Wno-int-to-pointer-cast',
|
||||
@@ -216,13 +217,19 @@ if CONFIG['GNU_CC']:
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-conversion',
|
||||
]
|
||||
if CONFIG['CLANG_CXX']:
|
||||
if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
|
||||
CFLAGS += [
|
||||
'-Wno-incompatible-pointer-types',
|
||||
'-Wno-tautological-compare',
|
||||
'-Wno-tautological-constant-out-of-range-compare',
|
||||
'-Wno-error=uninitialized',
|
||||
]
|
||||
if CONFIG['CLANG_CL']:
|
||||
CFLAGS += [
|
||||
'-Wno-deprecated-register',
|
||||
'-Wno-macro-redefined',
|
||||
'-Wno-unused-variable',
|
||||
]
|
||||
|
||||
# See bug 386897.
|
||||
if CONFIG['GNU_CC'] and CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_OPTIMIZE']:
|
||||
|
||||
@@ -89,6 +89,11 @@ GrGLvoid glBlendColor_mozilla(GrGLclampf red, GrGLclampf green, GrGLclampf blue,
|
||||
return sGLContext.get()->fBlendColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
GrGLvoid glBlendEquation_mozilla(GrGLenum mode)
|
||||
{
|
||||
return sGLContext.get()->fBlendEquation(mode);
|
||||
}
|
||||
|
||||
GrGLvoid glBlendFunc_mozilla(GrGLenum sfactor, GrGLenum dfactor)
|
||||
{
|
||||
return sGLContext.get()->fBlendFunc(sfactor, dfactor);
|
||||
@@ -315,6 +320,11 @@ GrGLvoid glGetShaderiv_mozilla(GrGLuint shader, GrGLenum pname, GrGLint* params)
|
||||
return sGLContext.get()->fGetShaderiv(shader, pname, params);
|
||||
}
|
||||
|
||||
GrGLvoid glGetShaderPrecisionFormat_mozilla(GrGLenum shadertype, GrGLenum precisiontype, GLint *range, GLint *precision)
|
||||
{
|
||||
return sGLContext.get()->fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
|
||||
}
|
||||
|
||||
const GLubyte* glGetString_mozilla(GrGLenum name)
|
||||
{
|
||||
// GLContext only exposes a OpenGL 2.0 style API, so we have to intercept a bunch
|
||||
@@ -357,6 +367,12 @@ const GLubyte* glGetString_mozilla(GrGLenum name)
|
||||
if (sGLContext.get()->IsSupported(GLFeature::standard_derivatives)) {
|
||||
strcat(extensionsString, "GL_OES_standard_derivatives ");
|
||||
}
|
||||
} else {
|
||||
if (sGLContext.get()->IsSupported(GLFeature::framebuffer_object)) {
|
||||
strcat(extensionsString, "GL_ARB_framebuffer_object ");
|
||||
} else if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_framebuffer_object)) {
|
||||
strcat(extensionsString, "GL_EXT_framebuffer_object ");
|
||||
}
|
||||
}
|
||||
|
||||
if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_texture_format_BGRA8888)) {
|
||||
@@ -581,6 +597,21 @@ GrGLvoid glUseProgram_mozilla(GrGLuint program)
|
||||
return sGLContext.get()->fUseProgram(program);
|
||||
}
|
||||
|
||||
GrGLvoid glVertexAttrib1f_mozilla(GrGLuint index, GrGLfloat value)
|
||||
{
|
||||
return sGLContext.get()->fVertexAttrib1f(index, value);
|
||||
}
|
||||
|
||||
GrGLvoid glVertexAttrib2fv_mozilla(GrGLuint index, const GrGLfloat* values)
|
||||
{
|
||||
return sGLContext.get()->fVertexAttrib2fv(index, values);
|
||||
}
|
||||
|
||||
GrGLvoid glVertexAttrib3fv_mozilla(GrGLuint index, const GrGLfloat* values)
|
||||
{
|
||||
return sGLContext.get()->fVertexAttrib3fv(index, values);
|
||||
}
|
||||
|
||||
GrGLvoid glVertexAttrib4fv_mozilla(GrGLuint index, const GrGLfloat* values)
|
||||
{
|
||||
return sGLContext.get()->fVertexAttrib4fv(index, values);
|
||||
@@ -767,6 +798,7 @@ static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
|
||||
i->fFunctions.fBindTexture = glBindTexture_mozilla;
|
||||
i->fFunctions.fBlendFunc = glBlendFunc_mozilla;
|
||||
i->fFunctions.fBlendColor = glBlendColor_mozilla;
|
||||
i->fFunctions.fBlendEquation = glBlendEquation_mozilla;
|
||||
i->fFunctions.fBufferData = glBufferData_mozilla;
|
||||
i->fFunctions.fBufferSubData = glBufferSubData_mozilla;
|
||||
i->fFunctions.fCheckFramebufferStatus = glCheckFramebufferStatus_mozilla;
|
||||
@@ -811,6 +843,7 @@ static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
|
||||
i->fFunctions.fGetRenderbufferParameteriv = glGetRenderbufferParameteriv_mozilla;
|
||||
i->fFunctions.fGetShaderInfoLog = glGetShaderInfoLog_mozilla;
|
||||
i->fFunctions.fGetShaderiv = glGetShaderiv_mozilla;
|
||||
i->fFunctions.fGetShaderPrecisionFormat = glGetShaderPrecisionFormat_mozilla;
|
||||
i->fFunctions.fGetString = glGetString_mozilla;
|
||||
i->fFunctions.fGetUniformLocation = glGetUniformLocation_mozilla;
|
||||
i->fFunctions.fLineWidth = glLineWidth_mozilla;
|
||||
@@ -847,6 +880,9 @@ static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
|
||||
i->fFunctions.fUniformMatrix3fv = glUniformMatrix3fv_mozilla;
|
||||
i->fFunctions.fUniformMatrix4fv = glUniformMatrix4fv_mozilla;
|
||||
i->fFunctions.fUseProgram = glUseProgram_mozilla;
|
||||
i->fFunctions.fVertexAttrib1f = glVertexAttrib1f_mozilla;
|
||||
i->fFunctions.fVertexAttrib2fv = glVertexAttrib2fv_mozilla;
|
||||
i->fFunctions.fVertexAttrib3fv = glVertexAttrib3fv_mozilla;
|
||||
i->fFunctions.fVertexAttrib4fv = glVertexAttrib4fv_mozilla;
|
||||
i->fFunctions.fVertexAttribPointer = glVertexAttribPointer_mozilla;
|
||||
i->fFunctions.fViewport = glViewport_mozilla;
|
||||
|
||||
@@ -254,9 +254,9 @@ Transform(DataSourceSurface* aDest,
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
|
||||
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||
SkRect destRect = SkRect::MakeXYWH(0, 0, srcSize.width, srcSize.height);
|
||||
destCanvas.drawBitmapRectToRect(src, nullptr, destRect, &paint);
|
||||
destCanvas.drawBitmapRect(src, destRect, &paint);
|
||||
}
|
||||
#else
|
||||
static pixman_transform
|
||||
|
||||
@@ -742,9 +742,9 @@ Transform(const gfxImageSurface* aDest,
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
|
||||
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||
SkRect destRect = SkRect::MakeXYWH(0, 0, srcSize.width, srcSize.height);
|
||||
destCanvas.drawBitmapRectToRect(src, nullptr, destRect, &paint);
|
||||
destCanvas.drawBitmapRect(src, destRect, &paint);
|
||||
}
|
||||
#else
|
||||
static pixman_transform
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
The source from this directory was copied from the skia subversion trunk
|
||||
using the update.sh script. The changes made were those applied by update.sh,
|
||||
the addition/update of Makefile.in files for the Mozilla build system.
|
||||
|
||||
This is an import of Skia from 2014-07-28 (b1ab5fdd11bb358d738c1bfa63737dc65174a281)
|
||||
|
||||
To update to a new version of Skia:
|
||||
|
||||
- Copy the entire trunk/ directory from a Skia clone to mozilla-central/gfx/skia
|
||||
- Clone Skia from upstream using the instructions here: https://sites.google.com/site/skiadocs/user-documentation/downloading
|
||||
- Copy the entire source tree from a Skia clone to mozilla-central/gfx/skia/skia
|
||||
- cd gfx/skia && ./gyp_mozbuild
|
||||
|
||||
Once that's done, use git status to view the files that have changed. Keep an eye on GrUserConfig.h
|
||||
|
||||
+70
-124
@@ -3,6 +3,7 @@
|
||||
import os
|
||||
|
||||
import locale
|
||||
from collections import defaultdict
|
||||
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
||||
|
||||
header = """
|
||||
@@ -24,34 +25,12 @@ header = """
|
||||
|
||||
footer = """
|
||||
|
||||
# can we find a better way of dealing with asm sources?
|
||||
|
||||
# left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with
|
||||
#XXX: doesn't build with Apple's assembler
|
||||
if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['OS_TARGET'] != 'Darwin':
|
||||
SOURCES += [
|
||||
'skia/src/opts/memset.arm.S',
|
||||
]
|
||||
if CONFIG['BUILD_ARM_NEON']:
|
||||
SOURCES += [
|
||||
'skia/src/opts/memset16_neon.S',
|
||||
'skia/src/opts/memset32_neon.S',
|
||||
]
|
||||
|
||||
if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC'] and CONFIG['OS_ARCH'] != 'WINNT':
|
||||
if CONFIG['CPU_ARCH'] == 'x86_64':
|
||||
SOURCES += [
|
||||
'skia/src/opts/SkBlitRow_opts_SSE4_x64_asm.S',
|
||||
]
|
||||
else:
|
||||
SOURCES += [
|
||||
'skia/src/opts/SkBlitRow_opts_SSE4_asm.S',
|
||||
]
|
||||
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
FINAL_LIBRARY = 'gkmedias'
|
||||
LOCAL_INCLUDES += [
|
||||
'skia/include/c',
|
||||
'skia/include/config',
|
||||
'skia/include/core',
|
||||
'skia/include/effects',
|
||||
@@ -60,6 +39,7 @@ LOCAL_INCLUDES += [
|
||||
'skia/include/pathops',
|
||||
'skia/include/pipe',
|
||||
'skia/include/ports',
|
||||
'skia/include/private',
|
||||
'skia/include/utils',
|
||||
'skia/include/utils/mac',
|
||||
'skia/include/utils/win',
|
||||
@@ -77,12 +57,6 @@ LOCAL_INCLUDES += [
|
||||
'skia/src/utils/win',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in {'android', 'gtk2', 'gtk3', 'qt', 'gonk', 'cocoa', 'uikit'}:
|
||||
DEFINES['SK_USE_POSIX_THREADS'] = 1
|
||||
|
||||
if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['HAVE_TOOLCHAIN_SUPPORT_MSSSE3']:
|
||||
DEFINES['SK_BUILD_SSSE3'] = 1
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
|
||||
DEFINES['SK_FONTHOST_CAIRO_STANDALONE'] = 0
|
||||
|
||||
@@ -104,42 +78,34 @@ if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
|
||||
if CONFIG['_MSC_VER']:
|
||||
# MSVC doesn't need special compiler flags, but Skia needs to be told that these files should
|
||||
# be built with the required SSE level or it will simply compile in stubs and cause runtime crashes
|
||||
SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=31']
|
||||
SOURCES['skia/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=41']
|
||||
SOURCES['skia/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkXfermode_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
|
||||
SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=31']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE4.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=41']
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=31']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=41']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['/arch:AVX -DSK_CPU_SSE_LEVEL=51']
|
||||
if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
|
||||
SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkMorphology_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkUtils_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkXfermode_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
|
||||
elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']:
|
||||
DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1
|
||||
DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0
|
||||
DEFINES['SK_ARM_HAS_OPTIONAL_NEON'] = 1
|
||||
elif CONFIG['CLANG_CL']:
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
|
||||
if CONFIG['GNU_CXX'] and CONFIG['CPU_ARCH'] == 'arm':
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
|
||||
|
||||
DEFINES['SKIA_IMPLEMENTATION'] = 1
|
||||
DEFINES['GR_IMPLEMENTATION'] = 1
|
||||
|
||||
# Suppress warnings in third-party code.
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-deprecated-declarations',
|
||||
@@ -147,18 +113,22 @@ if CONFIG['GNU_CXX']:
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-unused-function',
|
||||
]
|
||||
if CONFIG['GNU_CXX'] and not CONFIG['CLANG_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-logical-op',
|
||||
'-Wno-maybe-uninitialized',
|
||||
]
|
||||
if CONFIG['CLANG_CXX']:
|
||||
if CONFIG['CLANG_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-implicit-fallthrough',
|
||||
'-Wno-inconsistent-missing-override',
|
||||
'-Wno-macro-redefined',
|
||||
'-Wno-unused-private-field',
|
||||
]
|
||||
# work around inline function linking bug with template arguments
|
||||
SOURCES['skia/src/gpu/GrResourceCache.cpp'].flags += ['-fkeep-inline-functions']
|
||||
else:
|
||||
CXXFLAGS += [
|
||||
'-Wno-logical-op',
|
||||
'-Wno-maybe-uninitialized',
|
||||
]
|
||||
if CONFIG['CPU_ARCH'] == 'arm':
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
|
||||
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
|
||||
@@ -185,7 +155,7 @@ def generate_platform_sources():
|
||||
sources = {}
|
||||
|
||||
for plat in platforms:
|
||||
if os.system("cd skia && GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=%s gyp/skia_lib.gyp" % plat) != 0:
|
||||
if os.system("cd skia && GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=%s -D host_os=linux gyp/skia_lib.gyp" % plat) != 0:
|
||||
print 'Failed to generate sources for ' + plat
|
||||
continue
|
||||
|
||||
@@ -200,31 +170,26 @@ def generate_platform_sources():
|
||||
def generate_separated_sources(platform_sources):
|
||||
blacklist = [
|
||||
'ChromeUtils',
|
||||
'SkImageDecoder_',
|
||||
'_gif',
|
||||
'SkFontConfigParser_android',
|
||||
'SkJpeg',
|
||||
'SkXML',
|
||||
'SkCity',
|
||||
'GrGLCreateNativeInterface',
|
||||
'SkCreatePlatformGLContext',
|
||||
'fontconfig',
|
||||
'SkCondVar',
|
||||
'SkThreadUtils_pthread_',
|
||||
'SkImage_Codec',
|
||||
'SkBitmapChecksummer',
|
||||
'SkNativeGLContext',
|
||||
'SkFontConfig',
|
||||
'SkFontHost_win_dw',
|
||||
'SkFontMgr_android',
|
||||
'SkFontMgr_custom',
|
||||
'SkFontHost_FreeType.cpp',
|
||||
'SkForceLinking',
|
||||
'SkMovie',
|
||||
'SkImageDecoder',
|
||||
'SkImageEncoder',
|
||||
'SkBitmapHasher',
|
||||
'SkBitmapRegion',
|
||||
'codec',
|
||||
'SkWGL',
|
||||
'SkImages',
|
||||
'SkDiscardableMemory_ashmem',
|
||||
'SkMemory_malloc',
|
||||
'SkOpts_',
|
||||
'opts_check_x86',
|
||||
'third_party',
|
||||
]
|
||||
@@ -238,30 +203,18 @@ def generate_separated_sources(platform_sources):
|
||||
|
||||
separated = defaultdict(set, {
|
||||
'common': {
|
||||
#'skia/src/effects/gradients/SkGradientTileProc.cpp',
|
||||
'skia/src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
|
||||
'skia/src/ports/SkDiscardableMemory_none.cpp',
|
||||
'skia/src/ports/SkImageDecoder_empty.cpp',
|
||||
'skia/src/ports/SkMemory_mozalloc.cpp',
|
||||
# 'skia/src/images/SkImages.cpp',
|
||||
# 'skia/src/images/SkImageRef.cpp',
|
||||
# 'skia/src/images/SkImageRef_GlobalPool.cpp',
|
||||
# 'skia/src/images/SkImageRefPool.cpp',
|
||||
# 'skia/src/images/SkImageDecoder.cpp',
|
||||
# 'skia/src/images/SkImageDecoder_Factory.cpp',
|
||||
},
|
||||
'android': {
|
||||
# 'skia/src/ports/SkDebug_android.cpp',
|
||||
'skia/src/ports/SkFontHost_android_old.cpp',
|
||||
'skia/src/ports/SkFontHost_cairo.cpp',
|
||||
# 'skia/src/ports/SkFontHost_FreeType.cpp',
|
||||
# 'skia/src/ports/SkFontHost_FreeType_common.cpp',
|
||||
# 'skia/src/ports/SkThread_pthread.cpp',
|
||||
# 'skia/src/ports/SkPurgeableMemoryBlock_android.cpp',
|
||||
# 'skia/src/ports/SkTime_Unix.cpp',
|
||||
# 'skia/src/utils/SkThreadUtils_pthread.cpp',
|
||||
# 'skia/src/images/SkImageRef_ashmem.cpp',
|
||||
# 'skia/src/utils/android/ashmem.cpp',
|
||||
},
|
||||
'linux': {
|
||||
'skia/src/ports/SkFontHost_cairo.cpp',
|
||||
@@ -269,57 +222,43 @@ def generate_separated_sources(platform_sources):
|
||||
'intel': {
|
||||
# There is currently no x86-specific opt for SkTextureCompression
|
||||
'skia/src/opts/opts_check_x86.cpp',
|
||||
'skia/src/opts/SkTextureCompression_opts_none.cpp',
|
||||
'skia/src/opts/SkOpts_ssse3.cpp',
|
||||
'skia/src/opts/SkOpts_sse41.cpp',
|
||||
'skia/src/opts/SkOpts_avx.cpp',
|
||||
},
|
||||
'arm': {
|
||||
'skia/src/opts/SkUtils_opts_arm.cpp',
|
||||
'skia/src/core/SkUtilsArm.cpp',
|
||||
},
|
||||
'neon': {
|
||||
'skia/src/opts/SkOpts_neon.cpp',
|
||||
'skia/src/opts/SkBitmapProcState_arm_neon.cpp',
|
||||
},
|
||||
'none': {
|
||||
'skia/src/opts/SkUtils_opts_none.cpp',
|
||||
}
|
||||
'none': set()
|
||||
})
|
||||
|
||||
for plat in platform_sources.keys():
|
||||
if not separated.has_key(plat):
|
||||
separated[plat] = set()
|
||||
|
||||
for value in platform_sources[plat]:
|
||||
if isblacklisted(value):
|
||||
continue
|
||||
|
||||
if value.find('_SSE') > 0 or value.find('_SSSE') > 0 or value.find('_SSE4') > 0 : #lol
|
||||
separated['intel'].add(value)
|
||||
if value in separated['common']:
|
||||
continue
|
||||
|
||||
if value.find('_neon') > 0:
|
||||
separated['neon'].add(value)
|
||||
continue
|
||||
key = plat
|
||||
|
||||
if value.find('_arm') > 0:
|
||||
separated['arm'].add(value)
|
||||
continue
|
||||
if '_SSE' in value or '_SSSE' in value:
|
||||
key = 'intel'
|
||||
elif '_neon' in value:
|
||||
key = 'neon'
|
||||
elif '_arm' in value:
|
||||
key = 'arm'
|
||||
elif '_none' in value:
|
||||
key = 'none'
|
||||
elif all(value in platform_sources.get(p, {})
|
||||
for p in platforms if p != plat):
|
||||
key = 'common'
|
||||
|
||||
if value.find('_none') > 0:
|
||||
separated['none'].add(value)
|
||||
continue
|
||||
|
||||
found = True
|
||||
for other in platforms:
|
||||
if other == plat or not platform_sources.has_key(other):
|
||||
continue
|
||||
|
||||
if not value in platform_sources[other]:
|
||||
found = False
|
||||
break;
|
||||
|
||||
if found:
|
||||
separated['common'].add(value)
|
||||
else:
|
||||
separated[plat].add(value)
|
||||
separated[key].add(value)
|
||||
|
||||
return separated
|
||||
|
||||
@@ -333,7 +272,7 @@ def write_cflags(f, values, subsearch, cflag, indent):
|
||||
for _ in range(indent):
|
||||
f.write(' ')
|
||||
|
||||
val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
|
||||
val_list = uniq(sorted(values, key=lambda x: x.lower()))
|
||||
|
||||
if len(val_list) == 0:
|
||||
return
|
||||
@@ -360,15 +299,22 @@ def write_sources(f, values, indent):
|
||||
'SkBlitter_Sprite.cpp',
|
||||
'SkBlitRow_opts_arm.cpp',
|
||||
'SkScan_Antihair.cpp',
|
||||
'SkCondVar.cpp',
|
||||
'SkParse.cpp',
|
||||
'GrAddPathRenderers_default.cpp',
|
||||
'GrDistanceFieldTextContext.cpp',
|
||||
'SkSHA1.cpp',
|
||||
'SkMD5.cpp',
|
||||
'SkPictureData.cpp',
|
||||
'SkScaledImageCache.cpp',
|
||||
'opts_check_x86.cpp',
|
||||
'GrDrawContext',
|
||||
'GrResourceCache',
|
||||
'GrAA',
|
||||
'GrGL',
|
||||
'GrBatchAtlas.cpp',
|
||||
'SkArithmeticMode_gpu.cpp',
|
||||
'SkImage_Gpu.cpp',
|
||||
'SkPathOpsDebug.cpp',
|
||||
'SkParsePath.cpp',
|
||||
'SkOpts',
|
||||
'SkRecorder.cpp',
|
||||
]
|
||||
|
||||
def isblacklisted(value):
|
||||
@@ -396,7 +342,7 @@ def write_list(f, name, values, indent):
|
||||
for _ in range(indent):
|
||||
f.write(' ')
|
||||
|
||||
val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
|
||||
val_list = uniq(sorted(values, key=lambda x: x.lower()))
|
||||
|
||||
if len(val_list) == 0:
|
||||
return
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Install our generator
|
||||
cp dump_mozbuild.py trunk/third_party/externals/gyp/pylib/gyp/generator
|
||||
cp dump_mozbuild.py skia/third_party/externals/gyp/pylib/gyp/generator
|
||||
|
||||
# pushd trunk
|
||||
# pushd skia
|
||||
# for OS in win linux mac; do
|
||||
# GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=$OS -D arm_neon=0 gyp/effects.gyp
|
||||
# done
|
||||
|
||||
+247
-190
@@ -14,26 +14,31 @@
|
||||
# DO NOT MODIFY THIS FILE IT IS AUTOGENERATED.
|
||||
#
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/c/sk_paint.cpp',
|
||||
'skia/src/c/sk_surface.cpp',
|
||||
'skia/src/core/SkAAClip.cpp',
|
||||
'skia/src/core/SkAlphaRuns.cpp',
|
||||
'skia/src/core/SkAnnotation.cpp',
|
||||
'skia/src/core/SkBBHFactory.cpp',
|
||||
'skia/src/core/SkBBoxHierarchyRecord.cpp',
|
||||
'skia/src/core/SkBBoxRecord.cpp',
|
||||
'skia/src/core/SkBigPicture.cpp',
|
||||
'skia/src/core/SkBitmap.cpp',
|
||||
'skia/src/core/SkBitmap_scroll.cpp',
|
||||
'skia/src/core/SkBitmapCache.cpp',
|
||||
'skia/src/core/SkBitmapController.cpp',
|
||||
'skia/src/core/SkBitmapDevice.cpp',
|
||||
'skia/src/core/SkBitmapFilter.cpp',
|
||||
'skia/src/core/SkBitmapHeap.cpp',
|
||||
'skia/src/core/SkBitmapProcShader.cpp',
|
||||
'skia/src/core/SkBitmapProcState.cpp',
|
||||
'skia/src/core/SkBitmapProvider.cpp',
|
||||
'skia/src/core/SkBitmapScaler.cpp',
|
||||
'skia/src/core/SkBlitMask_D32.cpp',
|
||||
'skia/src/core/SkBlitRow_D16.cpp',
|
||||
'skia/src/core/SkBlitRow_D32.cpp',
|
||||
'skia/src/core/SkBlitter.cpp',
|
||||
'skia/src/core/SkBuffer.cpp',
|
||||
'skia/src/core/SkCachedData.cpp',
|
||||
'skia/src/core/SkCanvas.cpp',
|
||||
'skia/src/core/SkChecksum.cpp',
|
||||
'skia/src/core/SkChunkAlloc.cpp',
|
||||
'skia/src/core/SkClipStack.cpp',
|
||||
'skia/src/core/SkColor.cpp',
|
||||
@@ -53,6 +58,7 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/core/SkDistanceFieldGen.cpp',
|
||||
'skia/src/core/SkDither.cpp',
|
||||
'skia/src/core/SkDraw.cpp',
|
||||
'skia/src/core/SkDrawable.cpp',
|
||||
'skia/src/core/SkDrawLooper.cpp',
|
||||
'skia/src/core/SkEdge.cpp',
|
||||
'skia/src/core/SkEdgeBuilder.cpp',
|
||||
@@ -62,75 +68,85 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/core/SkFilterShader.cpp',
|
||||
'skia/src/core/SkFlattenable.cpp',
|
||||
'skia/src/core/SkFlattenableSerialization.cpp',
|
||||
'skia/src/core/SkFloat.cpp',
|
||||
'skia/src/core/SkFloatBits.cpp',
|
||||
'skia/src/core/SkFont.cpp',
|
||||
'skia/src/core/SkFontDescriptor.cpp',
|
||||
'skia/src/core/SkFontMgr.cpp',
|
||||
'skia/src/core/SkFontStream.cpp',
|
||||
'skia/src/core/SkFontStyle.cpp',
|
||||
'skia/src/core/SkForceCPlusPlusLinking.cpp',
|
||||
'skia/src/core/SkGeometry.cpp',
|
||||
'skia/src/core/SkGlyphCache.cpp',
|
||||
'skia/src/core/SkGraphics.cpp',
|
||||
'skia/src/core/SkHalf.cpp',
|
||||
'skia/src/core/SkImageCacherator.cpp',
|
||||
'skia/src/core/SkImageFilter.cpp',
|
||||
'skia/src/core/SkImageGenerator.cpp',
|
||||
'skia/src/core/SkImageInfo.cpp',
|
||||
'skia/src/core/SkInstCnt.cpp',
|
||||
'skia/src/core/SkLightingShader.cpp',
|
||||
'skia/src/core/SkLineClipper.cpp',
|
||||
'skia/src/core/SkLocalMatrixImageFilter.cpp',
|
||||
'skia/src/core/SkLocalMatrixShader.cpp',
|
||||
'skia/src/core/SkMallocPixelRef.cpp',
|
||||
'skia/src/core/SkMask.cpp',
|
||||
'skia/src/core/SkMaskCache.cpp',
|
||||
'skia/src/core/SkMaskFilter.cpp',
|
||||
'skia/src/core/SkMaskGamma.cpp',
|
||||
'skia/src/core/SkMath.cpp',
|
||||
'skia/src/core/SkMatrix.cpp',
|
||||
'skia/src/core/SkMatrixClipStateMgr.cpp',
|
||||
'skia/src/core/SkMatrixImageFilter.cpp',
|
||||
'skia/src/core/SkMetaData.cpp',
|
||||
'skia/src/core/SkMiniRecorder.cpp',
|
||||
'skia/src/core/SkMipMap.cpp',
|
||||
'skia/src/core/SkMultiPictureDraw.cpp',
|
||||
'skia/src/core/SkNinePatchIter.cpp',
|
||||
'skia/src/core/SkPackBits.cpp',
|
||||
'skia/src/core/SkPaint.cpp',
|
||||
'skia/src/core/SkPaintOptionsAndroid.cpp',
|
||||
'skia/src/core/SkPaintPriv.cpp',
|
||||
'skia/src/core/SkPatch.cpp',
|
||||
'skia/src/core/SkPath.cpp',
|
||||
'skia/src/core/SkPathEffect.cpp',
|
||||
'skia/src/core/SkPathHeap.cpp',
|
||||
'skia/src/core/SkPathMeasure.cpp',
|
||||
'skia/src/core/SkPathRef.cpp',
|
||||
'skia/src/core/SkPicture.cpp',
|
||||
'skia/src/core/SkPictureContentInfo.cpp',
|
||||
'skia/src/core/SkPictureFlat.cpp',
|
||||
'skia/src/core/SkPictureImageGenerator.cpp',
|
||||
'skia/src/core/SkPicturePlayback.cpp',
|
||||
'skia/src/core/SkPictureRangePlayback.cpp',
|
||||
'skia/src/core/SkPictureRecord.cpp',
|
||||
'skia/src/core/SkPictureRecorder.cpp',
|
||||
'skia/src/core/SkPictureReplacementPlayback.cpp',
|
||||
'skia/src/core/SkPictureShader.cpp',
|
||||
'skia/src/core/SkPictureStateTree.cpp',
|
||||
'skia/src/core/SkPixelRef.cpp',
|
||||
'skia/src/core/SkPixmap.cpp',
|
||||
'skia/src/core/SkPoint.cpp',
|
||||
'skia/src/core/SkProcSpriteBlitter.cpp',
|
||||
'skia/src/core/SkPoint3.cpp',
|
||||
'skia/src/core/SkPtrRecorder.cpp',
|
||||
'skia/src/core/SkQuadClipper.cpp',
|
||||
'skia/src/core/SkQuadTree.cpp',
|
||||
'skia/src/core/SkRasterClip.cpp',
|
||||
'skia/src/core/SkRasterizer.cpp',
|
||||
'skia/src/core/SkReadBuffer.cpp',
|
||||
'skia/src/core/SkRecordAnalysis.cpp',
|
||||
'skia/src/core/SkRecord.cpp',
|
||||
'skia/src/core/SkRecordDraw.cpp',
|
||||
'skia/src/core/SkRecorder.cpp',
|
||||
'skia/src/core/SkRecording.cpp',
|
||||
'skia/src/core/SkRecordOpts.cpp',
|
||||
'skia/src/core/SkRecords.cpp',
|
||||
'skia/src/core/SkRect.cpp',
|
||||
'skia/src/core/SkRefDict.cpp',
|
||||
'skia/src/core/SkRegion.cpp',
|
||||
'skia/src/core/SkRegion_path.cpp',
|
||||
'skia/src/core/SkRemote.cpp',
|
||||
'skia/src/core/SkResourceCache.cpp',
|
||||
'skia/src/core/SkRRect.cpp',
|
||||
'skia/src/core/SkRTree.cpp',
|
||||
'skia/src/core/SkRWBuffer.cpp',
|
||||
'skia/src/core/SkScalar.cpp',
|
||||
'skia/src/core/SkScalerContext.cpp',
|
||||
'skia/src/core/SkScan.cpp',
|
||||
'skia/src/core/SkScan_AntiPath.cpp',
|
||||
'skia/src/core/SkScan_Hairline.cpp',
|
||||
'skia/src/core/SkScan_Path.cpp',
|
||||
'skia/src/core/SkSemaphore.cpp',
|
||||
'skia/src/core/SkShader.cpp',
|
||||
'skia/src/core/SkSharedMutex.cpp',
|
||||
'skia/src/core/SkSpinlock.cpp',
|
||||
'skia/src/core/SkSpriteBlitter_ARGB32.cpp',
|
||||
'skia/src/core/SkSpriteBlitter_RGB16.cpp',
|
||||
'skia/src/core/SkStream.cpp',
|
||||
@@ -139,7 +155,10 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/core/SkStroke.cpp',
|
||||
'skia/src/core/SkStrokeRec.cpp',
|
||||
'skia/src/core/SkStrokerPriv.cpp',
|
||||
'skia/src/core/SkTileGrid.cpp',
|
||||
'skia/src/core/SkTaskGroup.cpp',
|
||||
'skia/src/core/SkTextBlob.cpp',
|
||||
'skia/src/core/SkThreadID.cpp',
|
||||
'skia/src/core/SkTime.cpp',
|
||||
'skia/src/core/SkTLS.cpp',
|
||||
'skia/src/core/SkTSearch.cpp',
|
||||
'skia/src/core/SkTypeface.cpp',
|
||||
@@ -147,30 +166,33 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/core/SkUnPreMultiply.cpp',
|
||||
'skia/src/core/SkUtils.cpp',
|
||||
'skia/src/core/SkValidatingReadBuffer.cpp',
|
||||
'skia/src/core/SkVarAlloc.cpp',
|
||||
'skia/src/core/SkVertState.cpp',
|
||||
'skia/src/core/SkWriteBuffer.cpp',
|
||||
'skia/src/core/SkWriter32.cpp',
|
||||
'skia/src/core/SkXfermode.cpp',
|
||||
'skia/src/core/SkXfermodeInterpretation.cpp',
|
||||
'skia/src/core/SkYUVPlanesCache.cpp',
|
||||
'skia/src/doc/SkDocument.cpp',
|
||||
'skia/src/effects/gradients/SkBitmapCache.cpp',
|
||||
'skia/src/effects/gradients/SkClampRange.cpp',
|
||||
'skia/src/effects/gradients/SkGradientBitmapCache.cpp',
|
||||
'skia/src/effects/gradients/SkGradientShader.cpp',
|
||||
'skia/src/effects/gradients/SkLinearGradient.cpp',
|
||||
'skia/src/effects/gradients/SkRadialGradient.cpp',
|
||||
'skia/src/effects/gradients/SkSweepGradient.cpp',
|
||||
'skia/src/effects/gradients/SkTwoPointConicalGradient.cpp',
|
||||
'skia/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp',
|
||||
'skia/src/effects/gradients/SkTwoPointRadialGradient.cpp',
|
||||
'skia/src/effects/GrCircleBlurFragmentProcessor.cpp',
|
||||
'skia/src/effects/Sk1DPathEffect.cpp',
|
||||
'skia/src/effects/Sk2DPathEffect.cpp',
|
||||
'skia/src/effects/SkAlphaThresholdFilter.cpp',
|
||||
'skia/src/effects/SkArcToPathEffect.cpp',
|
||||
'skia/src/effects/SkArithmeticMode.cpp',
|
||||
'skia/src/effects/SkAvoidXfermode.cpp',
|
||||
'skia/src/effects/SkBitmapSource.cpp',
|
||||
'skia/src/effects/SkBlurDrawLooper.cpp',
|
||||
'skia/src/effects/SkBlurImageFilter.cpp',
|
||||
'skia/src/effects/SkBlurMask.cpp',
|
||||
'skia/src/effects/SkBlurMaskFilter.cpp',
|
||||
'skia/src/effects/SkColorCubeFilter.cpp',
|
||||
'skia/src/effects/SkColorFilterImageFilter.cpp',
|
||||
'skia/src/effects/SkColorFilters.cpp',
|
||||
'skia/src/effects/SkColorMatrix.cpp',
|
||||
@@ -184,6 +206,7 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/effects/SkEmbossMask.cpp',
|
||||
'skia/src/effects/SkEmbossMaskFilter.cpp',
|
||||
'skia/src/effects/SkGpuBlurUtils.cpp',
|
||||
'skia/src/effects/SkImageSource.cpp',
|
||||
'skia/src/effects/SkLayerDrawLooper.cpp',
|
||||
'skia/src/effects/SkLayerRasterizer.cpp',
|
||||
'skia/src/effects/SkLerpXfermode.cpp',
|
||||
@@ -191,7 +214,6 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/effects/SkLumaColorFilter.cpp',
|
||||
'skia/src/effects/SkMagnifierImageFilter.cpp',
|
||||
'skia/src/effects/SkMatrixConvolutionImageFilter.cpp',
|
||||
'skia/src/effects/SkMatrixImageFilter.cpp',
|
||||
'skia/src/effects/SkMergeImageFilter.cpp',
|
||||
'skia/src/effects/SkMorphologyImageFilter.cpp',
|
||||
'skia/src/effects/SkOffsetImageFilter.cpp',
|
||||
@@ -199,131 +221,142 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/effects/SkPerlinNoiseShader.cpp',
|
||||
'skia/src/effects/SkPictureImageFilter.cpp',
|
||||
'skia/src/effects/SkPixelXorXfermode.cpp',
|
||||
'skia/src/effects/SkPorterDuff.cpp',
|
||||
'skia/src/effects/SkRectShaderImageFilter.cpp',
|
||||
'skia/src/effects/SkStippleMaskFilter.cpp',
|
||||
'skia/src/effects/SkTableColorFilter.cpp',
|
||||
'skia/src/effects/SkTableMaskFilter.cpp',
|
||||
'skia/src/effects/SkTestImageFilters.cpp',
|
||||
'skia/src/effects/SkTileImageFilter.cpp',
|
||||
'skia/src/effects/SkTransparentShader.cpp',
|
||||
'skia/src/effects/SkXfermodeImageFilter.cpp',
|
||||
'skia/src/fonts/SkFontMgr_indirect.cpp',
|
||||
'skia/src/fonts/SkGScalerContext.cpp',
|
||||
'skia/src/fonts/SkRandomScalerContext.cpp',
|
||||
'skia/src/fonts/SkRemotableFontMgr.cpp',
|
||||
'skia/src/fonts/SkTestScalerContext.cpp',
|
||||
'skia/src/gpu/batches/GrAtlasTextBatch.cpp',
|
||||
'skia/src/gpu/batches/GrBatch.cpp',
|
||||
'skia/src/gpu/batches/GrCopySurfaceBatch.cpp',
|
||||
'skia/src/gpu/batches/GrDashLinePathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrDefaultPathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrDrawAtlasBatch.cpp',
|
||||
'skia/src/gpu/batches/GrDrawBatch.cpp',
|
||||
'skia/src/gpu/batches/GrDrawPathBatch.cpp',
|
||||
'skia/src/gpu/batches/GrDrawVerticesBatch.cpp',
|
||||
'skia/src/gpu/batches/GrNinePatch.cpp',
|
||||
'skia/src/gpu/batches/GrNonAAFillRectBatch.cpp',
|
||||
'skia/src/gpu/batches/GrNonAAStrokeRectBatch.cpp',
|
||||
'skia/src/gpu/batches/GrRectBatchFactory.cpp',
|
||||
'skia/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrTessellatingPathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrVertexBatch.cpp',
|
||||
'skia/src/gpu/effects/GrBezierEffect.cpp',
|
||||
'skia/src/gpu/effects/GrBicubicEffect.cpp',
|
||||
'skia/src/gpu/effects/GrBitmapTextGeoProc.cpp',
|
||||
'skia/src/gpu/effects/GrConfigConversionEffect.cpp',
|
||||
'skia/src/gpu/effects/GrConstColorProcessor.cpp',
|
||||
'skia/src/gpu/effects/GrConvexPolyEffect.cpp',
|
||||
'skia/src/gpu/effects/GrConvolutionEffect.cpp',
|
||||
'skia/src/gpu/effects/GrCustomCoordsTextureEffect.cpp',
|
||||
'skia/src/gpu/effects/GrCoverageSetOpXP.cpp',
|
||||
'skia/src/gpu/effects/GrCustomXfermode.cpp',
|
||||
'skia/src/gpu/effects/GrDashingEffect.cpp',
|
||||
'skia/src/gpu/effects/GrDistanceFieldTextureEffect.cpp',
|
||||
'skia/src/gpu/effects/GrDisableColorXP.cpp',
|
||||
'skia/src/gpu/effects/GrDistanceFieldGeoProc.cpp',
|
||||
'skia/src/gpu/effects/GrDitherEffect.cpp',
|
||||
'skia/src/gpu/effects/GrMatrixConvolutionEffect.cpp',
|
||||
'skia/src/gpu/effects/GrOvalEffect.cpp',
|
||||
'skia/src/gpu/effects/GrPorterDuffXferProcessor.cpp',
|
||||
'skia/src/gpu/effects/GrRRectEffect.cpp',
|
||||
'skia/src/gpu/effects/GrSimpleTextureEffect.cpp',
|
||||
'skia/src/gpu/effects/GrSingleTextureEffect.cpp',
|
||||
'skia/src/gpu/effects/GrTextureDomain.cpp',
|
||||
'skia/src/gpu/effects/GrTextureStripAtlas.cpp',
|
||||
'skia/src/gpu/effects/GrXfermodeFragmentProcessor.cpp',
|
||||
'skia/src/gpu/effects/GrYUVtoRGBEffect.cpp',
|
||||
'skia/src/gpu/gl/debug/GrBufferObj.cpp',
|
||||
'skia/src/gpu/gl/debug/GrDebugGL.cpp',
|
||||
'skia/src/gpu/gl/debug/GrFrameBufferObj.cpp',
|
||||
'skia/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp',
|
||||
'skia/src/gpu/gl/debug/GrProgramObj.cpp',
|
||||
'skia/src/gpu/gl/debug/GrShaderObj.cpp',
|
||||
'skia/src/gpu/gl/debug/GrTextureObj.cpp',
|
||||
'skia/src/gpu/gl/debug/GrTextureUnitObj.cpp',
|
||||
'skia/src/gpu/gl/debug/SkDebugGLContext.cpp',
|
||||
'skia/src/gpu/gl/GrGLAssembleInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLBufferImpl.cpp',
|
||||
'skia/src/gpu/gl/GrGLCaps.cpp',
|
||||
'skia/src/gpu/gl/GrGLContext.cpp',
|
||||
'skia/src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
|
||||
'skia/src/gpu/gl/GrGLCreateNullInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLDefaultInterface_native.cpp',
|
||||
'skia/src/gpu/gl/GrGLExtensions.cpp',
|
||||
'skia/src/gpu/gl/GrGLIndexBuffer.cpp',
|
||||
'skia/src/gpu/gl/GrGLInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLNameAllocator.cpp',
|
||||
'skia/src/gpu/gl/GrGLNoOpInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLPath.cpp',
|
||||
'skia/src/gpu/gl/GrGLPathRange.cpp',
|
||||
'skia/src/gpu/gl/GrGLProgram.cpp',
|
||||
'skia/src/gpu/gl/GrGLProgramDesc.cpp',
|
||||
'skia/src/gpu/gl/GrGLProgramEffects.cpp',
|
||||
'skia/src/gpu/gl/GrGLRenderTarget.cpp',
|
||||
'skia/src/gpu/gl/GrGLShaderBuilder.cpp',
|
||||
'skia/src/gpu/gl/GrGLSL.cpp',
|
||||
'skia/src/gpu/gl/GrGLStencilBuffer.cpp',
|
||||
'skia/src/gpu/gl/GrGLTexture.cpp',
|
||||
'skia/src/gpu/gl/GrGLUniformManager.cpp',
|
||||
'skia/src/gpu/gl/GrGLUtil.cpp',
|
||||
'skia/src/gpu/gl/GrGLVertexArray.cpp',
|
||||
'skia/src/gpu/gl/GrGLVertexBuffer.cpp',
|
||||
'skia/src/gpu/gl/GrGpuGL.cpp',
|
||||
'skia/src/gpu/gl/GrGpuGL_program.cpp',
|
||||
'skia/src/gpu/gl/SkGLContextHelper.cpp',
|
||||
'skia/src/gpu/gl/SkGLContext.cpp',
|
||||
'skia/src/gpu/gl/SkNullGLContext.cpp',
|
||||
'skia/src/gpu/GrAAConvexPathRenderer.cpp',
|
||||
'skia/src/gpu/GrAAHairLinePathRenderer.cpp',
|
||||
'skia/src/gpu/GrAARectRenderer.cpp',
|
||||
'skia/src/gpu/GrAllocPool.cpp',
|
||||
'skia/src/gpu/GrAtlas.cpp',
|
||||
'skia/src/gpu/GrBitmapTextContext.cpp',
|
||||
'skia/src/gpu/GrAtlasTextBlob.cpp',
|
||||
'skia/src/gpu/GrAtlasTextContext.cpp',
|
||||
'skia/src/gpu/GrBatchFlushState.cpp',
|
||||
'skia/src/gpu/GrBatchFontCache.cpp',
|
||||
'skia/src/gpu/GrBatchTest.cpp',
|
||||
'skia/src/gpu/GrBlend.cpp',
|
||||
'skia/src/gpu/GrBlurUtils.cpp',
|
||||
'skia/src/gpu/GrBufferAllocPool.cpp',
|
||||
'skia/src/gpu/GrCacheID.cpp',
|
||||
'skia/src/gpu/GrClipData.cpp',
|
||||
'skia/src/gpu/GrClipMaskCache.cpp',
|
||||
'skia/src/gpu/GrCaps.cpp',
|
||||
'skia/src/gpu/GrClip.cpp',
|
||||
'skia/src/gpu/GrClipMaskManager.cpp',
|
||||
'skia/src/gpu/GrContext.cpp',
|
||||
'skia/src/gpu/GrDefaultPathRenderer.cpp',
|
||||
'skia/src/gpu/GrDrawState.cpp',
|
||||
'skia/src/gpu/GrCoordTransform.cpp',
|
||||
'skia/src/gpu/GrDefaultGeoProcFactory.cpp',
|
||||
'skia/src/gpu/GrDrawingManager.cpp',
|
||||
'skia/src/gpu/GrDrawTarget.cpp',
|
||||
'skia/src/gpu/GrEffect.cpp',
|
||||
'skia/src/gpu/GrFontScaler.cpp',
|
||||
'skia/src/gpu/GrFragmentProcessor.cpp',
|
||||
'skia/src/gpu/GrGpu.cpp',
|
||||
'skia/src/gpu/GrGpuFactory.cpp',
|
||||
'skia/src/gpu/GrGpuResource.cpp',
|
||||
'skia/src/gpu/GrInOrderDrawBuffer.cpp',
|
||||
'skia/src/gpu/GrGpuResourceRef.cpp',
|
||||
'skia/src/gpu/GrImageIDTextureAdjuster.cpp',
|
||||
'skia/src/gpu/GrInvariantOutput.cpp',
|
||||
'skia/src/gpu/GrLayerAtlas.cpp',
|
||||
'skia/src/gpu/GrLayerCache.cpp',
|
||||
'skia/src/gpu/GrLayerHoister.cpp',
|
||||
'skia/src/gpu/GrMemoryPool.cpp',
|
||||
'skia/src/gpu/GrOvalRenderer.cpp',
|
||||
'skia/src/gpu/GrPaint.cpp',
|
||||
'skia/src/gpu/GrPath.cpp',
|
||||
'skia/src/gpu/GrPathProcessor.cpp',
|
||||
'skia/src/gpu/GrPathRange.cpp',
|
||||
'skia/src/gpu/GrPathRenderer.cpp',
|
||||
'skia/src/gpu/GrPathRendererChain.cpp',
|
||||
'skia/src/gpu/GrPathRendering.cpp',
|
||||
'skia/src/gpu/GrPathUtils.cpp',
|
||||
'skia/src/gpu/GrPictureUtils.cpp',
|
||||
'skia/src/gpu/GrPipeline.cpp',
|
||||
'skia/src/gpu/GrPipelineBuilder.cpp',
|
||||
'skia/src/gpu/GrPrimitiveProcessor.cpp',
|
||||
'skia/src/gpu/GrProcessor.cpp',
|
||||
'skia/src/gpu/GrProcessorUnitTest.cpp',
|
||||
'skia/src/gpu/GrProcOptInfo.cpp',
|
||||
'skia/src/gpu/GrProgramElement.cpp',
|
||||
'skia/src/gpu/GrRecordReplaceDraw.cpp',
|
||||
'skia/src/gpu/GrRectanizer_pow2.cpp',
|
||||
'skia/src/gpu/GrRectanizer_skyline.cpp',
|
||||
'skia/src/gpu/GrReducedClip.cpp',
|
||||
'skia/src/gpu/GrRenderTarget.cpp',
|
||||
'skia/src/gpu/GrResourceCache.cpp',
|
||||
'skia/src/gpu/GrResourceProvider.cpp',
|
||||
'skia/src/gpu/GrSoftwarePathRenderer.cpp',
|
||||
'skia/src/gpu/GrStencil.cpp',
|
||||
'skia/src/gpu/GrStencilAndCoverPathRenderer.cpp',
|
||||
'skia/src/gpu/GrStencilAndCoverTextContext.cpp',
|
||||
'skia/src/gpu/GrStencilBuffer.cpp',
|
||||
'skia/src/gpu/GrStencilAttachment.cpp',
|
||||
'skia/src/gpu/GrStrokeInfo.cpp',
|
||||
'skia/src/gpu/GrSurface.cpp',
|
||||
'skia/src/gpu/GrSWMaskHelper.cpp',
|
||||
'skia/src/gpu/GrTestUtils.cpp',
|
||||
'skia/src/gpu/GrTextBlobCache.cpp',
|
||||
'skia/src/gpu/GrTextContext.cpp',
|
||||
'skia/src/gpu/GrTextStrike.cpp',
|
||||
'skia/src/gpu/GrTexture.cpp',
|
||||
'skia/src/gpu/GrTextureAccess.cpp',
|
||||
'skia/src/gpu/GrTextureParamsAdjuster.cpp',
|
||||
'skia/src/gpu/GrTextureProvider.cpp',
|
||||
'skia/src/gpu/GrTraceMarker.cpp',
|
||||
'skia/src/gpu/GrXferProcessor.cpp',
|
||||
'skia/src/gpu/GrYUVProvider.cpp',
|
||||
'skia/src/gpu/SkGpuDevice.cpp',
|
||||
'skia/src/gpu/SkGpuDevice_drawTexture.cpp',
|
||||
'skia/src/gpu/SkGr.cpp',
|
||||
'skia/src/gpu/SkGrPixelRef.cpp',
|
||||
'skia/src/gpu/SkGrTexturePixelRef.cpp',
|
||||
'skia/src/image/SkImage.cpp',
|
||||
'skia/src/image/SkImage_Gpu.cpp',
|
||||
'skia/src/image/SkImage_Generator.cpp',
|
||||
'skia/src/image/SkImage_Raster.cpp',
|
||||
'skia/src/image/SkImagePriv.cpp',
|
||||
'skia/src/image/SkImageShader.cpp',
|
||||
'skia/src/image/SkSurface.cpp',
|
||||
'skia/src/image/SkSurface_Gpu.cpp',
|
||||
'skia/src/image/SkSurface_Raster.cpp',
|
||||
@@ -331,26 +364,27 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/images/SkDecodingImageGenerator.cpp',
|
||||
'skia/src/images/SkPageFlipper.cpp',
|
||||
'skia/src/images/SkScaledBitmapSampler.cpp',
|
||||
'skia/src/lazy/SkCachingPixelRef.cpp',
|
||||
'skia/src/lazy/SkDiscardableMemoryPool.cpp',
|
||||
'skia/src/lazy/SkDiscardablePixelRef.cpp',
|
||||
'skia/src/pathops/SkAddIntersections.cpp',
|
||||
'skia/src/pathops/SkDCubicIntersection.cpp',
|
||||
'skia/src/pathops/SkDConicLineIntersection.cpp',
|
||||
'skia/src/pathops/SkDCubicLineIntersection.cpp',
|
||||
'skia/src/pathops/SkDCubicToQuads.cpp',
|
||||
'skia/src/pathops/SkDLineIntersection.cpp',
|
||||
'skia/src/pathops/SkDQuadImplicit.cpp',
|
||||
'skia/src/pathops/SkDQuadIntersection.cpp',
|
||||
'skia/src/pathops/SkDQuadLineIntersection.cpp',
|
||||
'skia/src/pathops/SkIntersections.cpp',
|
||||
'skia/src/pathops/SkOpAngle.cpp',
|
||||
'skia/src/pathops/SkOpBuilder.cpp',
|
||||
'skia/src/pathops/SkOpCoincidence.cpp',
|
||||
'skia/src/pathops/SkOpContour.cpp',
|
||||
'skia/src/pathops/SkOpCubicHull.cpp',
|
||||
'skia/src/pathops/SkOpEdgeBuilder.cpp',
|
||||
'skia/src/pathops/SkOpSegment.cpp',
|
||||
'skia/src/pathops/SkPathOpsBounds.cpp',
|
||||
'skia/src/pathops/SkOpSpan.cpp',
|
||||
'skia/src/pathops/SkPathOpsCommon.cpp',
|
||||
'skia/src/pathops/SkPathOpsConic.cpp',
|
||||
'skia/src/pathops/SkPathOpsCubic.cpp',
|
||||
'skia/src/pathops/SkPathOpsDebug.cpp',
|
||||
'skia/src/pathops/SkPathOpsCurve.cpp',
|
||||
'skia/src/pathops/SkPathOpsLine.cpp',
|
||||
'skia/src/pathops/SkPathOpsOp.cpp',
|
||||
'skia/src/pathops/SkPathOpsPoint.cpp',
|
||||
@@ -358,21 +392,24 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/pathops/SkPathOpsRect.cpp',
|
||||
'skia/src/pathops/SkPathOpsSimplify.cpp',
|
||||
'skia/src/pathops/SkPathOpsTightBounds.cpp',
|
||||
'skia/src/pathops/SkPathOpsTriangle.cpp',
|
||||
'skia/src/pathops/SkPathOpsTSect.cpp',
|
||||
'skia/src/pathops/SkPathOpsTypes.cpp',
|
||||
'skia/src/pathops/SkPathOpsWinding.cpp',
|
||||
'skia/src/pathops/SkPathWriter.cpp',
|
||||
'skia/src/pathops/SkQuarticRoot.cpp',
|
||||
'skia/src/pathops/SkReduceOrder.cpp',
|
||||
'skia/src/pipe/SkGPipeRead.cpp',
|
||||
'skia/src/pipe/SkGPipeWrite.cpp',
|
||||
'skia/src/ports/SkDiscardableMemory_none.cpp',
|
||||
'skia/src/ports/SkGlobalInitialization_default.cpp',
|
||||
'skia/src/ports/SkImageDecoder_empty.cpp',
|
||||
'skia/src/ports/SkImageGenerator_skia.cpp',
|
||||
'skia/src/ports/SkMemory_mozalloc.cpp',
|
||||
'skia/src/ports/SkOSFile_stdio.cpp',
|
||||
'skia/src/sfnt/SkOTTable_name.cpp',
|
||||
'skia/src/sfnt/SkOTUtils.cpp',
|
||||
'skia/src/utils/android/SkAndroidSDKCanvas.cpp',
|
||||
'skia/src/utils/SkBase64.cpp',
|
||||
'skia/src/utils/SkBitmapSourceDeserializer.cpp',
|
||||
'skia/src/utils/SkBitSet.cpp',
|
||||
'skia/src/utils/SkBoundaryPatch.cpp',
|
||||
'skia/src/utils/SkCamera.cpp',
|
||||
@@ -381,11 +418,10 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/utils/SkCubicInterval.cpp',
|
||||
'skia/src/utils/SkCullPoints.cpp',
|
||||
'skia/src/utils/SkDashPath.cpp',
|
||||
'skia/src/utils/SkDeferredCanvas.cpp',
|
||||
'skia/src/utils/SkDumpCanvas.cpp',
|
||||
'skia/src/utils/SkEventTracer.cpp',
|
||||
'skia/src/utils/SkFrontBufferedStream.cpp',
|
||||
'skia/src/utils/SkGatherPixelRefsAndRects.cpp',
|
||||
'skia/src/utils/SkImageGeneratorUtils.cpp',
|
||||
'skia/src/utils/SkInterpolator.cpp',
|
||||
'skia/src/utils/SkLayer.cpp',
|
||||
'skia/src/utils/SkMatrix22.cpp',
|
||||
@@ -395,16 +431,17 @@ UNIFIED_SOURCES += [
|
||||
'skia/src/utils/SkNullCanvas.cpp',
|
||||
'skia/src/utils/SkNWayCanvas.cpp',
|
||||
'skia/src/utils/SkOSFile.cpp',
|
||||
'skia/src/utils/SkPaintFilterCanvas.cpp',
|
||||
'skia/src/utils/SkParseColor.cpp',
|
||||
'skia/src/utils/SkParsePath.cpp',
|
||||
'skia/src/utils/SkPathUtils.cpp',
|
||||
'skia/src/utils/SkPictureUtils.cpp',
|
||||
'skia/src/utils/SkProxyCanvas.cpp',
|
||||
'skia/src/utils/SkPatchGrid.cpp',
|
||||
'skia/src/utils/SkPatchUtils.cpp',
|
||||
'skia/src/utils/SkRTConf.cpp',
|
||||
'skia/src/utils/SkTextBox.cpp',
|
||||
'skia/src/utils/SkTextureCompressor.cpp',
|
||||
'skia/src/utils/SkTextureCompressor_ASTC.cpp',
|
||||
'skia/src/utils/SkTextureCompressor_LATC.cpp',
|
||||
'skia/src/utils/SkTextureCompressor_R11EAC.cpp',
|
||||
'skia/src/utils/SkWhitelistTypefaces.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/core/SkAdvancedTypefaceMetrics.cpp',
|
||||
@@ -414,33 +451,93 @@ SOURCES += [
|
||||
'skia/src/core/SkBlitter_RGB16.cpp',
|
||||
'skia/src/core/SkBlitter_Sprite.cpp',
|
||||
'skia/src/core/SkFontHost.cpp',
|
||||
'skia/src/core/SkOpts.cpp',
|
||||
'skia/src/core/SkPictureData.cpp',
|
||||
'skia/src/core/SkScaledImageCache.cpp',
|
||||
'skia/src/core/SkRecorder.cpp',
|
||||
'skia/src/core/SkScan_Antihair.cpp',
|
||||
'skia/src/gpu/GrAddPathRenderers_default.cpp',
|
||||
'skia/src/gpu/GrDistanceFieldTextContext.cpp',
|
||||
'skia/src/effects/SkArithmeticMode_gpu.cpp',
|
||||
'skia/src/gpu/batches/GrAAConvexPathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrAAConvexTessellator.cpp',
|
||||
'skia/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrAAFillRectBatch.cpp',
|
||||
'skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp',
|
||||
'skia/src/gpu/batches/GrAAStrokeRectBatch.cpp',
|
||||
'skia/src/gpu/gl/builders/GrGLProgramBuilder.cpp',
|
||||
'skia/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp',
|
||||
'skia/src/gpu/gl/builders/GrGLSLPrettyPrint.cpp',
|
||||
'skia/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLAssembleInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLBufferImpl.cpp',
|
||||
'skia/src/gpu/gl/GrGLCaps.cpp',
|
||||
'skia/src/gpu/gl/GrGLContext.cpp',
|
||||
'skia/src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
|
||||
'skia/src/gpu/gl/GrGLCreateNullInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLDefaultInterface_native.cpp',
|
||||
'skia/src/gpu/gl/GrGLExtensions.cpp',
|
||||
'skia/src/gpu/gl/GrGLGLSL.cpp',
|
||||
'skia/src/gpu/gl/GrGLGpu.cpp',
|
||||
'skia/src/gpu/gl/GrGLGpuProgramCache.cpp',
|
||||
'skia/src/gpu/gl/GrGLIndexBuffer.cpp',
|
||||
'skia/src/gpu/gl/GrGLInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLNameAllocator.cpp',
|
||||
'skia/src/gpu/gl/GrGLNoOpInterface.cpp',
|
||||
'skia/src/gpu/gl/GrGLPath.cpp',
|
||||
'skia/src/gpu/gl/GrGLPathRange.cpp',
|
||||
'skia/src/gpu/gl/GrGLPathRendering.cpp',
|
||||
'skia/src/gpu/gl/GrGLProgram.cpp',
|
||||
'skia/src/gpu/gl/GrGLProgramDataManager.cpp',
|
||||
'skia/src/gpu/gl/GrGLProgramDesc.cpp',
|
||||
'skia/src/gpu/gl/GrGLRenderTarget.cpp',
|
||||
'skia/src/gpu/gl/GrGLStencilAttachment.cpp',
|
||||
'skia/src/gpu/gl/GrGLTexture.cpp',
|
||||
'skia/src/gpu/gl/GrGLTextureRenderTarget.cpp',
|
||||
'skia/src/gpu/gl/GrGLUtil.cpp',
|
||||
'skia/src/gpu/gl/GrGLVaryingHandler.cpp',
|
||||
'skia/src/gpu/gl/GrGLVertexArray.cpp',
|
||||
'skia/src/gpu/gl/GrGLVertexBuffer.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSL.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLBlend.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLCaps.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLFragmentProcessor.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLGeometryProcessor.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLGeometryShaderBuilder.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLProgramBuilder.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLShaderBuilder.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLUtil.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLVarying.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp',
|
||||
'skia/src/gpu/glsl/GrGLSLXferProcessor.cpp',
|
||||
'skia/src/gpu/GrBatchAtlas.cpp',
|
||||
'skia/src/gpu/GrDrawContext.cpp',
|
||||
'skia/src/gpu/GrResourceCache.cpp',
|
||||
'skia/src/image/SkImage_Gpu.cpp',
|
||||
'skia/src/pathops/SkPathOpsDebug.cpp',
|
||||
'skia/src/utils/SkMD5.cpp',
|
||||
'skia/src/utils/SkParse.cpp',
|
||||
'skia/src/utils/SkParsePath.cpp',
|
||||
'skia/src/utils/SkSHA1.cpp',
|
||||
]
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/ports/SkDebug_android.cpp',
|
||||
'skia/src/ports/SkOSFile_posix.cpp',
|
||||
'skia/src/ports/SkOSLibrary_posix.cpp',
|
||||
'skia/src/ports/SkTime_Unix.cpp',
|
||||
'skia/src/ports/SkTLS_pthread.cpp',
|
||||
'skia/src/utils/SkThreadUtils_pthread.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/ports/SkFontHost_android_old.cpp',
|
||||
'skia/src/ports/SkFontHost_cairo.cpp',
|
||||
'skia/src/ports/SkFontHost_FreeType.cpp',
|
||||
'skia/src/ports/SkFontHost_FreeType_common.cpp',
|
||||
]
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in {'cocoa', 'uikit'}:
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/ports/SkDebug_stdio.cpp',
|
||||
'skia/src/ports/SkOSFile_posix.cpp',
|
||||
'skia/src/ports/SkOSLibrary_posix.cpp',
|
||||
'skia/src/ports/SkTime_Unix.cpp',
|
||||
'skia/src/ports/SkTLS_pthread.cpp',
|
||||
'skia/src/utils/mac/SkCreateCGImageRef.cpp',
|
||||
@@ -454,35 +551,36 @@ if CONFIG['MOZ_WIDGET_GTK']:
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/ports/SkDebug_stdio.cpp',
|
||||
'skia/src/ports/SkOSFile_posix.cpp',
|
||||
'skia/src/ports/SkOSLibrary_posix.cpp',
|
||||
'skia/src/ports/SkTime_Unix.cpp',
|
||||
'skia/src/ports/SkTLS_pthread.cpp',
|
||||
'skia/src/utils/SkThreadUtils_pthread.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/ports/SkFontHost_cairo.cpp',
|
||||
'skia/src/ports/SkFontHost_FreeType.cpp',
|
||||
'skia/src/ports/SkFontHost_FreeType_common.cpp',
|
||||
]
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/ports/SkDebug_stdio.cpp',
|
||||
'skia/src/ports/SkOSFile_posix.cpp',
|
||||
'skia/src/ports/SkOSLibrary_posix.cpp',
|
||||
'skia/src/ports/SkTime_Unix.cpp',
|
||||
'skia/src/ports/SkTLS_pthread.cpp',
|
||||
'skia/src/utils/SkThreadUtils_pthread.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/ports/SkFontHost_cairo.cpp',
|
||||
'skia/src/ports/SkFontHost_FreeType.cpp',
|
||||
'skia/src/ports/SkFontHost_FreeType_common.cpp',
|
||||
]
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
SOURCES += [
|
||||
'skia/src/ports/SkDebug_win.cpp',
|
||||
'skia/src/ports/SkFontHost_win.cpp',
|
||||
'skia/src/ports/SkFontMgr_default_dw.cpp',
|
||||
'skia/src/ports/SkFontMgr_win_dw.cpp',
|
||||
'skia/src/ports/SkFontMgr_win_dw_factory.cpp',
|
||||
'skia/src/ports/SkOSFile_win.cpp',
|
||||
'skia/src/ports/SkOSLibrary_win.cpp',
|
||||
'skia/src/ports/SkRemotableFontMgr_win_dw.cpp',
|
||||
'skia/src/ports/SkScalerContext_win_dw.cpp',
|
||||
'skia/src/ports/SkTime_win.cpp',
|
||||
@@ -497,32 +595,22 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
'skia/src/utils/win/SkIStream.cpp',
|
||||
]
|
||||
if CONFIG['INTEL_ARCHITECTURE']:
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/opts/SkTextureCompression_opts_none.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/opts/opts_check_x86.cpp',
|
||||
'skia/src/opts/SkBitmapFilter_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkBitmapProcState_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp',
|
||||
'skia/src/opts/SkBlitRect_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkBlitRow_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkBlurImage_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkBlurImage_opts_SSE4.cpp',
|
||||
'skia/src/opts/SkMorphology_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkUtils_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkXfermode_opts_SSE2.cpp',
|
||||
'skia/src/opts/SkBlitRow_opts_SSE4.cpp',
|
||||
'skia/src/opts/SkOpts_avx.cpp',
|
||||
'skia/src/opts/SkOpts_sse41.cpp',
|
||||
'skia/src/opts/SkOpts_ssse3.cpp',
|
||||
]
|
||||
elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/core/SkUtilsArm.cpp',
|
||||
'skia/src/opts/SkBitmapProcState_opts_arm.cpp',
|
||||
'skia/src/opts/SkBlitMask_opts_arm.cpp',
|
||||
'skia/src/opts/SkBlurImage_opts_arm.cpp',
|
||||
'skia/src/opts/SkMorphology_opts_arm.cpp',
|
||||
'skia/src/opts/SkTextureCompression_opts_arm.cpp',
|
||||
'skia/src/opts/SkUtils_opts_arm.cpp',
|
||||
'skia/src/opts/SkXfermode_opts_arm.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/opts/SkBlitRow_opts_arm.cpp',
|
||||
@@ -533,61 +621,27 @@ elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:
|
||||
'skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
|
||||
'skia/src/opts/SkBlitMask_opts_arm_neon.cpp',
|
||||
'skia/src/opts/SkBlitRow_opts_arm_neon.cpp',
|
||||
'skia/src/opts/SkBlurImage_opts_neon.cpp',
|
||||
'skia/src/opts/SkMorphology_opts_neon.cpp',
|
||||
'skia/src/opts/SkTextureCompression_opts_neon.cpp',
|
||||
'skia/src/opts/SkXfermode_opts_arm_neon.cpp',
|
||||
'skia/src/opts/SkOpts_neon.cpp',
|
||||
]
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_arm_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkBlitMask_opts_arm_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_arm_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkMorphology_opts_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkTextureCompression_opts_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkXfermode_opts_arm_neon.cpp'].flags += ['-mfpu=neon']
|
||||
SOURCES['skia/src/opts/SkOpts_neon.cpp'].flags += ['-mfpu=neon']
|
||||
else:
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/opts/SkBitmapProcState_opts_none.cpp',
|
||||
'skia/src/opts/SkBlitMask_opts_none.cpp',
|
||||
'skia/src/opts/SkBlitRow_opts_none.cpp',
|
||||
'skia/src/opts/SkBlurImage_opts_none.cpp',
|
||||
'skia/src/opts/SkMorphology_opts_none.cpp',
|
||||
'skia/src/opts/SkTextureCompression_opts_none.cpp',
|
||||
'skia/src/opts/SkUtils_opts_none.cpp',
|
||||
'skia/src/opts/SkXfermode_opts_none.cpp',
|
||||
'skia/src/ports/SkDiscardableMemory_none.cpp',
|
||||
]
|
||||
|
||||
|
||||
# can we find a better way of dealing with asm sources?
|
||||
|
||||
# left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with
|
||||
#XXX: doesn't build with Apple's assembler
|
||||
if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['OS_TARGET'] != 'Darwin':
|
||||
SOURCES += [
|
||||
'skia/src/opts/memset.arm.S',
|
||||
]
|
||||
if CONFIG['BUILD_ARM_NEON']:
|
||||
SOURCES += [
|
||||
'skia/src/opts/memset16_neon.S',
|
||||
'skia/src/opts/memset32_neon.S',
|
||||
]
|
||||
|
||||
if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC'] and CONFIG['OS_ARCH'] != 'WINNT':
|
||||
if CONFIG['CPU_ARCH'] == 'x86_64':
|
||||
SOURCES += [
|
||||
'skia/src/opts/SkBlitRow_opts_SSE4_x64_asm.S',
|
||||
]
|
||||
else:
|
||||
SOURCES += [
|
||||
'skia/src/opts/SkBlitRow_opts_SSE4_asm.S',
|
||||
]
|
||||
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
FINAL_LIBRARY = 'gkmedias'
|
||||
LOCAL_INCLUDES += [
|
||||
'skia/include/c',
|
||||
'skia/include/config',
|
||||
'skia/include/core',
|
||||
'skia/include/effects',
|
||||
@@ -596,6 +650,7 @@ LOCAL_INCLUDES += [
|
||||
'skia/include/pathops',
|
||||
'skia/include/pipe',
|
||||
'skia/include/ports',
|
||||
'skia/include/private',
|
||||
'skia/include/utils',
|
||||
'skia/include/utils/mac',
|
||||
'skia/include/utils/win',
|
||||
@@ -622,7 +677,13 @@ if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['HAVE_TOOLCHAIN_SUPPORT_MSSSE3']:
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
|
||||
DEFINES['SK_FONTHOST_CAIRO_STANDALONE'] = 0
|
||||
|
||||
if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android') or (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa') or (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit') or (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk') or (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt') or CONFIG['MOZ_WIDGET_GTK']:
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in {
|
||||
'android',
|
||||
'cocoa',
|
||||
'uikit',
|
||||
'gonk',
|
||||
'qt',
|
||||
} or CONFIG['MOZ_WIDGET_GTK']:
|
||||
DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
|
||||
|
||||
if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
|
||||
@@ -634,42 +695,34 @@ if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
|
||||
if CONFIG['_MSC_VER']:
|
||||
# MSVC doesn't need special compiler flags, but Skia needs to be told that these files should
|
||||
# be built with the required SSE level or it will simply compile in stubs and cause runtime crashes
|
||||
SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=31']
|
||||
SOURCES['skia/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=41']
|
||||
SOURCES['skia/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkXfermode_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
|
||||
|
||||
SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=31']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE4.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=41']
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=31']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=41']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['/arch:AVX -DSK_CPU_SSE_LEVEL=51']
|
||||
if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
|
||||
SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkMorphology_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkUtils_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkXfermode_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
|
||||
elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']:
|
||||
DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1
|
||||
DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0
|
||||
DEFINES['SK_ARM_HAS_OPTIONAL_NEON'] = 1
|
||||
elif CONFIG['CLANG_CL']:
|
||||
SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
|
||||
if CONFIG['GNU_CXX'] and CONFIG['CPU_ARCH'] == 'arm':
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_SSE4.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
|
||||
|
||||
DEFINES['SKIA_IMPLEMENTATION'] = 1
|
||||
DEFINES['GR_IMPLEMENTATION'] = 1
|
||||
|
||||
# Suppress warnings in third-party code.
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-deprecated-declarations',
|
||||
@@ -677,18 +730,22 @@ if CONFIG['GNU_CXX']:
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-unused-function',
|
||||
]
|
||||
if CONFIG['GNU_CXX'] and not CONFIG['CLANG_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-logical-op',
|
||||
'-Wno-maybe-uninitialized',
|
||||
]
|
||||
if CONFIG['CLANG_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-implicit-fallthrough',
|
||||
'-Wno-inconsistent-missing-override',
|
||||
'-Wno-macro-redefined',
|
||||
'-Wno-unused-private-field',
|
||||
]
|
||||
if CONFIG['CLANG_CXX']:
|
||||
CXXFLAGS += [
|
||||
'-Wno-implicit-fallthrough',
|
||||
'-Wno-inconsistent-missing-override',
|
||||
'-Wno-macro-redefined',
|
||||
'-Wno-unused-private-field',
|
||||
]
|
||||
# work around inline function linking bug with template arguments
|
||||
SOURCES['skia/src/gpu/GrResourceCache.cpp'].flags += ['-fkeep-inline-functions']
|
||||
else:
|
||||
CXXFLAGS += [
|
||||
'-Wno-logical-op',
|
||||
'-Wno-maybe-uninitialized',
|
||||
]
|
||||
if CONFIG['CPU_ARCH'] == 'arm':
|
||||
SOURCES['skia/src/opts/SkBlitRow_opts_arm.cpp'].flags += ['-fomit-frame-pointer']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
|
||||
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBRDAllocator_DEFINED
|
||||
#define SkBRDAllocator_DEFINED
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCodec.h"
|
||||
|
||||
/**
|
||||
* Abstract subclass of SkBitmap's allocator.
|
||||
* Allows the allocator to indicate if the memory it allocates
|
||||
* is zero initialized.
|
||||
*/
|
||||
class SkBRDAllocator : public SkBitmap::Allocator {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Indicates if the memory allocated by this allocator is
|
||||
* zero initialized.
|
||||
*/
|
||||
virtual SkCodec::ZeroInitialized zeroInit() const = 0;
|
||||
};
|
||||
|
||||
#endif // SkBRDAllocator_DEFINED
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBitmapRegionDecoder_DEFINED
|
||||
#define SkBitmapRegionDecoder_DEFINED
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBRDAllocator.h"
|
||||
#include "SkEncodedFormat.h"
|
||||
#include "SkStream.h"
|
||||
|
||||
/*
|
||||
* This class aims to provide an interface to test multiple implementations of
|
||||
* SkBitmapRegionDecoder.
|
||||
*/
|
||||
class SkBitmapRegionDecoder {
|
||||
public:
|
||||
|
||||
enum Strategy {
|
||||
kCanvas_Strategy, // Draw to the canvas, uses SkCodec
|
||||
kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsetting
|
||||
};
|
||||
|
||||
/*
|
||||
* @param data Refs the data while this object exists, unrefs on destruction
|
||||
* @param strategy Strategy used for scaling and subsetting
|
||||
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
|
||||
*/
|
||||
static SkBitmapRegionDecoder* Create(
|
||||
SkData* data, Strategy strategy);
|
||||
|
||||
/*
|
||||
* @param stream Takes ownership of the stream
|
||||
* @param strategy Strategy used for scaling and subsetting
|
||||
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
|
||||
*/
|
||||
static SkBitmapRegionDecoder* Create(
|
||||
SkStreamRewindable* stream, Strategy strategy);
|
||||
|
||||
/*
|
||||
* Decode a scaled region of the encoded image stream
|
||||
*
|
||||
* @param bitmap Container for decoded pixels. It is assumed that the pixels
|
||||
* are initially unallocated and will be allocated by this function.
|
||||
* @param allocator Allocator for the pixels. If this is NULL, the default
|
||||
* allocator (HeapAllocator) will be used.
|
||||
* @param desiredSubset Subset of the original image to decode.
|
||||
* @param sampleSize An integer downscaling factor for the decode.
|
||||
* @param colorType Preferred output colorType.
|
||||
* New implementations should return NULL if they do not support
|
||||
* decoding to this color type.
|
||||
* The old kOriginal_Strategy will decode to a default color type
|
||||
* if this color type is unsupported.
|
||||
* @param requireUnpremul If the image is not opaque, we will use this to determine the
|
||||
* alpha type to use.
|
||||
*
|
||||
*/
|
||||
virtual bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
|
||||
const SkIRect& desiredSubset, int sampleSize,
|
||||
SkColorType colorType, bool requireUnpremul) = 0;
|
||||
/*
|
||||
* @param Requested destination color type
|
||||
* @return true if we support the requested color type and false otherwise
|
||||
*/
|
||||
virtual bool conversionSupported(SkColorType colorType) = 0;
|
||||
|
||||
virtual SkEncodedFormat getEncodedFormat() = 0;
|
||||
|
||||
int width() const { return fWidth; }
|
||||
int height() const { return fHeight; }
|
||||
|
||||
virtual ~SkBitmapRegionDecoder() {}
|
||||
|
||||
protected:
|
||||
|
||||
SkBitmapRegionDecoder(int width, int height)
|
||||
: fWidth(width)
|
||||
, fHeight(height)
|
||||
{}
|
||||
|
||||
private:
|
||||
const int fWidth;
|
||||
const int fHeight;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_canvas_DEFINED
|
||||
#define sk_canvas_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Save the current matrix and clip on the canvas. When the
|
||||
balancing call to sk_canvas_restore() is made, the previous matrix
|
||||
and clip are restored.
|
||||
*/
|
||||
SK_API void sk_canvas_save(sk_canvas_t*);
|
||||
/**
|
||||
This behaves the same as sk_canvas_save(), but in addition it
|
||||
allocates an offscreen surface. All drawing calls are directed
|
||||
there, and only when the balancing call to sk_canvas_restore() is
|
||||
made is that offscreen transfered to the canvas (or the previous
|
||||
layer).
|
||||
|
||||
@param sk_rect_t* (may be null) This rect, if non-null, is used as
|
||||
a hint to limit the size of the offscreen, and
|
||||
thus drawing may be clipped to it, though that
|
||||
clipping is not guaranteed to happen. If exact
|
||||
clipping is desired, use sk_canvas_clip_rect().
|
||||
@param sk_paint_t* (may be null) The paint is copied, and is applied
|
||||
to the offscreen when sk_canvas_restore() is
|
||||
called.
|
||||
*/
|
||||
SK_API void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
This call balances a previous call to sk_canvas_save() or
|
||||
sk_canvas_save_layer(), and is used to remove all modifications to
|
||||
the matrix and clip state since the last save call. It is an
|
||||
error to call sk_canvas_restore() more times than save and
|
||||
save_layer were called.
|
||||
*/
|
||||
SK_API void sk_canvas_restore(sk_canvas_t*);
|
||||
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified translation.
|
||||
*/
|
||||
SK_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified scale.
|
||||
*/
|
||||
SK_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified rotation in degrees.
|
||||
*/
|
||||
SK_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified rotation in radians.
|
||||
*/
|
||||
SK_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified skew.
|
||||
*/
|
||||
SK_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified matrix.
|
||||
*/
|
||||
SK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*);
|
||||
|
||||
/**
|
||||
Modify the current clip with the specified rectangle. The new
|
||||
current clip will be the intersection of the old clip and the
|
||||
rectange.
|
||||
*/
|
||||
SK_API void sk_canvas_clip_rect(sk_canvas_t*, const sk_rect_t*);
|
||||
/**
|
||||
Modify the current clip with the specified path. The new
|
||||
current clip will be the intersection of the old clip and the
|
||||
path.
|
||||
*/
|
||||
SK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*);
|
||||
|
||||
/**
|
||||
Fill the entire canvas (restricted to the current clip) with the
|
||||
specified paint.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified rectangle using the specified paint. The
|
||||
rectangle will be filled or stroked based on the style in the
|
||||
paint.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified oval using the specified paint. The oval will be
|
||||
filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified path using the specified paint. The path will be
|
||||
filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified image, with its top/left corner at (x,y), using
|
||||
the specified paint, transformed by the current matrix.
|
||||
|
||||
@param sk_paint_t* (may be NULL) the paint used to draw the image.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*,
|
||||
float x, float y, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified image, scaling and translating so that it fills
|
||||
the specified dst rect. If the src rect is non-null, only that
|
||||
subset of the image is transformed and drawn.
|
||||
|
||||
@param sk_paint_t* (may be NULL) The paint used to draw the image.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*,
|
||||
const sk_rect_t* src,
|
||||
const sk_rect_t* dst, const sk_paint_t*);
|
||||
|
||||
/**
|
||||
Draw the picture into this canvas (replay the pciture's drawing commands).
|
||||
|
||||
@param sk_matrix_t* If non-null, apply that matrix to the CTM when
|
||||
drawing this picture. This is logically
|
||||
equivalent to: save, concat, draw_picture,
|
||||
restore.
|
||||
|
||||
@param sk_paint_t* If non-null, draw the picture into a temporary
|
||||
buffer, and then apply the paint's alpha,
|
||||
colorfilter, imagefilter, and xfermode to that
|
||||
buffer as it is drawn to the canvas. This is
|
||||
logically equivalent to save_layer(paint),
|
||||
draw_picture, restore.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*,
|
||||
const sk_matrix_t*, const sk_paint_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_data_DEFINED
|
||||
#define sk_data_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Returns a new empty sk_data_t. This call must be balanced with a call to
|
||||
sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_empty();
|
||||
/**
|
||||
Returns a new sk_data_t by copying the specified source data.
|
||||
This call must be balanced with a call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_with_copy(const void* src, size_t length);
|
||||
/**
|
||||
Pass ownership of the given memory to a new sk_data_t, which will
|
||||
call free() when the refernce count of the data goes to zero. For
|
||||
example:
|
||||
size_t length = 1024;
|
||||
void* buffer = malloc(length);
|
||||
memset(buffer, 'X', length);
|
||||
sk_data_t* data = sk_data_new_from_malloc(buffer, length);
|
||||
This call must be balanced with a call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_from_malloc(const void* memory, size_t length);
|
||||
/**
|
||||
Returns a new sk_data_t using a subset of the data in the
|
||||
specified source sk_data_t. This call must be balanced with a
|
||||
call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_subset(const sk_data_t* src, size_t offset, size_t length);
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_data_t. Must be
|
||||
balanced by a call to sk_data_unref().
|
||||
*/
|
||||
SK_API void sk_data_ref(const sk_data_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the sk_data_t
|
||||
and the memory it is managing. New sk_data_t are created with a
|
||||
reference count of 1.
|
||||
*/
|
||||
SK_API void sk_data_unref(const sk_data_t*);
|
||||
|
||||
/**
|
||||
Returns the number of bytes stored.
|
||||
*/
|
||||
SK_API size_t sk_data_get_size(const sk_data_t*);
|
||||
/**
|
||||
Returns the pointer to the data.
|
||||
*/
|
||||
SK_API const void* sk_data_get_data(const sk_data_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_image_DEFINED
|
||||
#define sk_image_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
* Return a new image that has made a copy of the provided pixels, or NULL on failure.
|
||||
* Balance with a call to sk_image_unref().
|
||||
*/
|
||||
SK_API sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* If the specified data can be interpreted as a compressed image (e.g. PNG or JPEG) then this
|
||||
* returns an image. If the encoded data is not supported, returns NULL.
|
||||
*
|
||||
* On success, the encoded data may be processed immediately, or it may be ref()'d for later
|
||||
* use.
|
||||
*/
|
||||
SK_API sk_image_t* sk_image_new_from_encoded(const sk_data_t* encoded, const sk_irect_t* subset);
|
||||
|
||||
/**
|
||||
* Encode the image's pixels and return the result as a new PNG in a
|
||||
* sk_data_t, which the caller must manage: call sk_data_unref() when
|
||||
* they are done.
|
||||
*
|
||||
* If the image type cannot be encoded, this will return NULL.
|
||||
*/
|
||||
SK_API sk_data_t* sk_image_encode(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Increment the reference count on the given sk_image_t. Must be
|
||||
* balanced by a call to sk_image_unref().
|
||||
*/
|
||||
SK_API void sk_image_ref(const sk_image_t*);
|
||||
/**
|
||||
* Decrement the reference count. If the reference count is 1 before
|
||||
* the decrement, then release both the memory holding the sk_image_t
|
||||
* and the memory it is managing. New sk_image_t are created with a
|
||||
reference count of 1.
|
||||
*/
|
||||
SK_API void sk_image_unref(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Return the width of the sk_image_t/
|
||||
*/
|
||||
SK_API int sk_image_get_width(const sk_image_t*);
|
||||
/**
|
||||
* Return the height of the sk_image_t/
|
||||
*/
|
||||
SK_API int sk_image_get_height(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Returns a non-zero value unique among all images.
|
||||
*/
|
||||
SK_API uint32_t sk_image_get_unique_id(const sk_image_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_maskfilter_DEFINED
|
||||
#define sk_maskfilter_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
typedef enum {
|
||||
NORMAL_SK_BLUR_STYLE, //!< fuzzy inside and outside
|
||||
SOLID_SK_BLUR_STYLE, //!< solid inside, fuzzy outside
|
||||
OUTER_SK_BLUR_STYLE, //!< nothing inside, fuzzy outside
|
||||
INNER_SK_BLUR_STYLE, //!< fuzzy inside, nothing outside
|
||||
} sk_blurstyle_t;
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_maskfilter_t. Must be
|
||||
balanced by a call to sk_maskfilter_unref().
|
||||
*/
|
||||
void sk_maskfilter_ref(sk_maskfilter_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_maskfilter_t and any other associated resources. New
|
||||
sk_maskfilter_t are created with a reference count of 1.
|
||||
*/
|
||||
void sk_maskfilter_unref(sk_maskfilter_t*);
|
||||
|
||||
/**
|
||||
Create a blur maskfilter.
|
||||
@param sk_blurstyle_t The SkBlurStyle to use
|
||||
@param sigma Standard deviation of the Gaussian blur to apply. Must be > 0.
|
||||
*/
|
||||
sk_maskfilter_t* sk_maskfilter_new_blur(sk_blurstyle_t, float sigma);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_matrix_DEFINED
|
||||
#define sk_matrix_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/** Set the matrix to identity */
|
||||
void sk_matrix_set_identity(sk_matrix_t*);
|
||||
|
||||
/** Set the matrix to translate by (tx, ty). */
|
||||
void sk_matrix_set_translate(sk_matrix_t*, float tx, float ty);
|
||||
/**
|
||||
Preconcats the matrix with the specified translation.
|
||||
M' = M * T(dx, dy)
|
||||
*/
|
||||
void sk_matrix_pre_translate(sk_matrix_t*, float tx, float ty);
|
||||
/**
|
||||
Postconcats the matrix with the specified translation.
|
||||
M' = T(dx, dy) * M
|
||||
*/
|
||||
void sk_matrix_post_translate(sk_matrix_t*, float tx, float ty);
|
||||
|
||||
/** Set the matrix to scale by sx and sy. */
|
||||
void sk_matrix_set_scale(sk_matrix_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcats the matrix with the specified scale.
|
||||
M' = M * S(sx, sy)
|
||||
*/
|
||||
void sk_matrix_pre_scale(sk_matrix_t*, float sx, float sy);
|
||||
/**
|
||||
Postconcats the matrix with the specified scale.
|
||||
M' = S(sx, sy) * M
|
||||
*/
|
||||
void sk_matrix_post_scale(sk_matrix_t*, float sx, float sy);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_paint_DEFINED
|
||||
#define sk_paint_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Create a new paint with default settings:
|
||||
antialias : false
|
||||
stroke : false
|
||||
stroke width : 0.0f (hairline)
|
||||
stroke miter : 4.0f
|
||||
stroke cap : BUTT_SK_STROKE_CAP
|
||||
stroke join : MITER_SK_STROKE_JOIN
|
||||
color : opaque black
|
||||
shader : NULL
|
||||
maskfilter : NULL
|
||||
xfermode_mode : SRCOVER_SK_XFERMODE_MODE
|
||||
*/
|
||||
SK_API sk_paint_t* sk_paint_new();
|
||||
/**
|
||||
Release the memory storing the sk_paint_t and unref() all
|
||||
associated objects.
|
||||
*/
|
||||
SK_API void sk_paint_delete(sk_paint_t*);
|
||||
|
||||
/**
|
||||
Return true iff the paint has antialiasing enabled.
|
||||
*/
|
||||
SK_API bool sk_paint_is_antialias(const sk_paint_t*);
|
||||
/**
|
||||
Set to true to enable antialiasing, false to disable it on this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
|
||||
|
||||
/**
|
||||
Return the paint's curent drawing color.
|
||||
*/
|
||||
SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's curent drawing color.
|
||||
*/
|
||||
SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
|
||||
|
||||
/* stroke settings */
|
||||
|
||||
/**
|
||||
Return true iff stroking is enabled rather than filling on this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API bool sk_paint_is_stroke(const sk_paint_t*);
|
||||
/**
|
||||
Set to true to enable stroking rather than filling with this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
|
||||
|
||||
/**
|
||||
Return the width for stroking. A value of 0 strokes in hairline mode.
|
||||
*/
|
||||
SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
|
||||
/**
|
||||
Set the width for stroking. A value of 0 strokes in hairline mode
|
||||
(always draw 1-pixel wide, regardless of the matrix).
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
|
||||
|
||||
/**
|
||||
Return the paint's stroke miter value. This is used to control the
|
||||
behavior of miter joins when the joins angle is sharp.
|
||||
*/
|
||||
SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke miter value. This is used to control the
|
||||
behavior of miter joins when the joins angle is sharp. This value
|
||||
must be >= 0.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
|
||||
|
||||
typedef enum {
|
||||
BUTT_SK_STROKE_CAP,
|
||||
ROUND_SK_STROKE_CAP,
|
||||
SQUARE_SK_STROKE_CAP
|
||||
} sk_stroke_cap_t;
|
||||
|
||||
/**
|
||||
Return the paint's stroke cap type, controlling how the start and
|
||||
end of stroked lines and paths are treated.
|
||||
*/
|
||||
SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke cap type, controlling how the start and
|
||||
end of stroked lines and paths are treated.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
|
||||
|
||||
typedef enum {
|
||||
MITER_SK_STROKE_JOIN,
|
||||
ROUND_SK_STROKE_JOIN,
|
||||
BEVEL_SK_STROKE_JOIN
|
||||
} sk_stroke_join_t;
|
||||
|
||||
/**
|
||||
Return the paint's stroke join type, specifies the treatment that
|
||||
is applied to corners in paths and rectangles
|
||||
*/
|
||||
SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke join type, specifies the treatment that
|
||||
is applied to corners in paths and rectangles
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
|
||||
|
||||
/**
|
||||
* Set the paint's shader to the specified parameter. This will automatically call unref() on
|
||||
* any previous value, and call ref() on the new value.
|
||||
*/
|
||||
SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
|
||||
|
||||
/**
|
||||
* Set the paint's maskfilter to the specified parameter. This will automatically call unref() on
|
||||
* any previous value, and call ref() on the new value.
|
||||
*/
|
||||
SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
|
||||
|
||||
/**
|
||||
* Set the paint's xfermode to the specified parameter.
|
||||
*/
|
||||
SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_path_DEFINED
|
||||
#define sk_path_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef enum {
|
||||
CW_SK_PATH_DIRECTION,
|
||||
CCW_SK_PATH_DIRECTION,
|
||||
} sk_path_direction_t;
|
||||
|
||||
/** Create a new, empty path. */
|
||||
SK_API sk_path_t* sk_path_new();
|
||||
/** Release the memory used by a sk_path_t. */
|
||||
SK_API void sk_path_delete(sk_path_t*);
|
||||
|
||||
/** Set the beginning of the next contour to the point (x,y). */
|
||||
SK_API void sk_path_move_to(sk_path_t*, float x, float y);
|
||||
/**
|
||||
Add a line from the last point to the specified point (x,y). If no
|
||||
sk_path_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_line_to(sk_path_t*, float x, float y);
|
||||
/**
|
||||
Add a quadratic bezier from the last point, approaching control
|
||||
point (x0,y0), and ending at (x1,y1). If no sk_path_move_to() call
|
||||
has been made for this contour, the first point is automatically
|
||||
set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1);
|
||||
/**
|
||||
Add a conic curve from the last point, approaching control point
|
||||
(x0,y01), and ending at (x1,y1) with weight w. If no
|
||||
sk_path_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_conic_to(sk_path_t*, float x0, float y0, float x1, float y1, float w);
|
||||
/**
|
||||
Add a cubic bezier from the last point, approaching control points
|
||||
(x0,y0) and (x1,y1), and ending at (x2,y2). If no
|
||||
sk_path_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_cubic_to(sk_path_t*,
|
||||
float x0, float y0,
|
||||
float x1, float y1,
|
||||
float x2, float y2);
|
||||
/**
|
||||
Close the current contour. If the current point is not equal to the
|
||||
first point of the contour, a line segment is automatically added.
|
||||
*/
|
||||
SK_API void sk_path_close(sk_path_t*);
|
||||
|
||||
/**
|
||||
Add a closed rectangle contour to the path.
|
||||
*/
|
||||
SK_API void sk_path_add_rect(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
|
||||
/**
|
||||
Add a closed oval contour to the path
|
||||
*/
|
||||
SK_API void sk_path_add_oval(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
|
||||
|
||||
/**
|
||||
* If the path is empty, return false and set the rect parameter to [0, 0, 0, 0].
|
||||
* else return true and set the rect parameter to the bounds of the control-points
|
||||
* of the path.
|
||||
*/
|
||||
SK_API bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_picture_DEFINED
|
||||
#define sk_picture_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Create a new sk_picture_recorder_t. Its resources should be
|
||||
released with a call to sk_picture_recorder_delete().
|
||||
*/
|
||||
sk_picture_recorder_t* sk_picture_recorder_new();
|
||||
/**
|
||||
Release the memory and other resources used by this
|
||||
sk_picture_recorder_t.
|
||||
*/
|
||||
void sk_picture_recorder_delete(sk_picture_recorder_t*);
|
||||
|
||||
/**
|
||||
Returns the canvas that records the drawing commands
|
||||
|
||||
@param sk_rect_t* the cull rect used when recording this
|
||||
picture. Any drawing the falls outside of this
|
||||
rect is undefined, and may be drawn or it may not.
|
||||
*/
|
||||
sk_canvas_t* sk_picture_recorder_begin_recording(sk_picture_recorder_t*, const sk_rect_t*);
|
||||
/**
|
||||
Signal that the caller is done recording. This invalidates the
|
||||
canvas returned by begin_recording. Ownership of the sk_picture_t
|
||||
is passed to the caller, who must call sk_picture_unref() when
|
||||
they are done using it. The returned picture is immutable.
|
||||
*/
|
||||
sk_picture_t* sk_picture_recorder_end_recording(sk_picture_recorder_t*);
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_picture_t. Must be
|
||||
balanced by a call to sk_picture_unref().
|
||||
*/
|
||||
void sk_picture_ref(sk_picture_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_picture_t and any resouces it may be managing. New
|
||||
sk_picture_t are created with a reference count of 1.
|
||||
*/
|
||||
void sk_picture_unref(sk_picture_t*);
|
||||
|
||||
/**
|
||||
Returns a non-zero value unique among all pictures.
|
||||
*/
|
||||
uint32_t sk_picture_get_unique_id(sk_picture_t*);
|
||||
|
||||
/**
|
||||
Return the cull rect specified when this picture was recorded.
|
||||
*/
|
||||
sk_rect_t sk_picture_get_bounds(sk_picture_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_shader_DEFINED
|
||||
#define sk_shader_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
void sk_shader_ref(sk_shader_t*);
|
||||
void sk_shader_unref(sk_shader_t*);
|
||||
|
||||
typedef enum {
|
||||
CLAMP_SK_SHADER_TILEMODE,
|
||||
REPEAT_SK_SHADER_TILEMODE,
|
||||
MIRROR_SK_SHADER_TILEMODE,
|
||||
} sk_shader_tilemode_t;
|
||||
|
||||
/**
|
||||
Returns a shader that generates a linear gradient between the two
|
||||
specified points.
|
||||
|
||||
@param points The start and end points for the gradient.
|
||||
@param colors The array[count] of colors, to be distributed between
|
||||
the two points
|
||||
@param colorPos May be NULL. array[count] of SkScalars, or NULL, of
|
||||
the relative position of each corresponding color
|
||||
in the colors array. If this is NULL, the the
|
||||
colors are distributed evenly between the start
|
||||
and end point. If this is not null, the values
|
||||
must begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param colorCount Must be >=2. The number of colors (and pos if not
|
||||
NULL) entries.
|
||||
@param mode The tiling mode
|
||||
*/
|
||||
sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2],
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
|
||||
/**
|
||||
Returns a shader that generates a radial gradient given the center
|
||||
and radius.
|
||||
|
||||
@param center The center of the circle for this gradient
|
||||
@param radius Must be positive. The radius of the circle for this
|
||||
gradient
|
||||
@param colors The array[count] of colors, to be distributed
|
||||
between the center and edge of the circle
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the center and edge of
|
||||
the circle. If this is not null, the values must
|
||||
begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param count Must be >= 2. The number of colors (and pos if not
|
||||
NULL) entries
|
||||
@param tileMode The tiling mode
|
||||
@param localMatrix May be NULL
|
||||
*/
|
||||
sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center,
|
||||
float radius,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
/**
|
||||
Returns a shader that generates a sweep gradient given a center.
|
||||
|
||||
@param center The coordinates of the center of the sweep
|
||||
@param colors The array[count] of colors, to be distributed around
|
||||
the center.
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the center and edge of
|
||||
the circle. If this is not null, the values must
|
||||
begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param colorCount Must be >= 2. The number of colors (and pos if
|
||||
not NULL) entries
|
||||
@param localMatrix May be NULL
|
||||
*/
|
||||
sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
/**
|
||||
Returns a shader that generates a conical gradient given two circles, or
|
||||
returns NULL if the inputs are invalid. The gradient interprets the
|
||||
two circles according to the following HTML spec.
|
||||
http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
|
||||
|
||||
Returns a shader that generates a sweep gradient given a center.
|
||||
|
||||
@param start, startRadius Defines the first circle.
|
||||
@param end, endRadius Defines the first circle.
|
||||
@param colors The array[count] of colors, to be distributed between
|
||||
the two circles.
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the two circles. If
|
||||
this is not null, the values must begin with 0,
|
||||
end with 1.0, and intermediate values must be
|
||||
strictly increasing.
|
||||
@param colorCount Must be >= 2. The number of colors (and pos if
|
||||
not NULL) entries
|
||||
@param tileMode The tiling mode
|
||||
@param localMatrix May be NULL
|
||||
|
||||
*/
|
||||
sk_shader_t* sk_shader_new_two_point_conical_gradient(
|
||||
const sk_point_t* start,
|
||||
float startRadius,
|
||||
const sk_point_t* end,
|
||||
float endRadius,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_surface_DEFINED
|
||||
#define sk_surface_DEFINED
|
||||
|
||||
#include "sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Return a new surface, with the memory for the pixels automatically
|
||||
allocated. If the requested surface cannot be created, or the
|
||||
request is not a supported configuration, NULL will be returned.
|
||||
|
||||
@param sk_imageinfo_t* Specify the width, height, color type, and
|
||||
alpha type for the surface.
|
||||
|
||||
@param sk_surfaceprops_t* If not NULL, specify additional non-default
|
||||
properties of the surface.
|
||||
*/
|
||||
SK_API sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*, const sk_surfaceprops_t*);
|
||||
|
||||
/**
|
||||
Create a new surface which will draw into the specified pixels
|
||||
with the specified rowbytes. If the requested surface cannot be
|
||||
created, or the request is not a supported configuration, NULL
|
||||
will be returned.
|
||||
|
||||
@param sk_imageinfo_t* Specify the width, height, color type, and
|
||||
alpha type for the surface.
|
||||
@param void* pixels Specify the location in memory where the
|
||||
destination pixels are. This memory must
|
||||
outlast this surface.
|
||||
@param size_t rowBytes Specify the difference, in bytes, between
|
||||
each adjacent row. Should be at least
|
||||
(width * sizeof(one pixel)).
|
||||
@param sk_surfaceprops_t* If not NULL, specify additional non-default
|
||||
properties of the surface.
|
||||
*/
|
||||
SK_API sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*,
|
||||
void* pixels, size_t rowBytes,
|
||||
const sk_surfaceprops_t* props);
|
||||
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_surface_t and any pixel memory it may be managing. New
|
||||
sk_surface_t are created with a reference count of 1.
|
||||
*/
|
||||
SK_API void sk_surface_unref(sk_surface_t*);
|
||||
|
||||
/**
|
||||
* Return the canvas associated with this surface. Note: the canvas is owned by the surface,
|
||||
* so the returned object is only valid while the owning surface is valid.
|
||||
*/
|
||||
SK_API sk_canvas_t* sk_surface_get_canvas(sk_surface_t*);
|
||||
|
||||
/**
|
||||
* Call sk_image_unref() when the returned image is no longer used.
|
||||
*/
|
||||
SK_API sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_types_DEFINED
|
||||
#define sk_types_DEFINED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define SK_C_PLUS_PLUS_BEGIN_GUARD extern "C" {
|
||||
#define SK_C_PLUS_PLUS_END_GUARD }
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#define SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
#define SK_C_PLUS_PLUS_END_GUARD
|
||||
#endif
|
||||
|
||||
#ifndef SK_API
|
||||
#define SK_API
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef uint32_t sk_color_t;
|
||||
|
||||
/* This macro assumes all arguments are >=0 and <=255. */
|
||||
#define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define sk_color_get_a(c) (((c) >> 24) & 0xFF)
|
||||
#define sk_color_get_r(c) (((c) >> 16) & 0xFF)
|
||||
#define sk_color_get_g(c) (((c) >> 8) & 0xFF)
|
||||
#define sk_color_get_b(c) (((c) >> 0) & 0xFF)
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN_SK_COLORTYPE,
|
||||
RGBA_8888_SK_COLORTYPE,
|
||||
BGRA_8888_SK_COLORTYPE,
|
||||
ALPHA_8_SK_COLORTYPE,
|
||||
} sk_colortype_t;
|
||||
|
||||
typedef enum {
|
||||
OPAQUE_SK_ALPHATYPE,
|
||||
PREMUL_SK_ALPHATYPE,
|
||||
UNPREMUL_SK_ALPHATYPE,
|
||||
} sk_alphatype_t;
|
||||
|
||||
typedef enum {
|
||||
INTERSECT_SK_CLIPTYPE,
|
||||
DIFFERENCE_SK_CLIPTYPE,
|
||||
} sk_cliptype_t;
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN_SK_PIXELGEOMETRY,
|
||||
RGB_H_SK_PIXELGEOMETRY,
|
||||
BGR_H_SK_PIXELGEOMETRY,
|
||||
RGB_V_SK_PIXELGEOMETRY,
|
||||
BGR_V_SK_PIXELGEOMETRY,
|
||||
} sk_pixelgeometry_t;
|
||||
|
||||
/**
|
||||
Return the default sk_colortype_t; this is operating-system dependent.
|
||||
*/
|
||||
SK_API sk_colortype_t sk_colortype_get_default_8888();
|
||||
|
||||
typedef struct {
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
sk_colortype_t colorType;
|
||||
sk_alphatype_t alphaType;
|
||||
} sk_imageinfo_t;
|
||||
|
||||
typedef struct {
|
||||
sk_pixelgeometry_t pixelGeometry;
|
||||
} sk_surfaceprops_t;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} sk_point_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} sk_irect_t;
|
||||
|
||||
typedef struct {
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
} sk_rect_t;
|
||||
|
||||
typedef struct {
|
||||
float mat[9];
|
||||
} sk_matrix_t;
|
||||
|
||||
/**
|
||||
A sk_canvas_t encapsulates all of the state about drawing into a
|
||||
destination This includes a reference to the destination itself,
|
||||
and a stack of matrix/clip values.
|
||||
*/
|
||||
typedef struct sk_canvas_t sk_canvas_t;
|
||||
/**
|
||||
A sk_data_ holds an immutable data buffer.
|
||||
*/
|
||||
typedef struct sk_data_t sk_data_t;
|
||||
/**
|
||||
A sk_image_t is an abstraction for drawing a rectagle of pixels.
|
||||
The content of the image is always immutable, though the actual
|
||||
storage may change, if for example that image can be re-created via
|
||||
encoded data or other means.
|
||||
*/
|
||||
typedef struct sk_image_t sk_image_t;
|
||||
/**
|
||||
A sk_maskfilter_t is an object that perform transformations on an
|
||||
alpha-channel mask before drawing it; it may be installed into a
|
||||
sk_paint_t. Each time a primitive is drawn, it is first
|
||||
scan-converted into a alpha mask, which os handed to the
|
||||
maskfilter, which may create a new mask is to render into the
|
||||
destination.
|
||||
*/
|
||||
typedef struct sk_maskfilter_t sk_maskfilter_t;
|
||||
/**
|
||||
A sk_paint_t holds the style and color information about how to
|
||||
draw geometries, text and bitmaps.
|
||||
*/
|
||||
typedef struct sk_paint_t sk_paint_t;
|
||||
/**
|
||||
A sk_path_t encapsulates compound (multiple contour) geometric
|
||||
paths consisting of straight line segments, quadratic curves, and
|
||||
cubic curves.
|
||||
*/
|
||||
typedef struct sk_path_t sk_path_t;
|
||||
/**
|
||||
A sk_picture_t holds recorded canvas drawing commands to be played
|
||||
back at a later time.
|
||||
*/
|
||||
typedef struct sk_picture_t sk_picture_t;
|
||||
/**
|
||||
A sk_picture_recorder_t holds a sk_canvas_t that records commands
|
||||
to create a sk_picture_t.
|
||||
*/
|
||||
typedef struct sk_picture_recorder_t sk_picture_recorder_t;
|
||||
/**
|
||||
A sk_shader_t specifies the source color(s) for what is being drawn. If a
|
||||
paint has no shader, then the paint's color is used. If the paint
|
||||
has a shader, then the shader's color(s) are use instead, but they
|
||||
are modulated by the paint's alpha.
|
||||
*/
|
||||
typedef struct sk_shader_t sk_shader_t;
|
||||
/**
|
||||
A sk_surface_t holds the destination for drawing to a canvas. For
|
||||
raster drawing, the destination is an array of pixels in memory.
|
||||
For GPU drawing, the destination is a texture or a framebuffer.
|
||||
*/
|
||||
typedef struct sk_surface_t sk_surface_t;
|
||||
|
||||
typedef enum {
|
||||
CLEAR_SK_XFERMODE_MODE,
|
||||
SRC_SK_XFERMODE_MODE,
|
||||
DST_SK_XFERMODE_MODE,
|
||||
SRCOVER_SK_XFERMODE_MODE,
|
||||
DSTOVER_SK_XFERMODE_MODE,
|
||||
SRCIN_SK_XFERMODE_MODE,
|
||||
DSTIN_SK_XFERMODE_MODE,
|
||||
SRCOUT_SK_XFERMODE_MODE,
|
||||
DSTOUT_SK_XFERMODE_MODE,
|
||||
SRCATOP_SK_XFERMODE_MODE,
|
||||
DSTATOP_SK_XFERMODE_MODE,
|
||||
XOR_SK_XFERMODE_MODE,
|
||||
PLUS_SK_XFERMODE_MODE,
|
||||
MODULATE_SK_XFERMODE_MODE,
|
||||
SCREEN_SK_XFERMODE_MODE,
|
||||
OVERLAY_SK_XFERMODE_MODE,
|
||||
DARKEN_SK_XFERMODE_MODE,
|
||||
LIGHTEN_SK_XFERMODE_MODE,
|
||||
COLORDODGE_SK_XFERMODE_MODE,
|
||||
COLORBURN_SK_XFERMODE_MODE,
|
||||
HARDLIGHT_SK_XFERMODE_MODE,
|
||||
SOFTLIGHT_SK_XFERMODE_MODE,
|
||||
DIFFERENCE_SK_XFERMODE_MODE,
|
||||
EXCLUSION_SK_XFERMODE_MODE,
|
||||
MULTIPLY_SK_XFERMODE_MODE,
|
||||
HUE_SK_XFERMODE_MODE,
|
||||
SATURATION_SK_XFERMODE_MODE,
|
||||
COLOR_SK_XFERMODE_MODE,
|
||||
LUMINOSITY_SK_XFERMODE_MODE,
|
||||
} sk_xfermode_mode_t;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAndroidCodec_DEFINED
|
||||
#define SkAndroidCodec_DEFINED
|
||||
|
||||
#include "SkCodec.h"
|
||||
#include "SkEncodedFormat.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
/**
|
||||
* Abstract interface defining image codec functionality that is necessary for
|
||||
* Android.
|
||||
*/
|
||||
class SkAndroidCodec : SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* If this stream represents an encoded image that we know how to decode,
|
||||
* return an SkAndroidCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* The SkPngChunkReader handles unknown chunks in PNGs.
|
||||
* See SkCodec.h for more details.
|
||||
*
|
||||
* If NULL is returned, the stream is deleted immediately. Otherwise, the
|
||||
* SkCodec takes ownership of it, and will delete it when done with it.
|
||||
*/
|
||||
static SkAndroidCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL);
|
||||
|
||||
/**
|
||||
* If this data represents an encoded image that we know how to decode,
|
||||
* return an SkAndroidCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* The SkPngChunkReader handles unknown chunks in PNGs.
|
||||
* See SkCodec.h for more details.
|
||||
*
|
||||
* Will take a ref if it returns a codec, else will not affect the data.
|
||||
*/
|
||||
static SkAndroidCodec* NewFromData(SkData*, SkPngChunkReader* = NULL);
|
||||
|
||||
virtual ~SkAndroidCodec() {}
|
||||
|
||||
|
||||
const SkImageInfo& getInfo() const { return fInfo; }
|
||||
|
||||
/**
|
||||
* Format of the encoded data.
|
||||
*/
|
||||
SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
|
||||
|
||||
/**
|
||||
* Returns the dimensions of the scaled output image, for an input
|
||||
* sampleSize.
|
||||
*
|
||||
* When the sample size divides evenly into the original dimensions, the
|
||||
* scaled output dimensions will simply be equal to the original
|
||||
* dimensions divided by the sample size.
|
||||
*
|
||||
* When the sample size does not divide even into the original
|
||||
* dimensions, the codec may round up or down, depending on what is most
|
||||
* efficient to decode.
|
||||
*
|
||||
* Finally, the codec will always recommend a non-zero output, so the output
|
||||
* dimension will always be one if the sampleSize is greater than the
|
||||
* original dimension.
|
||||
*/
|
||||
SkISize getSampledDimensions(int sampleSize) const;
|
||||
|
||||
/**
|
||||
* Return (via desiredSubset) a subset which can decoded from this codec,
|
||||
* or false if the input subset is invalid.
|
||||
*
|
||||
* @param desiredSubset in/out parameter
|
||||
* As input, a desired subset of the original bounds
|
||||
* (as specified by getInfo).
|
||||
* As output, if true is returned, desiredSubset may
|
||||
* have been modified to a subset which is
|
||||
* supported. Although a particular change may have
|
||||
* been made to desiredSubset to create something
|
||||
* supported, it is possible other changes could
|
||||
* result in a valid subset. If false is returned,
|
||||
* desiredSubset's value is undefined.
|
||||
* @return true If the input desiredSubset is valid.
|
||||
* desiredSubset may be modified to a subset
|
||||
* supported by the codec.
|
||||
* false If desiredSubset is invalid (NULL or not fully
|
||||
* contained within the image).
|
||||
*/
|
||||
bool getSupportedSubset(SkIRect* desiredSubset) const;
|
||||
// TODO: Rename SkCodec::getValidSubset() to getSupportedSubset()
|
||||
|
||||
/**
|
||||
* Returns the dimensions of the scaled, partial output image, for an
|
||||
* input sampleSize and subset.
|
||||
*
|
||||
* @param sampleSize Factor to scale down by.
|
||||
* @param subset Must be a valid subset of the original image
|
||||
* dimensions and a subset supported by SkAndroidCodec.
|
||||
* getSubset() can be used to obtain a subset supported
|
||||
* by SkAndroidCodec.
|
||||
* @return Size of the scaled partial image. Or zero size
|
||||
* if either of the inputs is invalid.
|
||||
*/
|
||||
SkISize getSampledSubsetDimensions(int sampleSize, const SkIRect& subset) const;
|
||||
|
||||
/**
|
||||
* Additional options to pass to getAndroidPixels().
|
||||
*/
|
||||
// FIXME: It's a bit redundant to name these AndroidOptions when this class is already
|
||||
// called SkAndroidCodec. On the other hand, it's may be a bit confusing to call
|
||||
// these Options when SkCodec has a slightly different set of Options. Maybe these
|
||||
// should be DecodeOptions or SamplingOptions?
|
||||
struct AndroidOptions {
|
||||
AndroidOptions()
|
||||
: fZeroInitialized(SkCodec::kNo_ZeroInitialized)
|
||||
, fSubset(nullptr)
|
||||
, fColorPtr(nullptr)
|
||||
, fColorCount(nullptr)
|
||||
, fSampleSize(1)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Indicates is destination pixel memory is zero initialized.
|
||||
*/
|
||||
SkCodec::ZeroInitialized fZeroInitialized;
|
||||
|
||||
/**
|
||||
* If not NULL, represents a subset of the original image to decode.
|
||||
*
|
||||
* Must be within the bounds returned by getInfo().
|
||||
*
|
||||
* If the EncodedFormat is kWEBP_SkEncodedFormat, the top and left
|
||||
* values must be even.
|
||||
*/
|
||||
SkIRect* fSubset;
|
||||
|
||||
/**
|
||||
* If the client has requested a decode to kIndex8_SkColorType
|
||||
* (specified in the SkImageInfo), then the caller must provide
|
||||
* storage for up to 256 SkPMColor values in fColorPtr. On success,
|
||||
* the codec must copy N colors into that storage, (where N is the
|
||||
* logical number of table entries) and set fColorCount to N.
|
||||
*
|
||||
* If the client does not request kIndex8_SkColorType, then the last
|
||||
* two parameters may be NULL. If fColorCount is not null, it will be
|
||||
* set to 0.
|
||||
*/
|
||||
SkPMColor* fColorPtr;
|
||||
int* fColorCount;
|
||||
|
||||
/**
|
||||
* The client may provide an integer downscale factor for the decode.
|
||||
* The codec may implement this downscaling by sampling or another
|
||||
* method if it is more efficient.
|
||||
*/
|
||||
int fSampleSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode into the given pixels, a block of memory of size at
|
||||
* least (info.fHeight - 1) * rowBytes + (info.fWidth *
|
||||
* bytesPerPixel)
|
||||
*
|
||||
* Repeated calls to this function should give the same results,
|
||||
* allowing the PixelRef to be immutable.
|
||||
*
|
||||
* @param info A description of the format (config, size)
|
||||
* expected by the caller. This can simply be identical
|
||||
* to the info returned by getInfo().
|
||||
*
|
||||
* This contract also allows the caller to specify
|
||||
* different output-configs, which the implementation can
|
||||
* decide to support or not.
|
||||
*
|
||||
* A size that does not match getInfo() implies a request
|
||||
* to scale or subset. If the codec cannot perform this
|
||||
* scaling or subsetting, it will return an error code.
|
||||
*
|
||||
* If info is kIndex8_SkColorType, then the caller must provide storage for up to 256
|
||||
* SkPMColor values in options->fColorPtr. On success the codec must copy N colors into
|
||||
* that storage, (where N is the logical number of table entries) and set
|
||||
* options->fColorCount to N.
|
||||
*
|
||||
* If info is not kIndex8_SkColorType, options->fColorPtr and options->fColorCount may
|
||||
* be nullptr.
|
||||
*
|
||||
* The AndroidOptions object is also used to specify any requested scaling or subsetting
|
||||
* using options->fSampleSize and options->fSubset.
|
||||
*
|
||||
* @return Result kSuccess, or another value explaining the type of failure.
|
||||
*/
|
||||
// FIXME: It's a bit redundant to name this getAndroidPixels() when this class is already
|
||||
// called SkAndroidCodec. On the other hand, it's may be a bit confusing to call
|
||||
// this getPixels() when it is a slightly different API than SkCodec's getPixels().
|
||||
// Maybe this should be decode() or decodeSubset()?
|
||||
SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
|
||||
const AndroidOptions* options);
|
||||
|
||||
/**
|
||||
* Simplified version of getAndroidPixels() where we supply the default AndroidOptions.
|
||||
*
|
||||
* This will return an error if the info is kIndex_8_SkColorType and also will not perform
|
||||
* any scaling or subsetting.
|
||||
*/
|
||||
SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
|
||||
|
||||
protected:
|
||||
|
||||
SkAndroidCodec(const SkImageInfo&);
|
||||
|
||||
virtual SkEncodedFormat onGetEncodedFormat() const = 0;
|
||||
|
||||
virtual SkISize onGetSampledDimensions(int sampleSize) const = 0;
|
||||
|
||||
virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0;
|
||||
|
||||
virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels,
|
||||
size_t rowBytes, const AndroidOptions& options) = 0;
|
||||
|
||||
private:
|
||||
|
||||
// This will always be a reference to the info that is contained by the
|
||||
// embedded SkCodec.
|
||||
const SkImageInfo& fInfo;
|
||||
};
|
||||
#endif // SkAndroidCodec_DEFINED
|
||||
@@ -0,0 +1,614 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCodec_DEFINED
|
||||
#define SkCodec_DEFINED
|
||||
|
||||
#include "../private/SkTemplates.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkEncodedFormat.h"
|
||||
#include "SkImageInfo.h"
|
||||
#include "SkSize.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
class SkData;
|
||||
class SkPngChunkReader;
|
||||
class SkSampler;
|
||||
|
||||
/**
|
||||
* Abstraction layer directly on top of an image codec.
|
||||
*/
|
||||
class SkCodec : SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* If this stream represents an encoded image that we know how to decode,
|
||||
* return an SkCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* If the SkPngChunkReader is not NULL then:
|
||||
* If the image is not a PNG, the SkPngChunkReader will be ignored.
|
||||
* If the image is a PNG, the SkPngChunkReader will be reffed.
|
||||
* If the PNG has unknown chunks, the SkPngChunkReader will be used
|
||||
* to handle these chunks. SkPngChunkReader will be called to read
|
||||
* any unknown chunk at any point during the creation of the codec
|
||||
* or the decode. Note that if SkPngChunkReader fails to read a
|
||||
* chunk, this could result in a failure to create the codec or a
|
||||
* failure to decode the image.
|
||||
* If the PNG does not contain unknown chunks, the SkPngChunkReader
|
||||
* will not be used or modified.
|
||||
*
|
||||
* If NULL is returned, the stream is deleted immediately. Otherwise, the
|
||||
* SkCodec takes ownership of it, and will delete it when done with it.
|
||||
*/
|
||||
static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL);
|
||||
|
||||
/**
|
||||
* If this data represents an encoded image that we know how to decode,
|
||||
* return an SkCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* If the SkPngChunkReader is not NULL then:
|
||||
* If the image is not a PNG, the SkPngChunkReader will be ignored.
|
||||
* If the image is a PNG, the SkPngChunkReader will be reffed.
|
||||
* If the PNG has unknown chunks, the SkPngChunkReader will be used
|
||||
* to handle these chunks. SkPngChunkReader will be called to read
|
||||
* any unknown chunk at any point during the creation of the codec
|
||||
* or the decode. Note that if SkPngChunkReader fails to read a
|
||||
* chunk, this could result in a failure to create the codec or a
|
||||
* failure to decode the image.
|
||||
* If the PNG does not contain unknown chunks, the SkPngChunkReader
|
||||
* will not be used or modified.
|
||||
*
|
||||
* Will take a ref if it returns a codec, else will not affect the data.
|
||||
*/
|
||||
static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL);
|
||||
|
||||
virtual ~SkCodec();
|
||||
|
||||
/**
|
||||
* Return the ImageInfo associated with this codec.
|
||||
*/
|
||||
const SkImageInfo& getInfo() const { return fSrcInfo; }
|
||||
|
||||
/**
|
||||
* Return a size that approximately supports the desired scale factor.
|
||||
* The codec may not be able to scale efficiently to the exact scale
|
||||
* factor requested, so return a size that approximates that scale.
|
||||
* The returned value is the codec's suggestion for the closest valid
|
||||
* scale that it can natively support
|
||||
*/
|
||||
SkISize getScaledDimensions(float desiredScale) const {
|
||||
// Negative and zero scales are errors.
|
||||
SkASSERT(desiredScale > 0.0f);
|
||||
if (desiredScale <= 0.0f) {
|
||||
return SkISize::Make(0, 0);
|
||||
}
|
||||
|
||||
// Upscaling is not supported. Return the original size if the client
|
||||
// requests an upscale.
|
||||
if (desiredScale >= 1.0f) {
|
||||
return this->getInfo().dimensions();
|
||||
}
|
||||
return this->onGetScaledDimensions(desiredScale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return (via desiredSubset) a subset which can decoded from this codec,
|
||||
* or false if this codec cannot decode subsets or anything similar to
|
||||
* desiredSubset.
|
||||
*
|
||||
* @param desiredSubset In/out parameter. As input, a desired subset of
|
||||
* the original bounds (as specified by getInfo). If true is returned,
|
||||
* desiredSubset may have been modified to a subset which is
|
||||
* supported. Although a particular change may have been made to
|
||||
* desiredSubset to create something supported, it is possible other
|
||||
* changes could result in a valid subset.
|
||||
* If false is returned, desiredSubset's value is undefined.
|
||||
* @return true if this codec supports decoding desiredSubset (as
|
||||
* returned, potentially modified)
|
||||
*/
|
||||
bool getValidSubset(SkIRect* desiredSubset) const {
|
||||
return this->onGetValidSubset(desiredSubset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format of the encoded data.
|
||||
*/
|
||||
SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
|
||||
|
||||
/**
|
||||
* Used to describe the result of a call to getPixels().
|
||||
*
|
||||
* Result is the union of possible results from subclasses.
|
||||
*/
|
||||
enum Result {
|
||||
/**
|
||||
* General return value for success.
|
||||
*/
|
||||
kSuccess,
|
||||
/**
|
||||
* The input is incomplete. A partial image was generated.
|
||||
*/
|
||||
kIncompleteInput,
|
||||
/**
|
||||
* The generator cannot convert to match the request, ignoring
|
||||
* dimensions.
|
||||
*/
|
||||
kInvalidConversion,
|
||||
/**
|
||||
* The generator cannot scale to requested size.
|
||||
*/
|
||||
kInvalidScale,
|
||||
/**
|
||||
* Parameters (besides info) are invalid. e.g. NULL pixels, rowBytes
|
||||
* too small, etc.
|
||||
*/
|
||||
kInvalidParameters,
|
||||
/**
|
||||
* The input did not contain a valid image.
|
||||
*/
|
||||
kInvalidInput,
|
||||
/**
|
||||
* Fulfilling this request requires rewinding the input, which is not
|
||||
* supported for this input.
|
||||
*/
|
||||
kCouldNotRewind,
|
||||
/**
|
||||
* This method is not implemented by this codec.
|
||||
* FIXME: Perhaps this should be kUnsupported?
|
||||
*/
|
||||
kUnimplemented,
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether or not the memory passed to getPixels is zero initialized.
|
||||
*/
|
||||
enum ZeroInitialized {
|
||||
/**
|
||||
* The memory passed to getPixels is zero initialized. The SkCodec
|
||||
* may take advantage of this by skipping writing zeroes.
|
||||
*/
|
||||
kYes_ZeroInitialized,
|
||||
/**
|
||||
* The memory passed to getPixels has not been initialized to zero,
|
||||
* so the SkCodec must write all zeroes to memory.
|
||||
*
|
||||
* This is the default. It will be used if no Options struct is used.
|
||||
*/
|
||||
kNo_ZeroInitialized,
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional options to pass to getPixels.
|
||||
*/
|
||||
struct Options {
|
||||
Options()
|
||||
: fZeroInitialized(kNo_ZeroInitialized)
|
||||
, fSubset(NULL)
|
||||
{}
|
||||
|
||||
ZeroInitialized fZeroInitialized;
|
||||
/**
|
||||
* If not NULL, represents a subset of the original image to decode.
|
||||
* Must be within the bounds returned by getInfo().
|
||||
* If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which
|
||||
* currently supports subsets), the top and left values must be even.
|
||||
*
|
||||
* In getPixels, we will attempt to decode the exact rectangular
|
||||
* subset specified by fSubset.
|
||||
*
|
||||
* In a scanline decode, it does not make sense to specify a subset
|
||||
* top or subset height, since the client already controls which rows
|
||||
* to get and which rows to skip. During scanline decodes, we will
|
||||
* require that the subset top be zero and the subset height be equal
|
||||
* to the full height. We will, however, use the values of
|
||||
* subset left and subset width to decode partial scanlines on calls
|
||||
* to getScanlines().
|
||||
*/
|
||||
SkIRect* fSubset;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode into the given pixels, a block of memory of size at
|
||||
* least (info.fHeight - 1) * rowBytes + (info.fWidth *
|
||||
* bytesPerPixel)
|
||||
*
|
||||
* Repeated calls to this function should give the same results,
|
||||
* allowing the PixelRef to be immutable.
|
||||
*
|
||||
* @param info A description of the format (config, size)
|
||||
* expected by the caller. This can simply be identical
|
||||
* to the info returned by getInfo().
|
||||
*
|
||||
* This contract also allows the caller to specify
|
||||
* different output-configs, which the implementation can
|
||||
* decide to support or not.
|
||||
*
|
||||
* A size that does not match getInfo() implies a request
|
||||
* to scale. If the generator cannot perform this scale,
|
||||
* it will return kInvalidScale.
|
||||
*
|
||||
* If info is kIndex8_SkColorType, then the caller must provide storage for up to 256
|
||||
* SkPMColor values in ctable. On success the generator must copy N colors into that storage,
|
||||
* (where N is the logical number of table entries) and set ctableCount to N.
|
||||
*
|
||||
* If info is not kIndex8_SkColorType, then the last two parameters may be NULL. If ctableCount
|
||||
* is not null, it will be set to 0.
|
||||
*
|
||||
* If a scanline decode is in progress, scanline mode will end, requiring the client to call
|
||||
* startScanlineDecode() in order to return to decoding scanlines.
|
||||
*
|
||||
* @return Result kSuccess, or another value explaining the type of failure.
|
||||
*/
|
||||
Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options*,
|
||||
SkPMColor ctable[], int* ctableCount);
|
||||
|
||||
/**
|
||||
* Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and
|
||||
* uses the default Options.
|
||||
*/
|
||||
Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* Some images may initially report that they have alpha due to the format
|
||||
* of the encoded data, but then never use any colors which have alpha
|
||||
* less than 100%. This function can be called *after* decoding to
|
||||
* determine if such an image truly had alpha. Calling it before decoding
|
||||
* is undefined.
|
||||
* FIXME: see skbug.com/3582.
|
||||
*/
|
||||
bool reallyHasAlpha() const {
|
||||
return this->onReallyHasAlpha();
|
||||
}
|
||||
|
||||
/**
|
||||
* The remaining functions revolve around decoding scanlines.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare for a scanline decode with the specified options.
|
||||
*
|
||||
* After this call, this class will be ready to decode the first scanline.
|
||||
*
|
||||
* This must be called in order to call getScanlines or skipScanlines.
|
||||
*
|
||||
* This may require rewinding the stream.
|
||||
*
|
||||
* Not all SkCodecs support this.
|
||||
*
|
||||
* @param dstInfo Info of the destination. If the dimensions do not match
|
||||
* those of getInfo, this implies a scale.
|
||||
* @param options Contains decoding options, including if memory is zero
|
||||
* initialized.
|
||||
* @param ctable A pointer to a color table. When dstInfo.colorType() is
|
||||
* kIndex8, this should be non-NULL and have enough storage for 256
|
||||
* colors. The color table will be populated after decoding the palette.
|
||||
* @param ctableCount A pointer to the size of the color table. When
|
||||
* dstInfo.colorType() is kIndex8, this should be non-NULL. It will
|
||||
* be modified to the true size of the color table (<= 256) after
|
||||
* decoding the palette.
|
||||
* @return Enum representing success or reason for failure.
|
||||
*/
|
||||
Result startScanlineDecode(const SkImageInfo& dstInfo, const SkCodec::Options* options,
|
||||
SkPMColor ctable[], int* ctableCount);
|
||||
|
||||
/**
|
||||
* Simplified version of startScanlineDecode() that asserts that info is NOT
|
||||
* kIndex8_SkColorType and uses the default Options.
|
||||
*/
|
||||
Result startScanlineDecode(const SkImageInfo& dstInfo);
|
||||
|
||||
/**
|
||||
* Write the next countLines scanlines into dst.
|
||||
*
|
||||
* Not valid to call before calling startScanlineDecode().
|
||||
*
|
||||
* @param dst Must be non-null, and large enough to hold countLines
|
||||
* scanlines of size rowBytes.
|
||||
* @param countLines Number of lines to write.
|
||||
* @param rowBytes Number of bytes per row. Must be large enough to hold
|
||||
* a scanline based on the SkImageInfo used to create this object.
|
||||
* @return the number of lines successfully decoded. If this value is
|
||||
* less than countLines, this will fill the remaining lines with a
|
||||
* default value.
|
||||
*/
|
||||
int getScanlines(void* dst, int countLines, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* Skip count scanlines.
|
||||
*
|
||||
* Not valid to call before calling startScanlineDecode().
|
||||
*
|
||||
* The default version just calls onGetScanlines and discards the dst.
|
||||
* NOTE: If skipped lines are the only lines with alpha, this default
|
||||
* will make reallyHasAlpha return true, when it could have returned
|
||||
* false.
|
||||
*
|
||||
* @return true if the scanlines were successfully skipped
|
||||
* false on failure, possible reasons for failure include:
|
||||
* An incomplete input image stream.
|
||||
* Calling this function before calling startScanlineDecode().
|
||||
* If countLines is less than zero or so large that it moves
|
||||
* the current scanline past the end of the image.
|
||||
*/
|
||||
bool skipScanlines(int countLines);
|
||||
|
||||
/**
|
||||
* The order in which rows are output from the scanline decoder is not the
|
||||
* same for all variations of all image types. This explains the possible
|
||||
* output row orderings.
|
||||
*/
|
||||
enum SkScanlineOrder {
|
||||
/*
|
||||
* By far the most common, this indicates that the image can be decoded
|
||||
* reliably using the scanline decoder, and that rows will be output in
|
||||
* the logical order.
|
||||
*/
|
||||
kTopDown_SkScanlineOrder,
|
||||
|
||||
/*
|
||||
* This indicates that the scanline decoder reliably outputs rows, but
|
||||
* they will be returned in reverse order. If the scanline format is
|
||||
* kBottomUp, the nextScanline() API can be used to determine the actual
|
||||
* y-coordinate of the next output row, but the client is not forced
|
||||
* to take advantage of this, given that it's not too tough to keep
|
||||
* track independently.
|
||||
*
|
||||
* For full image decodes, it is safe to get all of the scanlines at
|
||||
* once, since the decoder will handle inverting the rows as it
|
||||
* decodes.
|
||||
*
|
||||
* For subset decodes and sampling, it is simplest to get and skip
|
||||
* scanlines one at a time, using the nextScanline() API. It is
|
||||
* possible to ask for larger chunks at a time, but this should be used
|
||||
* with caution. As with full image decodes, the decoder will handle
|
||||
* inverting the requested rows, but rows will still be delivered
|
||||
* starting from the bottom of the image.
|
||||
*
|
||||
* Upside down bmps are an example.
|
||||
*/
|
||||
kBottomUp_SkScanlineOrder,
|
||||
|
||||
/*
|
||||
* This indicates that the scanline decoder reliably outputs rows, but
|
||||
* they will not be in logical order. If the scanline format is
|
||||
* kOutOfOrder, the nextScanline() API should be used to determine the
|
||||
* actual y-coordinate of the next output row.
|
||||
*
|
||||
* For this scanline ordering, it is advisable to get and skip
|
||||
* scanlines one at a time.
|
||||
*
|
||||
* Interlaced gifs are an example.
|
||||
*/
|
||||
kOutOfOrder_SkScanlineOrder,
|
||||
|
||||
/*
|
||||
* Indicates that the entire image must be decoded in order to output
|
||||
* any amount of scanlines. In this case, it is a REALLY BAD IDEA to
|
||||
* request scanlines 1-by-1 or in small chunks. The client should
|
||||
* determine which scanlines are needed and ask for all of them in
|
||||
* a single call to getScanlines().
|
||||
*
|
||||
* Interlaced pngs are an example.
|
||||
*/
|
||||
kNone_SkScanlineOrder,
|
||||
};
|
||||
|
||||
/**
|
||||
* An enum representing the order in which scanlines will be returned by
|
||||
* the scanline decoder.
|
||||
*/
|
||||
SkScanlineOrder getScanlineOrder() const { return this->onGetScanlineOrder(); }
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate of the next row to be returned by the scanline
|
||||
* decoder.
|
||||
*
|
||||
* This will equal fCurrScanline, except in the case of strangely
|
||||
* encoded image types (bottom-up bmps, interlaced gifs).
|
||||
*
|
||||
* Results are undefined when not in scanline decoding mode.
|
||||
*/
|
||||
int nextScanline() const { return this->outputScanline(fCurrScanline); }
|
||||
|
||||
/**
|
||||
* Returns the output y-coordinate of the row that corresponds to an input
|
||||
* y-coordinate. The input y-coordinate represents where the scanline
|
||||
* is located in the encoded data.
|
||||
*
|
||||
* This will equal inputScanline, except in the case of strangely
|
||||
* encoded image types (bottom-up bmps, interlaced gifs).
|
||||
*/
|
||||
int outputScanline(int inputScanline) const;
|
||||
|
||||
protected:
|
||||
SkCodec(const SkImageInfo&, SkStream*);
|
||||
|
||||
virtual SkISize onGetScaledDimensions(float /* desiredScale */) const {
|
||||
// By default, scaling is not supported.
|
||||
return this->getInfo().dimensions();
|
||||
}
|
||||
|
||||
// FIXME: What to do about subsets??
|
||||
/**
|
||||
* Subclasses should override if they support dimensions other than the
|
||||
* srcInfo's.
|
||||
*/
|
||||
virtual bool onDimensionsSupported(const SkISize&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual SkEncodedFormat onGetEncodedFormat() const = 0;
|
||||
|
||||
/**
|
||||
* @param rowsDecoded When the encoded image stream is incomplete, this function
|
||||
* will return kIncompleteInput and rowsDecoded will be set to
|
||||
* the number of scanlines that were successfully decoded.
|
||||
* This will allow getPixels() to fill the uninitialized memory.
|
||||
*/
|
||||
virtual Result onGetPixels(const SkImageInfo& info,
|
||||
void* pixels, size_t rowBytes, const Options&,
|
||||
SkPMColor ctable[], int* ctableCount,
|
||||
int* rowsDecoded) = 0;
|
||||
|
||||
virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const {
|
||||
// By default, subsets are not supported.
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool onReallyHasAlpha() const { return false; }
|
||||
|
||||
/**
|
||||
* If the stream was previously read, attempt to rewind.
|
||||
*
|
||||
* If the stream needed to be rewound, call onRewind.
|
||||
* @returns true if the codec is at the right position and can be used.
|
||||
* false if there was a failure to rewind.
|
||||
*
|
||||
* This is called by getPixels() and start(). Subclasses may call if they
|
||||
* need to rewind at another time.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT rewindIfNeeded();
|
||||
|
||||
/**
|
||||
* Called by rewindIfNeeded, if the stream needed to be rewound.
|
||||
*
|
||||
* Subclasses should do any set up needed after a rewind.
|
||||
*/
|
||||
virtual bool onRewind() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* On an incomplete input, getPixels() and getScanlines() will fill any uninitialized
|
||||
* scanlines. This allows the subclass to indicate what value to fill with.
|
||||
*
|
||||
* @param colorType Destination color type.
|
||||
* @param alphaType Destination alpha type.
|
||||
* @return The value with which to fill uninitialized pixels.
|
||||
*
|
||||
* Note that we can interpret the return value as an SkPMColor, a 16-bit 565 color,
|
||||
* an 8-bit gray color, or an 8-bit index into a color table, depending on the color
|
||||
* type.
|
||||
*/
|
||||
uint32_t getFillValue(SkColorType colorType, SkAlphaType alphaType) const {
|
||||
return this->onGetFillValue(colorType, alphaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some subclasses will override this function, but this is a useful default for the color
|
||||
* types that we support. Note that for color types that do not use the full 32-bits,
|
||||
* we will simply take the low bits of the fill value.
|
||||
*
|
||||
* kN32_SkColorType: Transparent or Black
|
||||
* kRGB_565_SkColorType: Black
|
||||
* kGray_8_SkColorType: Black
|
||||
* kIndex_8_SkColorType: First color in color table
|
||||
*/
|
||||
virtual uint32_t onGetFillValue(SkColorType /*colorType*/, SkAlphaType alphaType) const {
|
||||
return kOpaque_SkAlphaType == alphaType ? SK_ColorBLACK : SK_ColorTRANSPARENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get method for the input stream
|
||||
*/
|
||||
SkStream* stream() {
|
||||
return fStream.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* The remaining functions revolve around decoding scanlines.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Most images types will be kTopDown and will not need to override this function.
|
||||
*/
|
||||
virtual SkScanlineOrder onGetScanlineOrder() const { return kTopDown_SkScanlineOrder; }
|
||||
|
||||
/**
|
||||
* Update the next scanline. Used by interlaced png.
|
||||
*/
|
||||
void updateNextScanline(int newY) { fCurrScanline = newY; }
|
||||
|
||||
const SkImageInfo& dstInfo() const { return fDstInfo; }
|
||||
|
||||
const SkCodec::Options& options() const { return fOptions; }
|
||||
|
||||
virtual int onOutputScanline(int inputScanline) const;
|
||||
|
||||
private:
|
||||
const SkImageInfo fSrcInfo;
|
||||
SkAutoTDelete<SkStream> fStream;
|
||||
bool fNeedsRewind;
|
||||
// These fields are only meaningful during scanline decodes.
|
||||
SkImageInfo fDstInfo;
|
||||
SkCodec::Options fOptions;
|
||||
int fCurrScanline;
|
||||
|
||||
/**
|
||||
* Return whether these dimensions are supported as a scale.
|
||||
*
|
||||
* The codec may choose to cache the information about scale and subset.
|
||||
* Either way, the same information will be passed to onGetPixels/onStart
|
||||
* on success.
|
||||
*
|
||||
* This must return true for a size returned from getScaledDimensions.
|
||||
*/
|
||||
bool dimensionsSupported(const SkISize& dim) {
|
||||
return dim == fSrcInfo.dimensions() || this->onDimensionsSupported(dim);
|
||||
}
|
||||
|
||||
// Methods for scanline decoding.
|
||||
virtual SkCodec::Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
|
||||
const SkCodec::Options& /*options*/, SkPMColor* /*ctable*/, int* /*ctableCount*/) {
|
||||
return kUnimplemented;
|
||||
}
|
||||
|
||||
// Naive default version just calls onGetScanlines on temp memory.
|
||||
virtual bool onSkipScanlines(int countLines) {
|
||||
// FIXME (msarett): Make this a pure virtual and always override this.
|
||||
SkAutoMalloc storage(fDstInfo.minRowBytes());
|
||||
|
||||
// Note that we pass 0 to rowBytes so we continue to use the same memory.
|
||||
// Also note that while getScanlines checks that rowBytes is big enough,
|
||||
// onGetScanlines bypasses that check.
|
||||
// Calling the virtual method also means we do not double count
|
||||
// countLines.
|
||||
return countLines == this->onGetScanlines(storage.get(), countLines, 0);
|
||||
}
|
||||
|
||||
virtual int onGetScanlines(void* /*dst*/, int /*countLines*/, size_t /*rowBytes*/) { return 0; }
|
||||
|
||||
/**
|
||||
* On an incomplete decode, getPixels() and getScanlines() will call this function
|
||||
* to fill any uinitialized memory.
|
||||
*
|
||||
* @param dstInfo Contains the destination color type
|
||||
* Contains the destination alpha type
|
||||
* Contains the destination width
|
||||
* The height stored in this info is unused
|
||||
* @param dst Pointer to the start of destination pixel memory
|
||||
* @param rowBytes Stride length in destination pixel memory
|
||||
* @param zeroInit Indicates if memory is zero initialized
|
||||
* @param linesRequested Number of lines that the client requested
|
||||
* @param linesDecoded Number of lines that were successfully decoded
|
||||
*/
|
||||
void fillIncompleteImage(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
|
||||
ZeroInitialized zeroInit, int linesRequested, int linesDecoded);
|
||||
|
||||
/**
|
||||
* Return an object which will allow forcing scanline decodes to sample in X.
|
||||
*
|
||||
* May create a sampler, if one is not currently being used. Otherwise, does
|
||||
* not affect ownership.
|
||||
*
|
||||
* Only valid during scanline decoding.
|
||||
*/
|
||||
virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
|
||||
|
||||
friend class SkSampledCodec;
|
||||
};
|
||||
#endif // SkCodec_DEFINED
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkEncodedFormat_DEFINED
|
||||
#define SkEncodedFormat_DEFINED
|
||||
|
||||
/**
|
||||
* Enum describing format of encoded data.
|
||||
*/
|
||||
enum SkEncodedFormat {
|
||||
kUnknown_SkEncodedFormat,
|
||||
kBMP_SkEncodedFormat,
|
||||
kGIF_SkEncodedFormat,
|
||||
kICO_SkEncodedFormat,
|
||||
kJPEG_SkEncodedFormat,
|
||||
kPNG_SkEncodedFormat,
|
||||
kWBMP_SkEncodedFormat,
|
||||
kWEBP_SkEncodedFormat,
|
||||
kPKM_SkEncodedFormat,
|
||||
kKTX_SkEncodedFormat,
|
||||
kASTC_SkEncodedFormat,
|
||||
};
|
||||
#endif // SkEncodedFormat_DEFINED
|
||||
@@ -58,13 +58,6 @@
|
||||
//#define SK_DEBUG_GLYPH_CACHE
|
||||
//#define SK_DEBUG_PATH
|
||||
|
||||
/* To assist debugging, Skia provides an instance counting utility in
|
||||
include/core/SkInstCount.h. This flag turns on and off that utility to
|
||||
allow instance count tracking in either debug or release builds. By
|
||||
default it is enabled in debug but disabled in release.
|
||||
*/
|
||||
#define SK_ENABLE_INST_COUNT 0
|
||||
|
||||
/* If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
|
||||
it will call SK_CRASH(). If this is not defined it, it is defined in
|
||||
SkPostConfig.h to write to an illegal address
|
||||
@@ -107,14 +100,6 @@
|
||||
*/
|
||||
//#define SK_DEFAULT_IMAGE_CACHE_LIMIT (1024 * 1024)
|
||||
|
||||
/* If zlib is available and you want to support the flate compression
|
||||
algorithm (used in PDF generation), define SK_ZLIB_INCLUDE to be the
|
||||
include path. Alternatively, define SK_SYSTEM_ZLIB to use the system zlib
|
||||
library specified as "#include <zlib.h>".
|
||||
*/
|
||||
//#define SK_ZLIB_INCLUDE <zlib.h>
|
||||
//#define SK_SYSTEM_ZLIB
|
||||
|
||||
/* Define this to allow PDF scalars above 32k. The PDF/A spec doesn't allow
|
||||
them, but modern PDF interpreters should handle them just fine.
|
||||
*/
|
||||
@@ -139,17 +124,15 @@
|
||||
//#define SK_SUPPORT_UNITTEST
|
||||
#endif
|
||||
|
||||
/* If your system embeds skia and has complex event logging, define this
|
||||
symbol to name a file that maps the following macros to your system's
|
||||
equivalents:
|
||||
SK_TRACE_EVENT0(event)
|
||||
SK_TRACE_EVENT1(event, name1, value1)
|
||||
SK_TRACE_EVENT2(event, name1, value1, name2, value2)
|
||||
src/utils/SkDebugTrace.h has a trivial implementation that writes to
|
||||
the debug output stream. If SK_USER_TRACE_INCLUDE_FILE is not defined,
|
||||
SkTrace.h will define the above three macros to do nothing.
|
||||
*/
|
||||
//#undef SK_USER_TRACE_INCLUDE_FILE
|
||||
/* Change the ordering to work in X windows.
|
||||
*/
|
||||
//#ifdef SK_SAMPLES_FOR_X
|
||||
// #define SK_R32_SHIFT 16
|
||||
// #define SK_G32_SHIFT 8
|
||||
// #define SK_B32_SHIFT 0
|
||||
// #define SK_A32_SHIFT 24
|
||||
//#endif
|
||||
|
||||
|
||||
/* Determines whether to build code that supports the GPU backend. Some classes
|
||||
that are not GPU-specific, such as SkShader subclasses, have optional code
|
||||
@@ -161,40 +144,14 @@
|
||||
//#define SK_SUPPORT_GPU 1
|
||||
|
||||
|
||||
/* The PDF generation code uses Path Ops to generate inverse fills and complex
|
||||
* clipping paths, but at this time, Path Ops is not release ready yet. So,
|
||||
* the code is hidden behind this #define guard. If you are feeling adventurous
|
||||
* and want the latest and greatest PDF generation code, uncomment the #define.
|
||||
/* The PDF generation code uses Path Ops to handle complex clipping paths,
|
||||
* but at this time, Path Ops is not release ready yet. So, the code is
|
||||
* hidden behind this #define guard. If you are feeling adventurous and
|
||||
* want the latest and greatest PDF generation code, uncomment the #define.
|
||||
* When Path Ops is release ready, the define guards and this user config
|
||||
* define should be removed entirely.
|
||||
*/
|
||||
//#define SK_PDF_USE_PATHOPS
|
||||
|
||||
/* Skia uses these defines as the target of include preprocessor directives.
|
||||
* The header files pointed to by these defines provide declarations and
|
||||
* possibly inline implementations of threading primitives.
|
||||
*
|
||||
* See SkThread.h for documentation on what these includes must contain.
|
||||
*/
|
||||
//#define SK_ATOMICS_PLATFORM_H "SkAtomics_xxx.h"
|
||||
//#define SK_MUTEX_PLATFORM_H "SkMutex_xxx.h"
|
||||
#if defined(_MSC_VER)
|
||||
# define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_win.h"
|
||||
#else
|
||||
# define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_sync.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_win.h"
|
||||
#else
|
||||
# define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_pthread.h"
|
||||
#endif
|
||||
|
||||
#if defined(SK_CPU_ARM32) || defined(SK_CPU_ARM64)
|
||||
# define SK_BARRIERS_PLATFORM_H "../../src/ports/SkBarriers_arm.h"
|
||||
#else
|
||||
# define SK_BARRIERS_PLATFORM_H "../../src/ports/SkBarriers_x86.h"
|
||||
#endif
|
||||
//#define SK_PDF_USE_PATHOPS_CLIPPING
|
||||
|
||||
// On all platforms we have this byte order
|
||||
#define SK_A32_SHIFT 24
|
||||
@@ -205,8 +162,21 @@
|
||||
#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
|
||||
|
||||
#define SK_SUPPORT_LEGACY_GETDEVICE
|
||||
|
||||
#define SK_IGNORE_ETC1_SUPPORT
|
||||
|
||||
#define SK_RASTERIZE_EVEN_ROUNDING
|
||||
|
||||
#define GR_GL_PER_GL_FUNC_CALLBACK 1
|
||||
|
||||
#define MOZ_SKIA 1
|
||||
|
||||
#ifndef MOZ_IMPLICIT
|
||||
# ifdef MOZ_CLANG_PLUGIN
|
||||
# define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
|
||||
# else
|
||||
# define MOZ_IMPLICIT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkAdvancedTypefaceMetrics_DEFINED
|
||||
#define SkAdvancedTypefaceMetrics_DEFINED
|
||||
|
||||
#include "SkRect.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkString.h"
|
||||
#include "SkTDArray.h"
|
||||
#include "SkTemplates.h"
|
||||
|
||||
/** \class SkAdvancedTypefaceMetrics
|
||||
|
||||
The SkAdvancedTypefaceMetrics class is used by the PDF backend to correctly
|
||||
embed typefaces. This class is filled in with information about a given
|
||||
typeface by the SkFontHost class.
|
||||
*/
|
||||
|
||||
class SkAdvancedTypefaceMetrics : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkAdvancedTypefaceMetrics)
|
||||
|
||||
SkString fFontName;
|
||||
|
||||
enum FontType {
|
||||
kType1_Font,
|
||||
kType1CID_Font,
|
||||
kCFF_Font,
|
||||
kTrueType_Font,
|
||||
kOther_Font,
|
||||
};
|
||||
// The type of the underlying font program. This field determines which
|
||||
// of the following fields are valid. If it is kOther_Font the per glyph
|
||||
// information will never be populated.
|
||||
FontType fType;
|
||||
|
||||
enum FontFlags {
|
||||
kEmpty_FontFlag = 0x0, //!<No flags set
|
||||
kMultiMaster_FontFlag = 0x1, //!<May be true for Type1 or CFF fonts.
|
||||
kNotEmbeddable_FontFlag = 0x2, //!<May not be embedded.
|
||||
kNotSubsettable_FontFlag = 0x4, //!<May not be subset.
|
||||
};
|
||||
// Global font flags.
|
||||
FontFlags fFlags;
|
||||
|
||||
uint16_t fLastGlyphID; // The last valid glyph ID in the font.
|
||||
uint16_t fEmSize; // The size of the em box (defines font units).
|
||||
|
||||
// These enum values match the values used in the PDF file format.
|
||||
enum StyleFlags {
|
||||
kFixedPitch_Style = 0x00001,
|
||||
kSerif_Style = 0x00002,
|
||||
kScript_Style = 0x00008,
|
||||
kItalic_Style = 0x00040,
|
||||
kAllCaps_Style = 0x10000,
|
||||
kSmallCaps_Style = 0x20000,
|
||||
kForceBold_Style = 0x40000
|
||||
};
|
||||
uint16_t fStyle; // Font style characteristics.
|
||||
int16_t fItalicAngle; // Counterclockwise degrees from vertical of the
|
||||
// dominant vertical stroke for an Italic face.
|
||||
// The following fields are all in font units.
|
||||
int16_t fAscent; // Max height above baseline, not including accents.
|
||||
int16_t fDescent; // Max depth below baseline (negative).
|
||||
int16_t fStemV; // Thickness of dominant vertical stem.
|
||||
int16_t fCapHeight; // Height (from baseline) of top of flat capitals.
|
||||
|
||||
SkIRect fBBox; // The bounding box of all glyphs (in font units).
|
||||
|
||||
// The type of advance data wanted.
|
||||
enum PerGlyphInfo {
|
||||
kNo_PerGlyphInfo = 0x0, // Don't populate any per glyph info.
|
||||
kHAdvance_PerGlyphInfo = 0x1, // Populate horizontal advance data.
|
||||
kVAdvance_PerGlyphInfo = 0x2, // Populate vertical advance data.
|
||||
kGlyphNames_PerGlyphInfo = 0x4, // Populate glyph names (Type 1 only).
|
||||
kToUnicode_PerGlyphInfo = 0x8 // Populate ToUnicode table, ignored
|
||||
// for Type 1 fonts
|
||||
};
|
||||
|
||||
template <typename Data>
|
||||
struct AdvanceMetric {
|
||||
enum MetricType {
|
||||
kDefault, // Default advance: fAdvance.count = 1
|
||||
kRange, // Advances for a range: fAdvance.count = fEndID-fStartID
|
||||
kRun // fStartID-fEndID have same advance: fAdvance.count = 1
|
||||
};
|
||||
MetricType fType;
|
||||
uint16_t fStartId;
|
||||
uint16_t fEndId;
|
||||
SkTDArray<Data> fAdvance;
|
||||
SkAutoTDelete<AdvanceMetric<Data> > fNext;
|
||||
};
|
||||
|
||||
struct VerticalMetric {
|
||||
int16_t fVerticalAdvance;
|
||||
int16_t fOriginXDisp; // Horiz. displacement of the secondary origin.
|
||||
int16_t fOriginYDisp; // Vert. displacement of the secondary origin.
|
||||
};
|
||||
typedef AdvanceMetric<int16_t> WidthRange;
|
||||
typedef AdvanceMetric<VerticalMetric> VerticalAdvanceRange;
|
||||
|
||||
// This is indexed by glyph id.
|
||||
SkAutoTDelete<WidthRange> fGlyphWidths;
|
||||
// Only used for Vertical CID fonts.
|
||||
SkAutoTDelete<VerticalAdvanceRange> fVerticalMetrics;
|
||||
|
||||
// The names of each glyph, only populated for postscript fonts.
|
||||
SkAutoTDelete<SkAutoTArray<SkString> > fGlyphNames;
|
||||
|
||||
// The mapping from glyph to Unicode, only populated if
|
||||
// kToUnicode_PerGlyphInfo is passed to GetAdvancedTypefaceMetrics.
|
||||
SkTDArray<SkUnichar> fGlyphToUnicode;
|
||||
|
||||
private:
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
namespace skia_advanced_typeface_metrics_utils {
|
||||
|
||||
template <typename Data>
|
||||
void resetRange(SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range,
|
||||
int startId);
|
||||
|
||||
template <typename Data>
|
||||
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* appendRange(
|
||||
SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<Data> >* nextSlot,
|
||||
int startId);
|
||||
|
||||
template <typename Data>
|
||||
void finishRange(
|
||||
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range,
|
||||
int endId,
|
||||
typename SkAdvancedTypefaceMetrics::AdvanceMetric<Data>::MetricType
|
||||
type);
|
||||
|
||||
/** Retrieve advance data for glyphs. Used by the PDF backend. It calls
|
||||
underlying platform dependent API getAdvance to acquire the data.
|
||||
@param num_glyphs Total number of glyphs in the given font.
|
||||
@param glyphIDs For per-glyph info, specify subset of the font by
|
||||
giving glyph ids. Each integer represents a glyph
|
||||
id. Passing NULL means all glyphs in the font.
|
||||
@param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if
|
||||
glyphIDs is NULL.
|
||||
*/
|
||||
template <typename Data, typename FontHandle>
|
||||
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
|
||||
FontHandle fontHandle,
|
||||
int num_glyphs,
|
||||
const uint32_t* glyphIDs,
|
||||
uint32_t glyphIDsCount,
|
||||
bool (*getAdvance)(FontHandle fontHandle, int gId, Data* data));
|
||||
|
||||
} // namespace skia_advanced_typeface_metrics_utils
|
||||
|
||||
#endif
|
||||
@@ -10,12 +10,11 @@
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkString.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
class SkData;
|
||||
class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
class SkStream;
|
||||
class SkWStream;
|
||||
struct SkPoint;
|
||||
|
||||
/**
|
||||
@@ -27,12 +26,10 @@ public:
|
||||
virtual ~SkAnnotation();
|
||||
|
||||
static SkAnnotation* Create(const char key[], SkData* value) {
|
||||
return SkNEW_ARGS(SkAnnotation, (key, value));
|
||||
return new SkAnnotation(key, value);
|
||||
}
|
||||
|
||||
static SkAnnotation* Create(SkReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkAnnotation, (buffer));
|
||||
}
|
||||
static SkAnnotation* Create(SkReadBuffer& buffer) { return new SkAnnotation(buffer); }
|
||||
|
||||
/**
|
||||
* Return the data for the specified key, or NULL.
|
||||
|
||||
@@ -8,62 +8,24 @@
|
||||
#ifndef SkBBHFactory_DEFINED
|
||||
#define SkBBHFactory_DEFINED
|
||||
|
||||
#include "SkSize.h"
|
||||
#include "SkPoint.h"
|
||||
|
||||
#include "SkTypes.h"
|
||||
class SkBBoxHierarchy;
|
||||
struct SkRect;
|
||||
|
||||
class SK_API SkBBHFactory {
|
||||
public:
|
||||
/**
|
||||
* Allocate a new SkBBoxHierarchy. Return NULL on failure.
|
||||
*/
|
||||
virtual SkBBoxHierarchy* operator()(int width, int height) const = 0;
|
||||
virtual SkBBoxHierarchy* operator()(const SkRect& bounds) const = 0;
|
||||
virtual ~SkBBHFactory() {};
|
||||
};
|
||||
|
||||
class SK_API SkQuadTreeFactory : public SkBBHFactory {
|
||||
public:
|
||||
virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
|
||||
private:
|
||||
typedef SkBBHFactory INHERITED;
|
||||
};
|
||||
|
||||
|
||||
class SK_API SkRTreeFactory : public SkBBHFactory {
|
||||
public:
|
||||
virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
|
||||
SkBBoxHierarchy* operator()(const SkRect& bounds) const override;
|
||||
private:
|
||||
typedef SkBBHFactory INHERITED;
|
||||
};
|
||||
|
||||
class SK_API SkTileGridFactory : public SkBBHFactory {
|
||||
public:
|
||||
struct TileGridInfo {
|
||||
/** Tile placement interval */
|
||||
SkISize fTileInterval;
|
||||
|
||||
/** Pixel coverage overlap between adjacent tiles */
|
||||
SkISize fMargin;
|
||||
|
||||
/** Offset added to device-space bounding box positions to convert
|
||||
* them to tile-grid space. This can be used to adjust the "phase"
|
||||
* of the tile grid to match probable query rectangles that will be
|
||||
* used to search into the tile grid. As long as the offset is smaller
|
||||
* or equal to the margin, there is no need to extend the domain of
|
||||
* the tile grid to prevent data loss.
|
||||
*/
|
||||
SkIPoint fOffset;
|
||||
};
|
||||
|
||||
SkTileGridFactory(const TileGridInfo& info) : fInfo(info) { }
|
||||
|
||||
virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
TileGridInfo fInfo;
|
||||
|
||||
typedef SkBBHFactory INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "SkColor.h"
|
||||
#include "SkColorTable.h"
|
||||
#include "SkImageInfo.h"
|
||||
#include "SkPixmap.h"
|
||||
#include "SkPoint.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
@@ -38,29 +39,6 @@ class SK_API SkBitmap {
|
||||
public:
|
||||
class SK_API Allocator;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
|
||||
enum Config {
|
||||
kNo_Config, //!< bitmap has not been configured
|
||||
kA8_Config, //!< 8-bits per pixel, with only alpha specified (0 is transparent, 0xFF is opaque)
|
||||
kIndex8_Config, //!< 8-bits per pixel, using SkColorTable to specify the colors
|
||||
kRGB_565_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
|
||||
kARGB_4444_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
|
||||
kARGB_8888_Config, //!< 32-bits per pixel, (see SkColorPriv.h for packing)
|
||||
};
|
||||
|
||||
// do not add this to the Config enum, otherwise the compiler will let us
|
||||
// pass this as a valid parameter for Config.
|
||||
enum {
|
||||
kConfigCount = kARGB_8888_Config + 1
|
||||
};
|
||||
|
||||
/** Return the config for the bitmap. */
|
||||
Config config() const;
|
||||
|
||||
SK_ATTR_DEPRECATED("use config()")
|
||||
Config getConfig() const { return this->config(); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default construct creates a bitmap with zero width and height, and no pixels.
|
||||
* Its colortype is set to kUnknown_SkColorType.
|
||||
@@ -91,10 +69,11 @@ public:
|
||||
|
||||
const SkImageInfo& info() const { return fInfo; }
|
||||
|
||||
int width() const { return fInfo.fWidth; }
|
||||
int height() const { return fInfo.fHeight; }
|
||||
SkColorType colorType() const { return fInfo.fColorType; }
|
||||
SkAlphaType alphaType() const { return fInfo.fAlphaType; }
|
||||
int width() const { return fInfo.width(); }
|
||||
int height() const { return fInfo.height(); }
|
||||
SkColorType colorType() const { return fInfo.colorType(); }
|
||||
SkAlphaType alphaType() const { return fInfo.alphaType(); }
|
||||
SkColorProfileType profileType() const { return fInfo.profileType(); }
|
||||
|
||||
/**
|
||||
* Return the number of bytes per pixel based on the colortype. If the colortype is
|
||||
@@ -155,7 +134,7 @@ public:
|
||||
Note this truncates the result to 32bits. Call getSize64() to detect
|
||||
if the real size exceeds 32bits.
|
||||
*/
|
||||
size_t getSize() const { return fInfo.fHeight * fRowBytes; }
|
||||
size_t getSize() const { return fInfo.height() * fRowBytes; }
|
||||
|
||||
/** Return the number of bytes from the pointer returned by getPixels()
|
||||
to the end of the allocated space in the buffer. Required in
|
||||
@@ -167,7 +146,7 @@ public:
|
||||
* Return the full size of the bitmap, in bytes.
|
||||
*/
|
||||
int64_t computeSize64() const {
|
||||
return sk_64_mul(fInfo.fHeight, fRowBytes);
|
||||
return sk_64_mul(fInfo.height(), fRowBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,6 +212,14 @@ public:
|
||||
void getBounds(SkRect* bounds) const;
|
||||
void getBounds(SkIRect* bounds) const;
|
||||
|
||||
SkIRect bounds() const { return fInfo.bounds(); }
|
||||
SkISize dimensions() const { return fInfo.dimensions(); }
|
||||
// Returns the bounds of this bitmap, offset by its pixelref origin.
|
||||
SkIRect getSubset() const {
|
||||
return SkIRect::MakeXYWH(fPixelRefOrigin.x(), fPixelRefOrigin.y(),
|
||||
fInfo.width(), fInfo.height());
|
||||
}
|
||||
|
||||
bool setInfo(const SkImageInfo&, size_t rowBytes = 0);
|
||||
|
||||
/**
|
||||
@@ -241,7 +228,13 @@ public:
|
||||
* a colortable, then ColorTable must be non-null, and will be ref'd.
|
||||
* On failure, the bitmap will be set to empty and return false.
|
||||
*/
|
||||
bool allocPixels(const SkImageInfo&, SkPixelRefFactory*, SkColorTable*);
|
||||
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo&, SkPixelRefFactory*, SkColorTable*);
|
||||
|
||||
void allocPixels(const SkImageInfo& info, SkPixelRefFactory* factory, SkColorTable* ctable) {
|
||||
if (!this->tryAllocPixels(info, factory, ctable)) {
|
||||
sk_throw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the bitmap's pixels to match the requested image info and
|
||||
@@ -251,24 +244,32 @@ public:
|
||||
* the pixel size specified by info.colorType()) then false is returned
|
||||
* and the bitmap is set to empty.
|
||||
*/
|
||||
bool allocPixels(const SkImageInfo& info, size_t rowBytes);
|
||||
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* Allocate a pixelref to match the specified image info, using the default
|
||||
* allocator.
|
||||
* On success, the bitmap's pixels will be "locked", and return true.
|
||||
* On failure, the bitmap will be set to empty and return false.
|
||||
*/
|
||||
bool allocPixels(const SkImageInfo& info) {
|
||||
return this->allocPixels(info, info.minRowBytes());
|
||||
void allocPixels(const SkImageInfo& info, size_t rowBytes) {
|
||||
if (!this->tryAllocPixels(info, rowBytes)) {
|
||||
sk_throw();
|
||||
}
|
||||
}
|
||||
|
||||
bool allocN32Pixels(int width, int height, bool isOpaque = false) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
|
||||
if (isOpaque) {
|
||||
info.fAlphaType = kOpaque_SkAlphaType;
|
||||
}
|
||||
return this->allocPixels(info);
|
||||
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info) {
|
||||
return this->tryAllocPixels(info, info.minRowBytes());
|
||||
}
|
||||
|
||||
void allocPixels(const SkImageInfo& info) {
|
||||
this->allocPixels(info, info.minRowBytes());
|
||||
}
|
||||
|
||||
bool SK_WARN_UNUSED_RESULT tryAllocN32Pixels(int width, int height, bool isOpaque = false) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32(width, height,
|
||||
isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
|
||||
return this->tryAllocPixels(info);
|
||||
}
|
||||
|
||||
void allocN32Pixels(int width, int height, bool isOpaque = false) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32(width, height,
|
||||
isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
|
||||
this->allocPixels(info);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,6 +278,9 @@ public:
|
||||
* referenced, if releaseProc is not null, it will be called with the
|
||||
* pixels and context as parameters.
|
||||
* On failure, the bitmap will be set to empty and return false.
|
||||
*
|
||||
* If specified, the releaseProc will always be called, even on failure. It is also possible
|
||||
* for success but the releaseProc is immediately called (e.g. valid Info but NULL pixels).
|
||||
*/
|
||||
bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkColorTable*,
|
||||
void (*releaseProc)(void* addr, void* context), void* context);
|
||||
@@ -343,8 +347,12 @@ public:
|
||||
@return true if the allocation succeeds. If not the pixelref field of
|
||||
the bitmap will be unchanged.
|
||||
*/
|
||||
bool allocPixels(SkColorTable* ctable = NULL) {
|
||||
return this->allocPixels(NULL, ctable);
|
||||
bool SK_WARN_UNUSED_RESULT tryAllocPixels(SkColorTable* ctable = NULL) {
|
||||
return this->tryAllocPixels(NULL, ctable);
|
||||
}
|
||||
|
||||
void allocPixels(SkColorTable* ctable = NULL) {
|
||||
this->allocPixels(NULL, ctable);
|
||||
}
|
||||
|
||||
/** Use the specified Allocator to create the pixelref that manages the
|
||||
@@ -365,7 +373,13 @@ public:
|
||||
@return true if the allocation succeeds. If not the pixelref field of
|
||||
the bitmap will be unchanged.
|
||||
*/
|
||||
bool allocPixels(Allocator* allocator, SkColorTable* ctable);
|
||||
bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator, SkColorTable* ctable);
|
||||
|
||||
void allocPixels(Allocator* allocator, SkColorTable* ctable) {
|
||||
if (!this->tryAllocPixels(allocator, ctable)) {
|
||||
sk_throw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current pixelref object or NULL if there is none. This does
|
||||
@@ -423,13 +437,15 @@ public:
|
||||
*/
|
||||
bool lockPixelsAreWritable() const;
|
||||
|
||||
bool requestLock(SkAutoPixmapUnlock* result) const;
|
||||
|
||||
/** Call this to be sure that the bitmap is valid enough to be drawn (i.e.
|
||||
it has non-null pixels, and if required by its colortype, it has a
|
||||
non-null colortable. Returns true if all of the above are met.
|
||||
*/
|
||||
bool readyToDraw() const {
|
||||
return this->getPixels() != NULL &&
|
||||
(this->colorType() != kIndex_8_SkColorType || NULL != fColorTable);
|
||||
(this->colorType() != kIndex_8_SkColorType || fColorTable);
|
||||
}
|
||||
|
||||
/** Returns the pixelRef's texture, or NULL
|
||||
@@ -462,10 +478,7 @@ public:
|
||||
* of the color is ignored (treated as opaque). If the colortype only supports
|
||||
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored.
|
||||
*/
|
||||
void eraseColor(SkColor c) const {
|
||||
this->eraseARGB(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c),
|
||||
SkColorGetB(c));
|
||||
}
|
||||
void eraseColor(SkColor c) const;
|
||||
|
||||
/**
|
||||
* Fill the entire bitmap with the specified color.
|
||||
@@ -473,7 +486,9 @@ public:
|
||||
* of the color is ignored (treated as opaque). If the colortype only supports
|
||||
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored.
|
||||
*/
|
||||
void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const;
|
||||
void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const {
|
||||
this->eraseColor(SkColorSetARGB(a, r, g, b));
|
||||
}
|
||||
|
||||
SK_ATTR_DEPRECATED("use eraseARGB or eraseColor")
|
||||
void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const {
|
||||
@@ -486,29 +501,12 @@ public:
|
||||
* of the color is ignored (treated as opaque). If the colortype only supports
|
||||
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored.
|
||||
*/
|
||||
void eraseArea(const SkIRect& area, SkColor c) const;
|
||||
void erase(SkColor c, const SkIRect& area) const;
|
||||
|
||||
/** Scroll (a subset of) the contents of this bitmap by dx/dy. If there are
|
||||
no pixels allocated (i.e. getPixels() returns null) the method will
|
||||
still update the inval region (if present). If the bitmap is immutable,
|
||||
do nothing and return false.
|
||||
|
||||
@param subset The subset of the bitmap to scroll/move. To scroll the
|
||||
entire contents, specify [0, 0, width, height] or just
|
||||
pass null.
|
||||
@param dx The amount to scroll in X
|
||||
@param dy The amount to scroll in Y
|
||||
@param inval Optional (may be null). Returns the area of the bitmap that
|
||||
was scrolled away. E.g. if dx = dy = 0, then inval would
|
||||
be set to empty. If dx >= width or dy >= height, then
|
||||
inval would be set to the entire bounds of the bitmap.
|
||||
@return true if the scroll was doable. Will return false if the colortype is kUnkown or
|
||||
if the bitmap is immutable.
|
||||
If no pixels are present (i.e. getPixels() returns false)
|
||||
inval will still be updated, and true will be returned.
|
||||
*/
|
||||
bool scrollRect(const SkIRect* subset, int dx, int dy,
|
||||
SkRegion* inval = NULL) const;
|
||||
// DEPRECATED
|
||||
void eraseArea(const SkIRect& area, SkColor c) const {
|
||||
this->erase(c, area);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the SkColor of the specified pixel. In most cases this will
|
||||
@@ -665,12 +663,21 @@ public:
|
||||
bool extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator,
|
||||
SkIPoint* offset) const;
|
||||
|
||||
/**
|
||||
* If the pixels are available from this bitmap (w/o locking) return true, and fill out the
|
||||
* specified pixmap (if not null). If the pixels are not available (either because there are
|
||||
* none, or becuase accessing them would require locking or other machinary) return false and
|
||||
* ignore the pixmap parameter.
|
||||
*
|
||||
* Note: if this returns true, the results (in the pixmap) are only valid until the bitmap
|
||||
* is changed in anyway, in which case the results are invalid.
|
||||
*/
|
||||
bool peekPixels(SkPixmap*) const;
|
||||
|
||||
SkDEBUGCODE(void validate() const;)
|
||||
|
||||
class Allocator : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(Allocator)
|
||||
|
||||
/** Allocate the pixel memory for the bitmap, given its dimensions and
|
||||
colortype. Return true on success, where success means either setPixels
|
||||
or setPixelRef was called. The pixels need not be locked when this
|
||||
@@ -689,7 +696,7 @@ public:
|
||||
*/
|
||||
class HeapAllocator : public Allocator {
|
||||
public:
|
||||
virtual bool allocPixelRef(SkBitmap*, SkColorTable*) SK_OVERRIDE;
|
||||
bool allocPixelRef(SkBitmap*, SkColorTable*) override;
|
||||
};
|
||||
|
||||
class RLEPixels {
|
||||
@@ -736,24 +743,17 @@ private:
|
||||
};
|
||||
|
||||
SkImageInfo fInfo;
|
||||
|
||||
uint32_t fRowBytes;
|
||||
|
||||
uint8_t fFlags;
|
||||
|
||||
void internalErase(const SkIRect&, U8CPU a, U8CPU r, U8CPU g, U8CPU b)const;
|
||||
|
||||
/* Unreference any pixelrefs or colortables
|
||||
*/
|
||||
void freePixels();
|
||||
void updatePixelsFromRef() const;
|
||||
|
||||
void legacyUnflatten(SkReadBuffer&);
|
||||
|
||||
static void WriteRawPixels(SkWriteBuffer*, const SkBitmap&);
|
||||
static bool ReadRawPixels(SkReadBuffer*, SkBitmap*);
|
||||
|
||||
friend class SkBitmapSource; // unflatten
|
||||
friend class SkReadBuffer; // unflatten, rawpixels
|
||||
friend class SkWriteBuffer; // rawpixels
|
||||
friend struct SkBitmapProcState;
|
||||
@@ -780,60 +780,6 @@ private:
|
||||
//TODO(mtklein): uncomment when 71713004 lands and Chromium's fixed.
|
||||
//#define SkAutoLockPixels(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockPixels)
|
||||
|
||||
/** Helper class that performs the lock/unlockColors calls on a colortable.
|
||||
The destructor will call unlockColors(false) if it has a bitmap's colortable
|
||||
*/
|
||||
class SkAutoLockColors : SkNoncopyable {
|
||||
public:
|
||||
/** Initialize with no bitmap. Call lockColors(bitmap) to lock bitmap's
|
||||
colortable
|
||||
*/
|
||||
SkAutoLockColors() : fCTable(NULL), fColors(NULL) {}
|
||||
/** Initialize with bitmap, locking its colortable if present
|
||||
*/
|
||||
explicit SkAutoLockColors(const SkBitmap& bm) {
|
||||
fCTable = bm.getColorTable();
|
||||
fColors = fCTable ? fCTable->lockColors() : NULL;
|
||||
}
|
||||
/** Initialize with a colortable (may be null)
|
||||
*/
|
||||
explicit SkAutoLockColors(SkColorTable* ctable) {
|
||||
fCTable = ctable;
|
||||
fColors = ctable ? ctable->lockColors() : NULL;
|
||||
}
|
||||
~SkAutoLockColors() {
|
||||
if (fCTable) {
|
||||
fCTable->unlockColors();
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the currently locked colors, or NULL if no bitmap's colortable
|
||||
is currently locked.
|
||||
*/
|
||||
const SkPMColor* colors() const { return fColors; }
|
||||
|
||||
/** Locks the table and returns is colors (assuming ctable is not null) and
|
||||
unlocks the previous table if one was present
|
||||
*/
|
||||
const SkPMColor* lockColors(SkColorTable* ctable) {
|
||||
if (fCTable) {
|
||||
fCTable->unlockColors();
|
||||
}
|
||||
fCTable = ctable;
|
||||
fColors = ctable ? ctable->lockColors() : NULL;
|
||||
return fColors;
|
||||
}
|
||||
|
||||
const SkPMColor* lockColors(const SkBitmap& bm) {
|
||||
return this->lockColors(bm.getColorTable());
|
||||
}
|
||||
|
||||
private:
|
||||
SkColorTable* fCTable;
|
||||
const SkPMColor* fColors;
|
||||
};
|
||||
#define SkAutoLockColors(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockColors)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline uint32_t* SkBitmap::getAddr32(int x, int y) const {
|
||||
@@ -865,13 +811,4 @@ inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const {
|
||||
return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)];
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Helpers until we can fully deprecate SkBitmap::Config
|
||||
//
|
||||
SK_API SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType);
|
||||
SK_API SkColorType SkBitmapConfigToColorType(SkBitmap::Config);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,54 +9,74 @@
|
||||
#ifndef SkBitmapDevice_DEFINED
|
||||
#define SkBitmapDevice_DEFINED
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkDevice.h"
|
||||
#include "SkImageFilter.h"
|
||||
#include "SkImageInfo.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkScalar.h"
|
||||
#include "SkSize.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
class SkDraw;
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
class SkPath;
|
||||
class SkPixelRef;
|
||||
class SkPixmap;
|
||||
class SkRRect;
|
||||
class SkSurface;
|
||||
class SkXfermode;
|
||||
struct SkPoint;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class SK_API SkBitmapDevice : public SkBaseDevice {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkBitmapDevice)
|
||||
|
||||
/**
|
||||
* Construct a new device with the specified bitmap as its backend. It is
|
||||
* valid for the bitmap to have no pixels associated with it. In that case,
|
||||
* any drawing to this device will have no effect.
|
||||
*/
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap);
|
||||
|
||||
/**
|
||||
* Create a new device along with its requisite pixel memory using
|
||||
* default SkSurfaceProps (i.e., kLegacyFontHost_InitType-style).
|
||||
* Note: this entry point is slated for removal - no one should call it.
|
||||
*/
|
||||
static SkBitmapDevice* Create(const SkImageInfo& info);
|
||||
|
||||
/**
|
||||
* Construct a new device with the specified bitmap as its backend. It is
|
||||
* valid for the bitmap to have no pixels associated with it. In that case,
|
||||
* any drawing to this device will have no effect.
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties);
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps);
|
||||
|
||||
static SkBitmapDevice* Create(const SkImageInfo&,
|
||||
const SkDeviceProperties* = NULL);
|
||||
static SkBitmapDevice* Create(const SkImageInfo&, const SkSurfaceProps&);
|
||||
|
||||
virtual SkImageInfo imageInfo() const SK_OVERRIDE;
|
||||
SkImageInfo imageInfo() const override;
|
||||
|
||||
protected:
|
||||
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE;
|
||||
|
||||
/** Clears the entire device to the specified color (including alpha).
|
||||
* Ignores the clip.
|
||||
*/
|
||||
virtual void clear(SkColor color) SK_OVERRIDE;
|
||||
bool onShouldDisableLCD(const SkPaint&) const override;
|
||||
|
||||
/** These are called inside the per-device-layer loop for each draw call.
|
||||
When these are called, we have already applied any saveLayer operations,
|
||||
and are handling any looping from the paint, and any effects from the
|
||||
DrawFilter.
|
||||
*/
|
||||
virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE;
|
||||
void drawPaint(const SkDraw&, const SkPaint& paint) override;
|
||||
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
|
||||
const SkPoint[], const SkPaint& paint) SK_OVERRIDE;
|
||||
const SkPoint[], const SkPaint& paint) override;
|
||||
virtual void drawRect(const SkDraw&, const SkRect& r,
|
||||
const SkPaint& paint) SK_OVERRIDE;
|
||||
const SkPaint& paint) override;
|
||||
virtual void drawOval(const SkDraw&, const SkRect& oval,
|
||||
const SkPaint& paint) SK_OVERRIDE;
|
||||
const SkPaint& paint) override;
|
||||
virtual void drawRRect(const SkDraw&, const SkRRect& rr,
|
||||
const SkPaint& paint) SK_OVERRIDE;
|
||||
const SkPaint& paint) override;
|
||||
|
||||
/**
|
||||
* If pathIsMutable, then the implementation is allowed to cast path to a
|
||||
@@ -72,43 +92,34 @@ protected:
|
||||
virtual void drawPath(const SkDraw&, const SkPath& path,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix* prePathMatrix = NULL,
|
||||
bool pathIsMutable = false) SK_OVERRIDE;
|
||||
bool pathIsMutable = false) override;
|
||||
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
|
||||
const SkMatrix& matrix, const SkPaint& paint) SK_OVERRIDE;
|
||||
const SkMatrix& matrix, const SkPaint& paint) override;
|
||||
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
|
||||
int x, int y, const SkPaint& paint) SK_OVERRIDE;
|
||||
int x, int y, const SkPaint& paint) override;
|
||||
|
||||
/**
|
||||
* The default impl. will create a bitmap-shader from the bitmap,
|
||||
* and call drawRect with it.
|
||||
*/
|
||||
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
|
||||
const SkRect* srcOrNull, const SkRect& dst,
|
||||
const SkPaint& paint,
|
||||
SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE;
|
||||
void drawBitmapRect(const SkDraw&, const SkBitmap&, const SkRect*, const SkRect&,
|
||||
const SkPaint&, SkCanvas::SrcRectConstraint) override;
|
||||
|
||||
/**
|
||||
* Does not handle text decoration.
|
||||
* Decorations (underline and stike-thru) will be handled by SkCanvas.
|
||||
*/
|
||||
virtual void drawText(const SkDraw&, const void* text, size_t len,
|
||||
SkScalar x, SkScalar y, const SkPaint& paint) SK_OVERRIDE;
|
||||
SkScalar x, SkScalar y, const SkPaint& paint) override;
|
||||
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
|
||||
const SkScalar pos[], SkScalar constY,
|
||||
int scalarsPerPos, const SkPaint& paint) SK_OVERRIDE;
|
||||
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint) SK_OVERRIDE;
|
||||
const SkScalar pos[], int scalarsPerPos,
|
||||
const SkPoint& offset, const SkPaint& paint) override;
|
||||
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
|
||||
const SkPoint verts[], const SkPoint texs[],
|
||||
const SkColor colors[], SkXfermode* xmode,
|
||||
const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint) SK_OVERRIDE;
|
||||
/** The SkBaseDevice passed will be an SkBaseDevice which was returned by a call to
|
||||
onCreateDevice on this device with kSaveLayer_Usage.
|
||||
*/
|
||||
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
|
||||
const SkPaint&) SK_OVERRIDE;
|
||||
const SkPaint& paint) override;
|
||||
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, const SkPaint&) override;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -117,7 +128,7 @@ protected:
|
||||
altered. The config/width/height/rowbytes must remain unchanged.
|
||||
@return the device contents as a bitmap
|
||||
*/
|
||||
virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE;
|
||||
const SkBitmap& onAccessBitmap() override;
|
||||
|
||||
SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
|
||||
// just for subclasses, to assign a custom pixelref
|
||||
@@ -126,15 +137,12 @@ protected:
|
||||
return pr;
|
||||
}
|
||||
|
||||
virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) SK_OVERRIDE;
|
||||
virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVERRIDE;
|
||||
virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes) SK_OVERRIDE;
|
||||
|
||||
/** Called when this device is installed into a Canvas. Balanced by a call
|
||||
to unlockPixels() when the device is removed from a Canvas.
|
||||
*/
|
||||
virtual void lockPixels() SK_OVERRIDE;
|
||||
virtual void unlockPixels() SK_OVERRIDE;
|
||||
bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) override;
|
||||
bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) override;
|
||||
bool onPeekPixels(SkPixmap*) override;
|
||||
bool onAccessPixels(SkPixmap*) override;
|
||||
void onAttachToCanvas(SkCanvas*) override;
|
||||
void onDetachFromCanvas() override;
|
||||
|
||||
private:
|
||||
friend class SkCanvas;
|
||||
@@ -142,22 +150,24 @@ private:
|
||||
friend class SkDraw;
|
||||
friend class SkDrawIter;
|
||||
friend class SkDeviceFilteredPaint;
|
||||
friend class SkDeviceImageFilterProxy;
|
||||
|
||||
friend class SkSurface_Raster;
|
||||
|
||||
// used to change the backend's pixels (and possibly config/rowbytes)
|
||||
// but cannot change the width/height, so there should be no change to
|
||||
// any clip information.
|
||||
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE;
|
||||
void replaceBitmapBackendForRasterSurface(const SkBitmap&) override;
|
||||
|
||||
virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
|
||||
SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
|
||||
|
||||
virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes) SK_OVERRIDE;
|
||||
SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override;
|
||||
|
||||
SkImageFilter::Cache* getImageFilterCache() override;
|
||||
|
||||
SkBitmap fBitmap;
|
||||
|
||||
void setNewSize(const SkISize&); // Used by SkCanvas for resetForNextPicture().
|
||||
|
||||
typedef SkBaseDevice INHERITED;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,17 +26,26 @@ public:
|
||||
a corresponding scanline of 16bit colors (specific format based on the
|
||||
config passed to the Factory.
|
||||
|
||||
The x,y params are useful just for dithering
|
||||
The x,y params provide the dithering phase for the start of the scanline
|
||||
|
||||
@param alpha A global alpha to be applied to all of the src colors
|
||||
@param x The x coordinate of the beginning of the scanline
|
||||
@param y THe y coordinate of the scanline
|
||||
*/
|
||||
typedef void (*Proc)(uint16_t* dst,
|
||||
const SkPMColor* src,
|
||||
int count, U8CPU alpha, int x, int y);
|
||||
typedef void (*Proc16)(uint16_t dst[], const SkPMColor src[], int count,
|
||||
U8CPU alpha, int x, int y);
|
||||
|
||||
static Proc Factory(unsigned flags, SkColorType);
|
||||
static Proc16 Factory16(unsigned flags);
|
||||
|
||||
/**
|
||||
* Function pointer that blends a single src color onto a scaline of dst colors.
|
||||
*
|
||||
* The x,y params provide the dithering phase for the start of the scanline
|
||||
*/
|
||||
typedef void (*ColorProc16)(uint16_t dst[], SkPMColor src, int count, int x, int y);
|
||||
|
||||
// Note : we ignore the kGlobalAlpha_Flag setting, but do respect kSrcPixelAlpha_Flag
|
||||
static ColorProc16 ColorFactory16(unsigned flags);
|
||||
|
||||
///////////// D32 version
|
||||
|
||||
@@ -51,38 +60,15 @@ public:
|
||||
@param count number of colors to blend
|
||||
@param alpha global alpha to be applied to all src colors
|
||||
*/
|
||||
typedef void (*Proc32)(uint32_t* dst,
|
||||
const SkPMColor* src,
|
||||
int count, U8CPU alpha);
|
||||
typedef void (*Proc32)(uint32_t dst[], const SkPMColor src[], int count, U8CPU alpha);
|
||||
|
||||
static Proc32 Factory32(unsigned flags32);
|
||||
|
||||
/** Function pointer that blends a single color with a row of 32-bit colors
|
||||
onto a 32-bit destination
|
||||
*/
|
||||
typedef void (*ColorProc)(SkPMColor* dst, const SkPMColor* src, int count,
|
||||
SkPMColor color);
|
||||
|
||||
/** Blend a single color onto a row of S32 pixels, writing the result
|
||||
into a row of D32 pixels. src and dst may be the same memory, but
|
||||
if they are not, they may not overlap.
|
||||
*/
|
||||
static void Color32(SkPMColor dst[], const SkPMColor src[],
|
||||
int count, SkPMColor color);
|
||||
|
||||
//! Public entry-point to return a blit function ptr
|
||||
static ColorProc ColorProcFactory();
|
||||
|
||||
/** Function pointer that blends a single color onto a 32-bit rectangle. */
|
||||
typedef void (*ColorRectProc)(SkPMColor* dst, int width, int height,
|
||||
size_t rowBytes, SkPMColor color);
|
||||
|
||||
/** Blend a single color into a rectangle of D32 pixels. */
|
||||
static void ColorRect32(SkPMColor* dst, int width, int height,
|
||||
size_t rowBytes, SkPMColor color);
|
||||
|
||||
//! Public entry-point to return a blit function ptr
|
||||
static ColorRectProc ColorRectProcFactory();
|
||||
static void Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMColor color);
|
||||
|
||||
/** These static functions are called by the Factory and Factory32
|
||||
functions, and should return either NULL, or a
|
||||
@@ -91,8 +77,9 @@ public:
|
||||
*/
|
||||
|
||||
static Proc32 PlatformProcs32(unsigned flags);
|
||||
static Proc PlatformProcs565(unsigned flags);
|
||||
static ColorProc PlatformColorProc();
|
||||
|
||||
static Proc16 PlatformFactory565(unsigned flags);
|
||||
static ColorProc16 PlatformColorFactory565(unsigned flags);
|
||||
|
||||
private:
|
||||
enum {
|
||||
|
||||
@@ -11,30 +11,31 @@
|
||||
#include "SkTypes.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkDeque.h"
|
||||
#include "SkClipStack.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL
|
||||
#define SK_LEGACY_DRAWTEXT_VIRTUAL virtual
|
||||
#else
|
||||
#define SK_LEGACY_DRAWTEXT_VIRTUAL
|
||||
#endif
|
||||
|
||||
class SkCanvasClipVisitor;
|
||||
class SkBaseDevice;
|
||||
class SkDraw;
|
||||
class SkDrawFilter;
|
||||
class SkMetaData;
|
||||
class SkPicture;
|
||||
class SkRRect;
|
||||
class SkSurface;
|
||||
class SkSurface_Base;
|
||||
class GrContext;
|
||||
class GrRenderTarget;
|
||||
class SkBaseDevice;
|
||||
class SkCanvasClipVisitor;
|
||||
class SkClipStack;
|
||||
class SkDraw;
|
||||
class SkDrawable;
|
||||
class SkDrawFilter;
|
||||
class SkImage;
|
||||
class SkImageFilter;
|
||||
class SkMetaData;
|
||||
class SkPath;
|
||||
class SkPicture;
|
||||
class SkPixmap;
|
||||
class SkRRect;
|
||||
struct SkRSXform;
|
||||
class SkSurface;
|
||||
class SkSurface_Base;
|
||||
class SkTextBlob;
|
||||
|
||||
/** \class SkCanvas
|
||||
|
||||
@@ -53,37 +54,6 @@ class GrRenderTarget;
|
||||
*/
|
||||
class SK_API SkCanvas : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkCanvas)
|
||||
|
||||
/**
|
||||
* Attempt to allocate an offscreen raster canvas, matching the ImageInfo.
|
||||
* On success, return a new canvas that will draw into that offscreen.
|
||||
*
|
||||
* The caller can access the pixels after drawing into this canvas by
|
||||
* calling readPixels() or peekPixels().
|
||||
*
|
||||
* If the requested ImageInfo is opaque (either the colortype is
|
||||
* intrinsically opaque like RGB_565, or the info's alphatype is kOpaque)
|
||||
* then the pixel memory may be uninitialized. Otherwise, the pixel memory
|
||||
* will be initialized to 0, which is interpreted as transparent.
|
||||
*
|
||||
* On failure, return NULL. This can fail for several reasons:
|
||||
* 1. the memory allocation failed (e.g. request is too large)
|
||||
* 2. invalid ImageInfo (e.g. negative dimensions)
|
||||
* 3. unsupported ImageInfo for a canvas
|
||||
* - kUnknown_SkColorType, kIndex_8_SkColorType
|
||||
* - kIgnore_SkAlphaType
|
||||
* - this list is not complete, so others may also be unsupported
|
||||
*
|
||||
* Note: it is valid to request a supported ImageInfo, but with zero
|
||||
* dimensions.
|
||||
*/
|
||||
static SkCanvas* NewRaster(const SkImageInfo&);
|
||||
|
||||
static SkCanvas* NewRasterN32(int width, int height) {
|
||||
return NewRaster(SkImageInfo::MakeN32Premul(width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to allocate raster canvas, matching the ImageInfo, that will draw directly into the
|
||||
* specified pixels. To access the pixels after drawing to them, the caller should call
|
||||
@@ -93,7 +63,7 @@ public:
|
||||
* 1. invalid ImageInfo (e.g. negative dimensions)
|
||||
* 2. unsupported ImageInfo for a canvas
|
||||
* - kUnknown_SkColorType, kIndex_8_SkColorType
|
||||
* - kIgnore_SkAlphaType
|
||||
* - kUnknown_SkAlphaType
|
||||
* - this list is not complete, so others may also be unsupported
|
||||
*
|
||||
* Note: it is valid to request a supported ImageInfo, but with zero
|
||||
@@ -116,7 +86,7 @@ public:
|
||||
* by any device/pixels. Typically this use used by subclasses who handle
|
||||
* the draw calls in some other way.
|
||||
*/
|
||||
SkCanvas(int width, int height);
|
||||
SkCanvas(int width, int height, const SkSurfaceProps* = NULL);
|
||||
|
||||
/** Construct a canvas with the specified device to draw into.
|
||||
|
||||
@@ -129,6 +99,14 @@ public:
|
||||
structure are copied to the canvas.
|
||||
*/
|
||||
explicit SkCanvas(const SkBitmap& bitmap);
|
||||
|
||||
/** Construct a canvas with the specified bitmap to draw into.
|
||||
@param bitmap Specifies a bitmap for the canvas to draw into. Its
|
||||
structure are copied to the canvas.
|
||||
@param props New canvas surface properties.
|
||||
*/
|
||||
SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);
|
||||
|
||||
virtual ~SkCanvas();
|
||||
|
||||
SkMetaData& getMetaData();
|
||||
@@ -151,7 +129,7 @@ public:
|
||||
* origin of the base layer is always (0,0). The current drawable area may be
|
||||
* smaller (due to clipping or saveLayer).
|
||||
*/
|
||||
SkISize getBaseLayerSize() const;
|
||||
virtual SkISize getBaseLayerSize() const;
|
||||
|
||||
/**
|
||||
* DEPRECATED: call getBaseLayerSize
|
||||
@@ -169,6 +147,9 @@ protected: // Can we make this private?
|
||||
#endif
|
||||
SkBaseDevice* getDevice() const;
|
||||
public:
|
||||
SkBaseDevice* getDevice_just_for_deprecated_compatibility_testing() const {
|
||||
return this->getDevice();
|
||||
}
|
||||
|
||||
/**
|
||||
* saveLayer() can create another device (which is later drawn onto
|
||||
@@ -193,8 +174,12 @@ public:
|
||||
* Create a new surface matching the specified info, one that attempts to
|
||||
* be maximally compatible when used with this canvas. If there is no matching Surface type,
|
||||
* NULL is returned.
|
||||
*
|
||||
* If surfaceprops is specified, those are passed to the new surface, otherwise the new surface
|
||||
* inherits the properties of the surface that owns this canvas. If this canvas has no parent
|
||||
* surface, then the new surface is created with default properties.
|
||||
*/
|
||||
SkSurface* newSurface(const SkImageInfo&);
|
||||
SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL);
|
||||
|
||||
/**
|
||||
* Return the GPU context of the device that is associated with the canvas.
|
||||
@@ -347,6 +332,9 @@ public:
|
||||
@return The value to pass to restoreToCount() to balance this save()
|
||||
*/
|
||||
int saveLayer(const SkRect* bounds, const SkPaint* paint);
|
||||
int saveLayer(const SkRect& bounds, const SkPaint* paint) {
|
||||
return this->saveLayer(&bounds, paint);
|
||||
}
|
||||
|
||||
/** DEPRECATED - use saveLayer(const SkRect*, const SkPaint*) instead.
|
||||
|
||||
@@ -417,11 +405,6 @@ public:
|
||||
*/
|
||||
void restoreToCount(int saveCount);
|
||||
|
||||
/** Returns true if drawing is currently going to a layer (from saveLayer)
|
||||
* rather than to the root device.
|
||||
*/
|
||||
virtual bool isDrawingToLayer() const;
|
||||
|
||||
/** Preconcat the current matrix with the specified translation
|
||||
@param dx The distance to translate in X
|
||||
@param dy The distance to translate in Y
|
||||
@@ -609,24 +592,15 @@ public:
|
||||
@param color the color to draw with
|
||||
@param mode the mode to apply the color in (defaults to SrcOver)
|
||||
*/
|
||||
void drawColor(SkColor color,
|
||||
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
|
||||
void drawColor(SkColor color, SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
|
||||
|
||||
/**
|
||||
* This erases the entire drawing surface to the specified color,
|
||||
* irrespective of the clip. It does not blend with the previous pixels,
|
||||
* but always overwrites them.
|
||||
*
|
||||
* It is roughly equivalent to the following:
|
||||
* canvas.save();
|
||||
* canvas.clipRect(hugeRect, kReplace_Op);
|
||||
* paint.setColor(color);
|
||||
* paint.setXfermodeMode(kSrc_Mode);
|
||||
* canvas.drawPaint(paint);
|
||||
* canvas.restore();
|
||||
* though it is almost always much more efficient.
|
||||
* Helper method for drawing a color in SRC mode, completely replacing all the pixels
|
||||
* in the current clip with this color.
|
||||
*/
|
||||
virtual void clear(SkColor);
|
||||
void clear(SkColor color) {
|
||||
this->drawColor(color, SkXfermode::kSrc_Mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* This makes the contents of the canvas undefined. Subsequent calls that
|
||||
@@ -647,7 +621,7 @@ public:
|
||||
* specified paint.
|
||||
* @param paint The paint used to fill the canvas
|
||||
*/
|
||||
virtual void drawPaint(const SkPaint& paint);
|
||||
void drawPaint(const SkPaint& paint);
|
||||
|
||||
enum PointMode {
|
||||
/** drawPoints draws each point separately */
|
||||
@@ -679,8 +653,7 @@ public:
|
||||
@param pts Array of points to draw
|
||||
@param paint The paint used to draw the points
|
||||
*/
|
||||
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
|
||||
const SkPaint& paint);
|
||||
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint);
|
||||
|
||||
/** Helper method for drawing a single point. See drawPoints() for a more
|
||||
details.
|
||||
@@ -711,7 +684,7 @@ public:
|
||||
@param rect The rect to be drawn
|
||||
@param paint The paint used to draw the rect
|
||||
*/
|
||||
virtual void drawRect(const SkRect& rect, const SkPaint& paint);
|
||||
void drawRect(const SkRect& rect, const SkPaint& paint);
|
||||
|
||||
/** Draw the specified rectangle using the specified paint. The rectangle
|
||||
will be filled or framed based on the Style in the paint.
|
||||
@@ -740,7 +713,7 @@ public:
|
||||
@param oval The rectangle bounds of the oval to be drawn
|
||||
@param paint The paint used to draw the oval
|
||||
*/
|
||||
virtual void drawOval(const SkRect& oval, const SkPaint&);
|
||||
void drawOval(const SkRect& oval, const SkPaint&);
|
||||
|
||||
/**
|
||||
* Draw the specified RRect using the specified paint The rrect will be filled or stroked
|
||||
@@ -749,7 +722,7 @@ public:
|
||||
* @param rrect The round-rect to draw
|
||||
* @param paint The paint used to draw the round-rect
|
||||
*/
|
||||
virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint);
|
||||
void drawRRect(const SkRRect& rrect, const SkPaint& paint);
|
||||
|
||||
/**
|
||||
* Draw the annulus formed by the outer and inner rrects. The results
|
||||
@@ -797,7 +770,84 @@ public:
|
||||
@param path The path to be drawn
|
||||
@param paint The paint used to draw the path
|
||||
*/
|
||||
virtual void drawPath(const SkPath& path, const SkPaint& paint);
|
||||
void drawPath(const SkPath& path, const SkPaint& paint);
|
||||
|
||||
/** Draw the specified image, with its top/left corner at (x,y), using the
|
||||
specified paint, transformed by the current matrix.
|
||||
|
||||
@param image The image to be drawn
|
||||
@param left The position of the left side of the image being drawn
|
||||
@param top The position of the top side of the image being drawn
|
||||
@param paint The paint used to draw the image, or NULL
|
||||
*/
|
||||
void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint = NULL);
|
||||
|
||||
/**
|
||||
* Controls the behavior at the edge of the src-rect, when specified in drawImageRect,
|
||||
* trading off speed for exactness.
|
||||
*
|
||||
* When filtering is enabled (in the Paint), skia may need to sample in a neighborhood around
|
||||
* the pixels in the image. If there is a src-rect specified, it is intended to restrict the
|
||||
* pixels that will be read. However, for performance reasons, some implementations may slow
|
||||
* down if they cannot read 1-pixel past the src-rect boundary at times.
|
||||
*
|
||||
* This enum allows the caller to specify if such a 1-pixel "slop" will be visually acceptable.
|
||||
* If it is, the caller should pass kFast, and it may result in a faster draw. If the src-rect
|
||||
* must be strictly respected, the caller should pass kStrict.
|
||||
*/
|
||||
enum SrcRectConstraint {
|
||||
/**
|
||||
* If kStrict is specified, the implementation must respect the src-rect
|
||||
* (if specified) strictly, and will never sample outside of those bounds during sampling
|
||||
* even when filtering. This may be slower than kFast.
|
||||
*/
|
||||
kStrict_SrcRectConstraint,
|
||||
|
||||
/**
|
||||
* If kFast is specified, the implementation may sample outside of the src-rect
|
||||
* (if specified) by half the width of filter. This allows greater flexibility
|
||||
* to the implementation and can make the draw much faster.
|
||||
*/
|
||||
kFast_SrcRectConstraint,
|
||||
};
|
||||
|
||||
/** Draw the specified image, scaling and translating so that it fills the specified
|
||||
* dst rect. If the src rect is non-null, only that subset of the image is transformed
|
||||
* and drawn.
|
||||
*
|
||||
* @param image The image to be drawn
|
||||
* @param src Optional: specify the subset of the image to be drawn
|
||||
* @param dst The destination rectangle where the scaled/translated
|
||||
* image will be drawn
|
||||
* @param paint The paint used to draw the image, or NULL
|
||||
* @param constraint Control the tradeoff between speed and exactness w.r.t. the src-rect.
|
||||
*/
|
||||
void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
|
||||
const SkPaint* paint,
|
||||
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
||||
// variant that takes src SkIRect
|
||||
void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
|
||||
// variant that assumes src == image-bounds
|
||||
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
|
||||
SrcRectConstraint = kStrict_SrcRectConstraint);
|
||||
|
||||
/**
|
||||
* Draw the image stretched differentially to fit into dst.
|
||||
* center is a rect within the image, and logically divides the image
|
||||
* into 9 sections (3x3). For example, if the middle pixel of a [5x5]
|
||||
* image is the "center", then the center-rect should be [2, 2, 3, 3].
|
||||
*
|
||||
* If the dst is >= the image size, then...
|
||||
* - The 4 corners are not stretched at all.
|
||||
* - The sides are stretched in only one axis.
|
||||
* - The center is stretched in both axes.
|
||||
* Else, for each axis where dst < image,
|
||||
* - The corners shrink proportionally
|
||||
* - The sides (along the shrink axis) and center are not drawn
|
||||
*/
|
||||
void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
|
||||
const SkPaint* paint = NULL);
|
||||
|
||||
/** Draw the specified bitmap, with its top/left corner at (x,y), using the
|
||||
specified paint, transformed by the current matrix. Note: if the paint
|
||||
@@ -815,51 +865,27 @@ public:
|
||||
@param top The position of the top side of the bitmap being drawn
|
||||
@param paint The paint used to draw the bitmap, or NULL
|
||||
*/
|
||||
virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint = NULL);
|
||||
void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint = NULL);
|
||||
|
||||
enum DrawBitmapRectFlags {
|
||||
kNone_DrawBitmapRectFlag = 0x0,
|
||||
/**
|
||||
* When filtering is enabled, allow the color samples outside of
|
||||
* the src rect (but still in the src bitmap) to bleed into the
|
||||
* drawn portion
|
||||
*/
|
||||
kBleed_DrawBitmapRectFlag = 0x1,
|
||||
};
|
||||
|
||||
/** Draw the specified bitmap, with the specified matrix applied (before the
|
||||
canvas' matrix is applied).
|
||||
@param bitmap The bitmap to be drawn
|
||||
@param src Optional: specify the subset of the bitmap to be drawn
|
||||
@param dst The destination rectangle where the scaled/translated
|
||||
image will be drawn
|
||||
@param paint The paint used to draw the bitmap, or NULL
|
||||
*/
|
||||
virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
|
||||
const SkRect& dst,
|
||||
const SkPaint* paint = NULL,
|
||||
DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag);
|
||||
|
||||
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst,
|
||||
const SkPaint* paint = NULL) {
|
||||
this->drawBitmapRectToRect(bitmap, NULL, dst, paint, kNone_DrawBitmapRectFlag);
|
||||
}
|
||||
|
||||
void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
|
||||
const SkRect& dst, const SkPaint* paint = NULL,
|
||||
DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) {
|
||||
SkRect realSrcStorage;
|
||||
SkRect* realSrcPtr = NULL;
|
||||
if (isrc) {
|
||||
realSrcStorage.set(*isrc);
|
||||
realSrcPtr = &realSrcStorage;
|
||||
}
|
||||
this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags);
|
||||
}
|
||||
|
||||
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
|
||||
const SkPaint* paint = NULL);
|
||||
/** Draw the specified bitmap, scaling and translating so that it fills the specified
|
||||
* dst rect. If the src rect is non-null, only that subset of the bitmap is transformed
|
||||
* and drawn.
|
||||
*
|
||||
* @param bitmap The bitmap to be drawn
|
||||
* @param src Optional: specify the subset of the bitmap to be drawn
|
||||
* @param dst The destination rectangle where the scaled/translated
|
||||
* bitmap will be drawn
|
||||
* @param paint The paint used to draw the bitmap, or NULL
|
||||
* @param constraint Control the tradeoff between speed and exactness w.r.t. the src-rect.
|
||||
*/
|
||||
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
|
||||
// variant where src is SkIRect
|
||||
void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
|
||||
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
|
||||
SrcRectConstraint = kStrict_SrcRectConstraint);
|
||||
|
||||
/**
|
||||
* Draw the bitmap stretched differentially to fit into dst.
|
||||
@@ -875,8 +901,8 @@ public:
|
||||
* - The corners shrink proportionally
|
||||
* - The sides (along the shrink axis) and center are not drawn
|
||||
*/
|
||||
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint* paint = NULL);
|
||||
void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
|
||||
const SkPaint* paint = NULL);
|
||||
|
||||
/** Draw the specified bitmap, with its top/left corner at (x,y),
|
||||
NOT transformed by the current matrix. Note: if the paint
|
||||
@@ -889,8 +915,7 @@ public:
|
||||
@param top The position of the top side of the bitmap being drawn
|
||||
@param paint The paint used to draw the bitmap, or NULL
|
||||
*/
|
||||
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
|
||||
const SkPaint* paint = NULL);
|
||||
void drawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint = NULL);
|
||||
|
||||
/** Draw the text, with origin at (x,y), using the specified paint.
|
||||
The origin is interpreted based on the Align setting in the paint.
|
||||
@@ -900,8 +925,8 @@ public:
|
||||
@param y The y-coordinate of the origin of the text being drawn
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
SK_LEGACY_DRAWTEXT_VIRTUAL void drawText(const void* text, size_t byteLength, SkScalar x,
|
||||
SkScalar y, const SkPaint& paint);
|
||||
void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with each character/glyph origin specified by the pos[]
|
||||
array. The origin is interpreted by the Align setting in the paint.
|
||||
@@ -910,8 +935,8 @@ public:
|
||||
@param pos Array of positions, used to position each character
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
SK_LEGACY_DRAWTEXT_VIRTUAL void drawPosText(const void* text, size_t byteLength,
|
||||
const SkPoint pos[], const SkPaint& paint);
|
||||
void drawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with each character/glyph origin specified by the x
|
||||
coordinate taken from the xpos[] array, and the y from the constY param.
|
||||
@@ -922,9 +947,8 @@ public:
|
||||
@param constY The shared Y coordinate for all of the positions
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
SK_LEGACY_DRAWTEXT_VIRTUAL void drawPosTextH(const void* text, size_t byteLength,
|
||||
const SkScalar xpos[], SkScalar constY,
|
||||
const SkPaint& paint);
|
||||
void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with origin at (x,y), using the specified paint, along
|
||||
the specified path. The paint's Align setting determins where along the
|
||||
@@ -938,8 +962,7 @@ public:
|
||||
position the text
|
||||
@param paint The paint used for the text
|
||||
*/
|
||||
void drawTextOnPathHV(const void* text, size_t byteLength,
|
||||
const SkPath& path, SkScalar hOffset,
|
||||
void drawTextOnPathHV(const void* text, size_t byteLength, const SkPath& path, SkScalar hOffset,
|
||||
SkScalar vOffset, const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with origin at (x,y), using the specified paint, along
|
||||
@@ -952,17 +975,16 @@ public:
|
||||
mapped onto the path
|
||||
@param paint The paint used for the text
|
||||
*/
|
||||
SK_LEGACY_DRAWTEXT_VIRTUAL void drawTextOnPath(const void* text, size_t byteLength,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint);
|
||||
void drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint);
|
||||
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call
|
||||
Perform back-end analysis/optimization of a picture. This may attach
|
||||
optimization data to the picture which can be used by a later
|
||||
drawPicture call.
|
||||
@param picture The recorded drawing commands to analyze/optimize
|
||||
/** Draw the text blob, offset by (x,y), using the specified paint.
|
||||
@param blob The text blob to be drawn
|
||||
@param x The x-offset of the text being drawn
|
||||
@param y The y-offset of the text being drawn
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
void EXPERIMENTAL_optimize(const SkPicture* picture);
|
||||
void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
|
||||
|
||||
/** Draw the picture into this canvas. This method effective brackets the
|
||||
playback of the picture's draw calls with save/restore, so the state
|
||||
@@ -970,7 +992,23 @@ public:
|
||||
@param picture The recorded drawing commands to playback into this
|
||||
canvas.
|
||||
*/
|
||||
void drawPicture(const SkPicture* picture);
|
||||
void drawPicture(const SkPicture* picture) {
|
||||
this->drawPicture(picture, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the picture into this canvas.
|
||||
*
|
||||
* If matrix is non-null, apply that matrix to the CTM when drawing this picture. This is
|
||||
* logically equivalent to
|
||||
* save/concat/drawPicture/restore
|
||||
*
|
||||
* If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's
|
||||
* alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas.
|
||||
* This is logically equivalent to
|
||||
* saveLayer(paint)/drawPicture/restore
|
||||
*/
|
||||
void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* paint);
|
||||
|
||||
enum VertexMode {
|
||||
kTriangles_VertexMode,
|
||||
@@ -1001,48 +1039,64 @@ public:
|
||||
@param indexCount number of entries in the indices array (if not null)
|
||||
@param paint Specifies the shader/texture if present.
|
||||
*/
|
||||
virtual void drawVertices(VertexMode vmode, int vertexCount,
|
||||
const SkPoint vertices[], const SkPoint texs[],
|
||||
const SkColor colors[], SkXfermode* xmode,
|
||||
const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint);
|
||||
void drawVertices(VertexMode vmode, int vertexCount,
|
||||
const SkPoint vertices[], const SkPoint texs[],
|
||||
const SkColor colors[], SkXfermode* xmode,
|
||||
const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Send a blob of data to the canvas.
|
||||
For canvases that draw, this call is effectively a no-op, as the data
|
||||
is not parsed, but just ignored. However, this call exists for
|
||||
subclasses like SkPicture's recording canvas, that can store the data
|
||||
and then play it back later (via another call to drawData).
|
||||
*/
|
||||
virtual void drawData(const void* data, size_t length) {
|
||||
// do nothing. Subclasses may do something with the data
|
||||
}
|
||||
/**
|
||||
Draw a cubic coons patch
|
||||
|
||||
/** Add comments. beginCommentGroup/endCommentGroup open/close a new group.
|
||||
Each comment added via addComment is notionally attached to its
|
||||
enclosing group. Top-level comments simply belong to no group.
|
||||
@param cubic specifies the 4 bounding cubic bezier curves of a patch with clockwise order
|
||||
starting at the top left corner.
|
||||
@param colors specifies the colors for the corners which will be bilerp across the patch,
|
||||
their order is clockwise starting at the top left corner.
|
||||
@param texCoords specifies the texture coordinates that will be bilerp across the patch,
|
||||
their order is the same as the colors.
|
||||
@param xmode specifies how are the colors and the textures combined if both of them are
|
||||
present.
|
||||
@param paint Specifies the shader/texture if present.
|
||||
*/
|
||||
virtual void beginCommentGroup(const char* description) {
|
||||
// do nothing. Subclasses may do something
|
||||
}
|
||||
virtual void addComment(const char* kywd, const char* value) {
|
||||
// do nothing. Subclasses may do something
|
||||
}
|
||||
virtual void endCommentGroup() {
|
||||
// do nothing. Subclasses may do something
|
||||
void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
|
||||
|
||||
/**
|
||||
* Draw a set of sprites from the atlas. Each is specified by a tex rectangle in the
|
||||
* coordinate space of the atlas, and a corresponding xform which transforms the tex rectangle
|
||||
* into a quad.
|
||||
*
|
||||
* xform maps [0, 0, tex.width, tex.height] -> quad
|
||||
*
|
||||
* The color array is optional. When specified, each color modulates the pixels in its
|
||||
* corresponding quad (via the specified SkXfermode::Mode).
|
||||
*
|
||||
* The cullRect is optional. When specified, it must be a conservative bounds of all of the
|
||||
* resulting transformed quads, allowing the canvas to skip drawing if the cullRect does not
|
||||
* intersect the current clip.
|
||||
*
|
||||
* The paint is optional. If specified, its antialiasing, alpha, color-filter, image-filter
|
||||
* and xfermode are used to affect each of the quads.
|
||||
*/
|
||||
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
|
||||
const SkColor colors[], int count, SkXfermode::Mode, const SkRect* cullRect,
|
||||
const SkPaint* paint);
|
||||
|
||||
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
|
||||
const SkRect* cullRect, const SkPaint* paint) {
|
||||
this->drawAtlas(atlas, xform, tex, NULL, count, SkXfermode::kDst_Mode, cullRect, paint);
|
||||
}
|
||||
|
||||
/**
|
||||
* With this call the client asserts that subsequent draw operations (up to the
|
||||
* matching popCull()) are fully contained within the given bounding box. The assertion
|
||||
* is not enforced, but the information might be used to quick-reject command blocks,
|
||||
* so an incorrect bounding box may result in incomplete rendering.
|
||||
* Draw the contents of this drawable into the canvas. If the canvas is async
|
||||
* (e.g. it is recording into a picture) then the drawable will be referenced instead,
|
||||
* to have its draw() method called when the picture is finalized.
|
||||
*
|
||||
* If the intent is to force the contents of the drawable into this canvas immediately,
|
||||
* then drawable->draw(canvas) may be called.
|
||||
*/
|
||||
void pushCull(const SkRect& cullRect);
|
||||
|
||||
/**
|
||||
* Terminates the current culling block, and restores the previous one (if any).
|
||||
*/
|
||||
void popCull();
|
||||
void drawDrawable(SkDrawable* drawable, const SkMatrix* = NULL);
|
||||
void drawDrawable(SkDrawable*, SkScalar x, SkScalar y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1085,25 +1139,13 @@ public:
|
||||
*/
|
||||
const SkMatrix& getTotalMatrix() const;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
|
||||
enum ClipType {
|
||||
kEmpty_ClipType = 0,
|
||||
kRect_ClipType,
|
||||
kComplex_ClipType
|
||||
};
|
||||
/** Returns a description of the total clip; may be cheaper than
|
||||
getting the clip and querying it directly.
|
||||
*/
|
||||
virtual ClipType getClipType() const;
|
||||
#endif
|
||||
|
||||
/** Return the clip stack. The clip stack stores all the individual
|
||||
* clips organized by the save/restore frame in which they were
|
||||
* added.
|
||||
* @return the current clip stack ("list" of individual clip elements)
|
||||
*/
|
||||
const SkClipStack* getClipStack() const {
|
||||
return &fClipStack;
|
||||
return fClipStack;
|
||||
}
|
||||
|
||||
typedef SkCanvasClipVisitor ClipVisitor;
|
||||
@@ -1154,20 +1196,30 @@ public:
|
||||
bool fDone;
|
||||
};
|
||||
|
||||
// don't call
|
||||
const SkRegion& internal_private_getTotalClip() const;
|
||||
// don't call
|
||||
void internal_private_getTotalClipAsPath(SkPath*) const;
|
||||
// don't call
|
||||
GrRenderTarget* internal_private_accessTopLayerRenderTarget();
|
||||
|
||||
// don't call
|
||||
static void Internal_Private_SetIgnoreSaveLayerBounds(bool);
|
||||
static bool Internal_Private_GetIgnoreSaveLayerBounds();
|
||||
static void Internal_Private_SetTreatSpriteAsBitmap(bool);
|
||||
static bool Internal_Private_GetTreatSpriteAsBitmap();
|
||||
|
||||
// TEMP helpers until we switch virtual over to const& for src-rect
|
||||
void legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint,
|
||||
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
||||
void legacy_drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint,
|
||||
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
||||
|
||||
protected:
|
||||
// default impl defers to getDevice()->newSurface(info)
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&);
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&);
|
||||
|
||||
// default impl defers to its device
|
||||
virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes);
|
||||
virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes);
|
||||
virtual bool onPeekPixels(SkPixmap*);
|
||||
virtual bool onAccessTopLayerPixels(SkPixmap*);
|
||||
|
||||
// Subclass save/restore notifiers.
|
||||
// Overriders should call the corresponding INHERITED method up the inheritance chain.
|
||||
@@ -1182,6 +1234,7 @@ protected:
|
||||
return kFullLayer_SaveLayerStrategy;
|
||||
}
|
||||
virtual void willRestore() {}
|
||||
virtual void didRestore() {}
|
||||
virtual void didConcat(const SkMatrix&) {}
|
||||
virtual void didSetMatrix(const SkMatrix&) {}
|
||||
|
||||
@@ -1201,6 +1254,39 @@ protected:
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint);
|
||||
|
||||
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint);
|
||||
|
||||
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
|
||||
|
||||
virtual void onDrawDrawable(SkDrawable*, const SkMatrix*);
|
||||
|
||||
virtual void onDrawPaint(const SkPaint&);
|
||||
virtual void onDrawRect(const SkRect&, const SkPaint&);
|
||||
virtual void onDrawOval(const SkRect&, const SkPaint&);
|
||||
virtual void onDrawRRect(const SkRRect&, const SkPaint&);
|
||||
virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&);
|
||||
virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
|
||||
const SkPoint texs[], const SkColor colors[], SkXfermode*,
|
||||
const uint16_t indices[], int indexCount, const SkPaint&);
|
||||
|
||||
virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int count, SkXfermode::Mode, const SkRect* cull, const SkPaint*);
|
||||
virtual void onDrawPath(const SkPath&, const SkPaint&);
|
||||
virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*);
|
||||
virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
|
||||
SrcRectConstraint);
|
||||
virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
|
||||
const SkPaint*);
|
||||
|
||||
virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*);
|
||||
virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
|
||||
SrcRectConstraint);
|
||||
virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
|
||||
const SkPaint*);
|
||||
virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*);
|
||||
|
||||
enum ClipEdgeStyle {
|
||||
kHard_ClipEdgeStyle,
|
||||
kSoft_ClipEdgeStyle
|
||||
@@ -1213,7 +1299,7 @@ protected:
|
||||
|
||||
virtual void onDiscard();
|
||||
|
||||
virtual void onDrawPicture(const SkPicture* picture);
|
||||
virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);
|
||||
|
||||
// Returns the canvas to be used by DrawIter. Default implementation
|
||||
// returns this. Subclasses that encapsulate an indirect canvas may
|
||||
@@ -1229,30 +1315,40 @@ protected:
|
||||
SkIRect* intersection,
|
||||
const SkImageFilter* imageFilter = NULL);
|
||||
|
||||
// Called by child classes that override clipPath and clipRRect to only
|
||||
// track fast conservative clip bounds, rather than exact clips.
|
||||
void updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op,
|
||||
bool inverseFilled);
|
||||
private:
|
||||
enum ShaderOverrideOpacity {
|
||||
kNone_ShaderOverrideOpacity, //!< there is no overriding shader (bitmap or image)
|
||||
kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque
|
||||
kNotOpaque_ShaderOverrideOpacity, //!< the overriding shader may not be opaque
|
||||
};
|
||||
|
||||
// notify our surface (if we have one) that we are about to draw, so it
|
||||
// can perform copy-on-write or invalidate any cached images
|
||||
void predrawNotify();
|
||||
void predrawNotify(bool willOverwritesEntireSurface = false);
|
||||
void predrawNotify(const SkRect* rect, const SkPaint* paint, ShaderOverrideOpacity);
|
||||
void predrawNotify(const SkRect* rect, const SkPaint* paint, bool shaderOverrideIsOpaque) {
|
||||
this->predrawNotify(rect, paint, shaderOverrideIsOpaque ? kOpaque_ShaderOverrideOpacity
|
||||
: kNotOpaque_ShaderOverrideOpacity);
|
||||
}
|
||||
|
||||
virtual void onPushCull(const SkRect& cullRect);
|
||||
virtual void onPopCull();
|
||||
|
||||
private:
|
||||
class MCRec;
|
||||
|
||||
SkClipStack fClipStack;
|
||||
SkAutoTUnref<SkClipStack> fClipStack;
|
||||
SkDeque fMCStack;
|
||||
// points to top of stack
|
||||
MCRec* fMCRec;
|
||||
// the first N recs that can fit here mean we won't call malloc
|
||||
uint32_t fMCRecStorage[32];
|
||||
enum {
|
||||
kMCRecSize = 128, // most recent measurement
|
||||
kMCRecCount = 32, // common depth for save/restores
|
||||
kDeviceCMSize = 136, // most recent measurement
|
||||
};
|
||||
intptr_t fMCRecStorage[kMCRecSize * kMCRecCount / sizeof(intptr_t)];
|
||||
intptr_t fDeviceCMStorage[kDeviceCMSize / sizeof(intptr_t)];
|
||||
|
||||
int fSaveLayerCount; // number of successful saveLayer calls
|
||||
int fCullCount; // number of active culls
|
||||
const SkSurfaceProps fProps;
|
||||
|
||||
int fSaveCount; // value returned by getSaveCount()
|
||||
|
||||
SkMetaData* fMetaData;
|
||||
|
||||
@@ -1267,25 +1363,37 @@ private:
|
||||
bool fDeviceCMDirty; // cleared by updateDeviceCMCache()
|
||||
void updateDeviceCMCache();
|
||||
|
||||
void doSave();
|
||||
void checkForDeferredSave();
|
||||
|
||||
friend class SkDrawIter; // needs setupDrawForLayerDevice()
|
||||
friend class AutoDrawLooper;
|
||||
friend class SkLua; // needs top layer size and offset
|
||||
friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip
|
||||
friend class SkDeferredDevice; // needs getTopDevice()
|
||||
friend class SkSurface_Raster; // needs getDevice()
|
||||
friend class SkRecorder; // InitFlags
|
||||
friend class SkNoSaveLayerCanvas; // InitFlags
|
||||
friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProps*, InitFlags)
|
||||
friend class SkPictureRecord; // predrawNotify (why does it need it? <reed>)
|
||||
|
||||
SkBaseDevice* createLayerDevice(const SkImageInfo&);
|
||||
enum InitFlags {
|
||||
kDefault_InitFlags = 0,
|
||||
kConservativeRasterClip_InitFlag = 1 << 0,
|
||||
};
|
||||
SkCanvas(const SkIRect& bounds, InitFlags);
|
||||
SkCanvas(SkBaseDevice* device, InitFlags);
|
||||
|
||||
SkBaseDevice* init(SkBaseDevice*);
|
||||
void resetForNextPicture(const SkIRect& bounds);
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
*
|
||||
* Specify a device for this canvas to draw into. If it is not null, its
|
||||
* reference count is incremented. If the canvas was already holding a
|
||||
* device, its reference count is decremented. The new device is returned.
|
||||
*/
|
||||
SkBaseDevice* setRootDevice(SkBaseDevice* device);
|
||||
// needs gettotalclip()
|
||||
friend class SkCanvasStateUtils;
|
||||
|
||||
// call this each time we attach ourselves to a device
|
||||
// - constructor
|
||||
// - internalSaveLayer
|
||||
void setupDevice(SkBaseDevice*);
|
||||
|
||||
SkBaseDevice* init(SkBaseDevice*, InitFlags);
|
||||
|
||||
/**
|
||||
* Gets the size/origin of the top level layer in global canvas coordinates. We don't want this
|
||||
@@ -1294,21 +1402,15 @@ private:
|
||||
SkISize getTopLayerSize() const;
|
||||
SkIPoint getTopLayerOrigin() const;
|
||||
|
||||
// internal methods are not virtual, so they can safely be called by other
|
||||
// canvas apis, without confusing subclasses (like SkPictureRecording)
|
||||
void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* paint);
|
||||
void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
|
||||
const SkRect& dst, const SkPaint* paint,
|
||||
DrawBitmapRectFlags flags);
|
||||
void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint* paint);
|
||||
SrcRectConstraint);
|
||||
void internalDrawPaint(const SkPaint& paint);
|
||||
int internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
|
||||
SaveFlags, bool justForImageFilter, SaveLayerStrategy strategy);
|
||||
void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*);
|
||||
void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, SaveLayerStrategy);
|
||||
void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool isBitmapDevice);
|
||||
|
||||
// shared by save() and saveLayer()
|
||||
int internalSave();
|
||||
void internalSave();
|
||||
void internalRestore();
|
||||
static void DrawRect(const SkDraw& draw, const SkPaint& paint,
|
||||
const SkRect& r, SkScalar textSize);
|
||||
@@ -1316,6 +1418,17 @@ private:
|
||||
const char text[], size_t byteLength,
|
||||
SkScalar x, SkScalar y);
|
||||
|
||||
// only for canvasutils
|
||||
const SkRegion& internal_private_getTotalClip() const;
|
||||
|
||||
/*
|
||||
* Returns true if drawing the specified rect (or all if it is null) with the specified
|
||||
* paint (or default if null) would overwrite the entire root device of the canvas
|
||||
* (i.e. the canvas' surface if it had one).
|
||||
*/
|
||||
bool wouldOverwriteEntireSurface(const SkRect*, const SkPaint*, ShaderOverrideOpacity) const;
|
||||
|
||||
|
||||
/* These maintain a cache of the clip bounds in local coordinates,
|
||||
(converted to 2s-compliment if floats are slow).
|
||||
*/
|
||||
@@ -1323,6 +1436,7 @@ private:
|
||||
mutable bool fCachedLocalClipBoundsDirty;
|
||||
bool fAllowSoftClip;
|
||||
bool fAllowSimplifyClip;
|
||||
const bool fConservativeRasterClip;
|
||||
|
||||
const SkRect& getLocalClipBounds() const {
|
||||
if (fCachedLocalClipBoundsDirty) {
|
||||
@@ -1346,9 +1460,6 @@ private:
|
||||
};
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
// The cull stack rects are in device-space
|
||||
SkTDArray<SkIRect> fCullStack;
|
||||
void validateCull(const SkIRect&);
|
||||
void validateClip() const;
|
||||
#else
|
||||
void validateClip() const {}
|
||||
@@ -1394,28 +1505,6 @@ private:
|
||||
};
|
||||
#define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore)
|
||||
|
||||
/** Stack helper class to automatically open and close a comment block
|
||||
*/
|
||||
class SkAutoCommentBlock : SkNoncopyable {
|
||||
public:
|
||||
SkAutoCommentBlock(SkCanvas* canvas, const char* description) {
|
||||
fCanvas = canvas;
|
||||
if (NULL != fCanvas) {
|
||||
fCanvas->beginCommentGroup(description);
|
||||
}
|
||||
}
|
||||
|
||||
~SkAutoCommentBlock() {
|
||||
if (NULL != fCanvas) {
|
||||
fCanvas->endCommentGroup();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SkCanvas* fCanvas;
|
||||
};
|
||||
#define SkAutoCommentBlock(...) SK_REQUIRE_LOCAL_VAR(SkAutoCommentBlock)
|
||||
|
||||
/**
|
||||
* If the caller wants read-only access to the pixels in a canvas, it can just
|
||||
* call canvas->peekPixels(), since that is the fastest way to "peek" at the
|
||||
|
||||
@@ -22,6 +22,11 @@ public:
|
||||
* pointers.
|
||||
*/
|
||||
void reset();
|
||||
/**
|
||||
* Reset to 0 used bytes preserving as much memory as possible.
|
||||
* This invalidates all returned pointers.
|
||||
*/
|
||||
void rewind();
|
||||
|
||||
enum AllocFailType {
|
||||
kReturnNil_AllocFailType,
|
||||
@@ -43,7 +48,8 @@ public:
|
||||
|
||||
size_t totalCapacity() const { return fTotalCapacity; }
|
||||
size_t totalUsed() const { return fTotalUsed; }
|
||||
int blockCount() const { return fBlockCount; }
|
||||
SkDEBUGCODE(int blockCount() const { return fBlockCount; })
|
||||
SkDEBUGCODE(size_t totalLost() const { return fTotalLost; })
|
||||
|
||||
/**
|
||||
* Returns true if the specified address is within one of the chunks, and
|
||||
@@ -60,9 +66,13 @@ private:
|
||||
size_t fChunkSize;
|
||||
size_t fTotalCapacity;
|
||||
size_t fTotalUsed; // will be <= fTotalCapacity
|
||||
int fBlockCount;
|
||||
SkDEBUGCODE(int fBlockCount;)
|
||||
SkDEBUGCODE(size_t fTotalLost;) // will be <= fTotalCapacity
|
||||
|
||||
Block* newBlock(size_t bytes, AllocFailType ftype);
|
||||
Block* addBlockIfNecessary(size_t bytes, AllocFailType ftype);
|
||||
|
||||
SkDEBUGCODE(void validate();)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@ class SkCanvasClipVisitor;
|
||||
// (i.e., the fSaveCount in force when it was added). Restores are thus
|
||||
// implemented by removing clips from fDeque that have an fSaveCount larger
|
||||
// then the freshly decremented count.
|
||||
class SK_API SkClipStack {
|
||||
class SK_API SkClipStack : public SkNVRefCnt<SkClipStack> {
|
||||
public:
|
||||
enum BoundsType {
|
||||
// The bounding box contains all the pixels that can be written to
|
||||
@@ -309,13 +309,6 @@ public:
|
||||
BoundsType* boundType,
|
||||
bool* isIntersectionOfRects = NULL) const;
|
||||
|
||||
/**
|
||||
* Takes an input rect in device space and conservatively clips it to the
|
||||
* clip-stack. If false is returned then the rect does not intersect the
|
||||
* clip and is unmodified.
|
||||
*/
|
||||
bool intersectRectWithClip(SkRect* devRect) const;
|
||||
|
||||
/**
|
||||
* Returns true if the input rect in device space is entirely contained
|
||||
* by the clip. A return value of false does not guarantee that the rect
|
||||
@@ -323,6 +316,12 @@ public:
|
||||
*/
|
||||
bool quickContains(const SkRect& devRect) const;
|
||||
|
||||
/**
|
||||
* Flattens the clip stack into a single SkPath. Returns true if any of
|
||||
* the clip stack components requires anti-aliasing.
|
||||
*/
|
||||
bool asPath(SkPath* path) const;
|
||||
|
||||
void clipDevRect(const SkIRect& ir, SkRegion::Op op) {
|
||||
SkRect r;
|
||||
r.set(ir);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@@ -6,11 +5,11 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkColor_DEFINED
|
||||
#define SkColor_DEFINED
|
||||
|
||||
#include "SkScalar.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
/** \file SkColor.h
|
||||
|
||||
@@ -161,9 +160,4 @@ SK_API SkPMColor SkPreMultiplyColor(SkColor c);
|
||||
*/
|
||||
typedef SkPMColor (*SkXfermodeProc)(SkPMColor src, SkPMColor dst);
|
||||
|
||||
/** Define a function pointer type for combining a premultiplied src color
|
||||
and a 16bit device color.
|
||||
*/
|
||||
typedef uint16_t (*SkXfermodeProc16)(SkPMColor src, uint16_t dst);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@@ -6,17 +5,17 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkColorFilter_DEFINED
|
||||
#define SkColorFilter_DEFINED
|
||||
|
||||
#include "SkColor.h"
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkTDArray.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
class SkBitmap;
|
||||
class GrEffect;
|
||||
class GrContext;
|
||||
class GrFragmentProcessor;
|
||||
class SkBitmap;
|
||||
|
||||
/**
|
||||
* ColorFilters are optional objects in the drawing pipeline. When present in
|
||||
@@ -28,8 +27,6 @@ class GrContext;
|
||||
*/
|
||||
class SK_API SkColorFilter : public SkFlattenable {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkColorFilter)
|
||||
|
||||
/**
|
||||
* If the filter can be represented by a source color plus Mode, this
|
||||
* returns true, and sets (if not NULL) the color and mode appropriately.
|
||||
@@ -69,34 +66,27 @@ public:
|
||||
@param count the number of entries in the src[] and result[] arrays
|
||||
@param result written by the filter
|
||||
*/
|
||||
virtual void filterSpan(const SkPMColor src[], int count,
|
||||
SkPMColor result[]) const = 0;
|
||||
/** Called with a scanline of colors, as if there was a shader installed.
|
||||
The implementation writes out its filtered version into result[].
|
||||
Note: shader and result may be the same buffer.
|
||||
@param src array of colors, possibly generated by a shader
|
||||
@param count the number of entries in the src[] and result[] arrays
|
||||
@param result written by the filter
|
||||
*/
|
||||
virtual void filterSpan16(const uint16_t shader[], int count,
|
||||
uint16_t result[]) const;
|
||||
virtual void filterSpan(const SkPMColor src[], int count, SkPMColor result[]) const = 0;
|
||||
|
||||
enum Flags {
|
||||
/** If set the filter methods will not change the alpha channel of the
|
||||
colors.
|
||||
/** If set the filter methods will not change the alpha channel of the colors.
|
||||
*/
|
||||
kAlphaUnchanged_Flag = 0x01,
|
||||
/** If set, this subclass implements filterSpan16(). If this flag is
|
||||
set, then kAlphaUnchanged_Flag must also be set.
|
||||
*/
|
||||
kHasFilter16_Flag = 0x02
|
||||
};
|
||||
|
||||
/** Returns the flags for this filter. Override in subclasses to return
|
||||
custom flags.
|
||||
/** Returns the flags for this filter. Override in subclasses to return custom flags.
|
||||
*/
|
||||
virtual uint32_t getFlags() const { return 0; }
|
||||
|
||||
/**
|
||||
* If this subclass can optimally createa composition with the inner filter, return it as
|
||||
* a new filter (which the caller must unref() when it is done). If no such optimization
|
||||
* is known, return NULL.
|
||||
*
|
||||
* e.g. result(color) == this_filter(inner(color))
|
||||
*/
|
||||
virtual SkColorFilter* newComposed(const SkColorFilter* /*inner*/) const { return NULL; }
|
||||
|
||||
/**
|
||||
* Apply this colorfilter to the specified SkColor. This routine handles
|
||||
* converting to SkPMColor, calling the filter, and then converting back
|
||||
@@ -123,10 +113,31 @@ public:
|
||||
*/
|
||||
static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
|
||||
|
||||
/** A subclass may implement this factory function to work with the GPU backend. If the return
|
||||
is non-NULL then the caller owns a ref on the returned object.
|
||||
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
|
||||
* the outer filter to the result of the inner's.
|
||||
* The reference counts for outer and inner are incremented.
|
||||
*
|
||||
* Due to internal limits, it is possible that this will return NULL, so the caller must
|
||||
* always check.
|
||||
*/
|
||||
virtual GrEffect* asNewEffect(GrContext*) const;
|
||||
static SkColorFilter* CreateComposeFilter(SkColorFilter* outer, SkColorFilter* inner);
|
||||
|
||||
/**
|
||||
* A subclass may implement this factory function to work with the GPU backend. It returns
|
||||
* a GrFragmentProcessor that implemets the color filter in GPU shader code.
|
||||
*
|
||||
* The fragment processor receives a premultiplied input color and produces a premultiplied
|
||||
* output color.
|
||||
*
|
||||
* A null return indicates that the color filter isn't implemented for the GPU backend.
|
||||
*/
|
||||
virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool affectsTransparentBlack() const {
|
||||
return this->filterColor(0) != 0;
|
||||
}
|
||||
|
||||
SK_TO_STRING_PUREVIRT()
|
||||
|
||||
@@ -135,9 +146,18 @@ public:
|
||||
|
||||
protected:
|
||||
SkColorFilter() {}
|
||||
SkColorFilter(SkReadBuffer& rb) : INHERITED(rb) {}
|
||||
|
||||
private:
|
||||
/*
|
||||
* Returns 1 if this is a single filter (not a composition of other filters), otherwise it
|
||||
* reutrns the number of leaf-node filters in a composition. This should be the same value
|
||||
* as the number of GrFragmentProcessors returned by asFragmentProcessors's array parameter.
|
||||
*
|
||||
* e.g. compose(filter, compose(compose(filter, filter), filter)) --> 4
|
||||
*/
|
||||
virtual int privateComposedFilterCount() const { return 1; }
|
||||
friend class SkComposeColorFilter;
|
||||
|
||||
typedef SkFlattenable INHERITED;
|
||||
};
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ static inline unsigned Sk255To256(U8CPU value) {
|
||||
/** Multiplify value by 0..256, and shift the result down 8
|
||||
(i.e. return (value * alpha256) >> 8)
|
||||
*/
|
||||
#define SkAlphaMul(value, alpha256) (SkMulS16(value, alpha256) >> 8)
|
||||
#define SkAlphaMul(value, alpha256) (((value) * (alpha256)) >> 8)
|
||||
|
||||
// The caller may want negative values, so keep all params signed (int)
|
||||
// so we don't accidentally slip into unsigned math and lose the sign
|
||||
@@ -213,11 +213,21 @@ static inline int SkAlphaBlend255(S16CPU src, S16CPU dst, U8CPU alpha) {
|
||||
SkASSERT((int16_t)dst == dst);
|
||||
SkASSERT((uint8_t)alpha == alpha);
|
||||
|
||||
int prod = SkMulS16(src - dst, alpha) + 128;
|
||||
int prod = (src - dst) * alpha + 128;
|
||||
prod = (prod + (prod >> 8)) >> 8;
|
||||
return dst + prod;
|
||||
}
|
||||
|
||||
static inline U8CPU SkUnitScalarClampToByte(SkScalar x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (x >= SK_Scalar1) {
|
||||
return 255;
|
||||
}
|
||||
return SkScalarToFixed(x) >> 8;
|
||||
}
|
||||
|
||||
#define SK_R16_BITS 5
|
||||
#define SK_G16_BITS 6
|
||||
#define SK_B16_BITS 5
|
||||
@@ -281,6 +291,16 @@ static inline U16CPU SkAlphaMulRGB16(U16CPU c, unsigned scale) {
|
||||
// this helper explicitly returns a clean 16bit value (but slower)
|
||||
#define SkAlphaMulRGB16_ToU16(c, s) (uint16_t)SkAlphaMulRGB16(c, s)
|
||||
|
||||
/** Blend pre-expanded RGB32 with 16bit color value by the 0..32 scale parameter.
|
||||
The computation yields only 16bits of valid data, but we claim to return
|
||||
32bits, so that the compiler won't generate extra instructions to "clean"
|
||||
the top 16bits.
|
||||
*/
|
||||
static inline U16CPU SkBlend32_RGB16(uint32_t src_expand, uint16_t dst, unsigned scale) {
|
||||
uint32_t dst_expand = SkExpand_rgb_16(dst) * scale;
|
||||
return SkCompact_rgb_16((src_expand + dst_expand) >> 5);
|
||||
}
|
||||
|
||||
/** Blend src and dst 16bit colors by the 0..256 scale parameter.
|
||||
The computation yields only 16bits of valid data, but we claim
|
||||
to return 32bits, so that the compiler won't generate extra instructions to
|
||||
@@ -306,7 +326,8 @@ static inline void SkBlendRGB16(const uint16_t src[], uint16_t dst[],
|
||||
do {
|
||||
uint32_t src32 = SkExpand_rgb_16(*src++);
|
||||
uint32_t dst32 = SkExpand_rgb_16(*dst);
|
||||
*dst++ = SkCompact_rgb_16(dst32 + ((src32 - dst32) * srcScale >> 5));
|
||||
*dst++ = static_cast<uint16_t>(
|
||||
SkCompact_rgb_16(dst32 + ((src32 - dst32) * srcScale >> 5)));
|
||||
} while (--count > 0);
|
||||
}
|
||||
|
||||
@@ -345,21 +366,31 @@ static inline void SkBlendRGB16(const uint16_t src[], uint16_t dst[],
|
||||
#define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK)
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
static inline void SkPMColorAssert(SkPMColor c) {
|
||||
unsigned a = SkGetPackedA32(c);
|
||||
unsigned r = SkGetPackedR32(c);
|
||||
unsigned g = SkGetPackedG32(c);
|
||||
unsigned b = SkGetPackedB32(c);
|
||||
|
||||
SkA32Assert(a);
|
||||
SkASSERT(r <= a);
|
||||
SkASSERT(g <= a);
|
||||
SkASSERT(b <= a);
|
||||
}
|
||||
#define SkPMColorAssert(color_value) \
|
||||
do { \
|
||||
SkPMColor pm_color_value = (color_value); \
|
||||
uint32_t alpha_color_value = SkGetPackedA32(pm_color_value); \
|
||||
SkA32Assert(alpha_color_value); \
|
||||
SkASSERT(SkGetPackedR32(pm_color_value) <= alpha_color_value); \
|
||||
SkASSERT(SkGetPackedG32(pm_color_value) <= alpha_color_value); \
|
||||
SkASSERT(SkGetPackedB32(pm_color_value) <= alpha_color_value); \
|
||||
} while (false)
|
||||
#else
|
||||
#define SkPMColorAssert(c)
|
||||
#endif
|
||||
|
||||
static inline bool SkPMColorValid(SkPMColor c) {
|
||||
auto a = SkGetPackedA32(c);
|
||||
bool valid = a <= SK_A32_MASK
|
||||
&& SkGetPackedR32(c) <= a
|
||||
&& SkGetPackedG32(c) <= a
|
||||
&& SkGetPackedB32(c) <= a;
|
||||
if (valid) {
|
||||
SkPMColorAssert(c); // Make sure we're consistent when it counts.
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pack the components into a SkPMColor, checking (in the debug version) that
|
||||
* the components are 0..255, and are already premultiplied (i.e. alpha >= color)
|
||||
@@ -787,7 +818,7 @@ static inline SkPMColor16 SkPackARGB4444(unsigned a, unsigned r,
|
||||
(g << SK_G4444_SHIFT) | (b << SK_B4444_SHIFT));
|
||||
}
|
||||
|
||||
static inline U16CPU SkAlphaMulQ4(U16CPU c, unsigned scale) {
|
||||
static inline SkPMColor16 SkAlphaMulQ4(SkPMColor16 c, int scale) {
|
||||
SkASSERT(scale <= 16);
|
||||
|
||||
const unsigned mask = 0xF0F; //gMask_0F0F;
|
||||
@@ -797,14 +828,14 @@ static inline U16CPU SkAlphaMulQ4(U16CPU c, unsigned scale) {
|
||||
unsigned ag = ((c >> 4) & mask) * scale;
|
||||
return (rb & mask) | (ag & ~mask);
|
||||
#else
|
||||
c = (c & mask) | ((c & (mask << 4)) << 12);
|
||||
c = c * scale >> 4;
|
||||
return (c & mask) | ((c >> 12) & (mask << 4));
|
||||
unsigned expanded_c = (c & mask) | ((c & (mask << 4)) << 12);
|
||||
unsigned scaled_c = (expanded_c * scale) >> 4;
|
||||
return (scaled_c & mask) | ((scaled_c >> 12) & (mask << 4));
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Expand the SkPMColor16 color into a 32bit value that can be scaled all at
|
||||
once by a value up to 16. Used in conjunction with SkCompact_4444.
|
||||
once by a value up to 16.
|
||||
*/
|
||||
static inline uint32_t SkExpand_4444(U16CPU c) {
|
||||
SkASSERT(c == (uint16_t)c);
|
||||
@@ -813,18 +844,6 @@ static inline uint32_t SkExpand_4444(U16CPU c) {
|
||||
return (c & mask) | ((c & ~mask) << 12);
|
||||
}
|
||||
|
||||
/** Compress an expanded value (from SkExpand_4444) back down to a SkPMColor16.
|
||||
NOTE: this explicitly does not clean the top 16 bits (which may be garbage).
|
||||
It does this for speed, since if it is being written directly to 16bits of
|
||||
memory, the top 16bits will be ignored. Casting the result to uint16_t here
|
||||
would add 2 more instructions, slow us down. It is up to the caller to
|
||||
perform the cast if needed.
|
||||
*/
|
||||
static inline U16CPU SkCompact_4444(uint32_t c) {
|
||||
const unsigned mask = 0xF0F; //gMask_0F0F;
|
||||
return (c & mask) | ((c >> 12) & ~mask);
|
||||
}
|
||||
|
||||
static inline uint16_t SkSrcOver4444To16(SkPMColor16 s, uint16_t d) {
|
||||
unsigned sa = SkGetPackedA4444(s);
|
||||
unsigned sr = SkR4444ToR565(SkGetPackedR4444(s));
|
||||
@@ -856,22 +875,6 @@ static inline uint16_t SkBlend4444To16(SkPMColor16 src, uint16_t dst, int scale1
|
||||
return SkSrcOver4444To16(SkAlphaMulQ4(src, scale16), dst);
|
||||
}
|
||||
|
||||
static inline uint16_t SkBlend4444(SkPMColor16 src, SkPMColor16 dst, int scale16) {
|
||||
SkASSERT((unsigned)scale16 <= 16);
|
||||
|
||||
uint32_t src32 = SkExpand_4444(src) * scale16;
|
||||
// the scaled srcAlpha is the bottom byte
|
||||
#ifdef SK_DEBUG
|
||||
{
|
||||
unsigned srcA = SkGetPackedA4444(src) * scale16;
|
||||
SkASSERT(srcA == (src32 & 0xFF));
|
||||
}
|
||||
#endif
|
||||
unsigned dstScale = SkAlpha255To256(255 - (src32 & 0xFF)) >> 4;
|
||||
uint32_t dst32 = SkExpand_4444(dst) * dstScale;
|
||||
return SkCompact_4444((src32 + dst32) >> 4);
|
||||
}
|
||||
|
||||
static inline SkPMColor SkPixel4444ToPixel32(U16CPU c) {
|
||||
uint32_t d = (SkGetPackedA4444(c) << SK_A32_SHIFT) |
|
||||
(SkGetPackedR4444(c) << SK_R32_SHIFT) |
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2007 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkColorShader_DEFINED
|
||||
#define SkColorShader_DEFINED
|
||||
|
||||
#include "SkShader.h"
|
||||
|
||||
/** \class SkColorShader
|
||||
A Shader that represents a single color. In general, this effect can be
|
||||
accomplished by just using the color field on the paint, but if an
|
||||
actual shader object is needed, this provides that feature.
|
||||
*/
|
||||
class SK_API SkColorShader : public SkShader {
|
||||
public:
|
||||
/** Create a ColorShader that ignores the color in the paint, and uses the
|
||||
specified color. Note: like all shaders, at draw time the paint's alpha
|
||||
will be respected, and is applied to the specified color.
|
||||
*/
|
||||
explicit SkColorShader(SkColor c);
|
||||
|
||||
virtual bool isOpaque() const SK_OVERRIDE;
|
||||
|
||||
virtual size_t contextSize() const SK_OVERRIDE {
|
||||
return sizeof(ColorShaderContext);
|
||||
}
|
||||
|
||||
class ColorShaderContext : public SkShader::Context {
|
||||
public:
|
||||
ColorShaderContext(const SkColorShader& shader, const ContextRec&);
|
||||
|
||||
virtual uint32_t getFlags() const SK_OVERRIDE;
|
||||
virtual uint8_t getSpan16Alpha() const SK_OVERRIDE;
|
||||
virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE;
|
||||
virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
|
||||
virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkPMColor fPMColor;
|
||||
uint32_t fFlags;
|
||||
uint16_t fColor16;
|
||||
|
||||
typedef SkShader::Context INHERITED;
|
||||
};
|
||||
|
||||
// we return false for this, use asAGradient
|
||||
virtual BitmapType asABitmap(SkBitmap* outTexture,
|
||||
SkMatrix* outMatrix,
|
||||
TileMode xy[2]) const SK_OVERRIDE;
|
||||
|
||||
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
|
||||
|
||||
virtual bool asNewEffect(GrContext* context, const SkPaint& paint,
|
||||
const SkMatrix* localMatrix, GrColor* paintColor,
|
||||
GrEffect** effect) const SK_OVERRIDE;
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader)
|
||||
|
||||
protected:
|
||||
SkColorShader(SkReadBuffer&);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkColor fColor; // ignored if fInheritColor is true
|
||||
|
||||
typedef SkShader INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef SkColorTable_DEFINED
|
||||
#define SkColorTable_DEFINED
|
||||
|
||||
#include "../private/SkOncePtr.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkImageInfo.h"
|
||||
@@ -18,75 +19,64 @@
|
||||
|
||||
SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by
|
||||
8-bit bitmaps, where the bitmap bytes are interpreted as indices into the colortable.
|
||||
*/
|
||||
class SkColorTable : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkColorTable)
|
||||
|
||||
/** Makes a deep copy of colors.
|
||||
SkColorTable is thread-safe.
|
||||
*/
|
||||
class SK_API SkColorTable : public SkRefCnt {
|
||||
public:
|
||||
/** Copy up to 256 colors into a new SkColorTable.
|
||||
*/
|
||||
SkColorTable(const SkColorTable& src);
|
||||
SkColorTable(const SkPMColor colors[], int count,
|
||||
SkAlphaType alphaType = kPremul_SkAlphaType);
|
||||
SkColorTable(const SkPMColor colors[], int count);
|
||||
virtual ~SkColorTable();
|
||||
|
||||
SkAlphaType alphaType() const { return (SkAlphaType)fAlphaType; }
|
||||
|
||||
bool isOpaque() const {
|
||||
return SkAlphaTypeIsOpaque(this->alphaType());
|
||||
}
|
||||
|
||||
/** Returns the number of colors in the table.
|
||||
*/
|
||||
*/
|
||||
int count() const { return fCount; }
|
||||
|
||||
/** Returns the specified color from the table. In the debug build, this asserts that
|
||||
the index is in range (0 <= index < count).
|
||||
*/
|
||||
* the index is in range (0 <= index < count).
|
||||
*/
|
||||
SkPMColor operator[](int index) const {
|
||||
SkASSERT(fColors != NULL && (unsigned)index < fCount);
|
||||
SkASSERT(fColors != NULL && (unsigned)index < (unsigned)fCount);
|
||||
return fColors[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array of colors for reading. This must be balanced by a call
|
||||
* to unlockColors().
|
||||
/** Return the array of colors for reading.
|
||||
*/
|
||||
const SkPMColor* lockColors() {
|
||||
SkDEBUGCODE(sk_atomic_inc(&fColorLockCount);)
|
||||
return fColors;
|
||||
}
|
||||
const SkPMColor* readColors() const { return fColors; }
|
||||
|
||||
/**
|
||||
* Balancing call to lockColors().
|
||||
/** read16BitCache() returns the array of RGB16 colors that mirror the 32bit colors.
|
||||
*/
|
||||
void unlockColors();
|
||||
const uint16_t* read16BitCache() const;
|
||||
|
||||
/** Similar to lockColors(), lock16BitCache() returns the array of
|
||||
RGB16 colors that mirror the 32bit colors. However, this function
|
||||
will return null if kColorsAreOpaque_Flag is not set.
|
||||
Also, unlike lockColors(), the returned array here cannot be modified.
|
||||
*/
|
||||
const uint16_t* lock16BitCache();
|
||||
/** Balancing call to lock16BitCache().
|
||||
*/
|
||||
void unlock16BitCache() {
|
||||
SkASSERT(f16BitCacheLockCount > 0);
|
||||
SkDEBUGCODE(f16BitCacheLockCount -= 1);
|
||||
}
|
||||
|
||||
explicit SkColorTable(SkReadBuffer&);
|
||||
void writeToBuffer(SkWriteBuffer&) const;
|
||||
|
||||
private:
|
||||
SkPMColor* fColors;
|
||||
uint16_t* f16BitCache;
|
||||
uint16_t fCount;
|
||||
uint8_t fAlphaType;
|
||||
SkDEBUGCODE(int fColorLockCount;)
|
||||
SkDEBUGCODE(int f16BitCacheLockCount;)
|
||||
// may return null
|
||||
static SkColorTable* Create(SkReadBuffer&);
|
||||
|
||||
void inval16BitCache();
|
||||
private:
|
||||
enum AllocatedWithMalloc {
|
||||
kAllocatedWithMalloc
|
||||
};
|
||||
// assumes ownership of colors (assumes it was allocated w/ malloc)
|
||||
SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc);
|
||||
|
||||
SkPMColor* fColors;
|
||||
SkOncePtr<uint16_t[]> f16BitCache;
|
||||
int fCount;
|
||||
|
||||
void init(const SkPMColor* colors, int count);
|
||||
|
||||
friend class SkImageGenerator;
|
||||
// Only call if no other thread or cache has seen this table.
|
||||
void dangerous_overwriteColors(const SkPMColor newColors[], int count) {
|
||||
if (count < 0 || count > fCount) {
|
||||
sk_throw();
|
||||
}
|
||||
// assumes that f16BitCache nas NOT been initialized yet, so we don't try to update it
|
||||
memcpy(fColors, newColors, count * sizeof(SkPMColor));
|
||||
fCount = count; // update fCount, in case count is smaller
|
||||
}
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
@@ -34,7 +34,14 @@ public:
|
||||
SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
|
||||
virtual ~SkComposeShader();
|
||||
|
||||
virtual size_t contextSize() const SK_OVERRIDE;
|
||||
size_t contextSize() const override;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const GrFragmentProcessor* asFragmentProcessor(GrContext*,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
SkFilterQuality) const override;
|
||||
#endif
|
||||
|
||||
class ComposeShaderContext : public SkShader::Context {
|
||||
public:
|
||||
@@ -48,7 +55,7 @@ public:
|
||||
|
||||
virtual ~ComposeShaderContext();
|
||||
|
||||
virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
|
||||
void shadeSpan(int x, int y, SkPMColor[], int count) override;
|
||||
|
||||
private:
|
||||
SkShader::Context* fShaderContextA;
|
||||
@@ -62,15 +69,15 @@ public:
|
||||
SkShader* getShaderB() { return fShaderB; }
|
||||
#endif
|
||||
|
||||
virtual bool asACompose(ComposeRec* rec) const SK_OVERRIDE;
|
||||
bool asACompose(ComposeRec* rec) const override;
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
|
||||
|
||||
protected:
|
||||
SkComposeShader(SkReadBuffer& );
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE;
|
||||
void flatten(SkWriteBuffer&) const override;
|
||||
Context* onCreateContext(const ContextRec&, void*) const override;
|
||||
|
||||
private:
|
||||
SkShader* fShaderA;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
@@ -6,14 +5,14 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef SkData_DEFINED
|
||||
#define SkData_DEFINED
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
struct SkFILE;
|
||||
class SkStream;
|
||||
|
||||
/**
|
||||
* SkData holds an immutable data buffer. Not only is the data immutable,
|
||||
@@ -22,8 +21,6 @@ struct SkFILE;
|
||||
*/
|
||||
class SK_API SkData : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkData)
|
||||
|
||||
/**
|
||||
* Returns the number of bytes stored.
|
||||
*/
|
||||
@@ -44,6 +41,19 @@ public:
|
||||
return reinterpret_cast<const uint8_t*>(fPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* USE WITH CAUTION.
|
||||
* This call will assert that the refcnt is 1, as a precaution against modifying the
|
||||
* contents when another client/thread has access to the data.
|
||||
*/
|
||||
void* writable_data() {
|
||||
if (fSize) {
|
||||
// only assert we're unique if we're not empty
|
||||
SkASSERT(this->unique());
|
||||
}
|
||||
return fPtr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to copy a range of the data into a caller-provided buffer.
|
||||
* Returns the actual number of bytes copied, after clamping offset and
|
||||
@@ -60,15 +70,21 @@ public:
|
||||
|
||||
/**
|
||||
* Function that, if provided, will be called when the SkData goes out
|
||||
* of scope, allowing for custom allocation/freeing of the data.
|
||||
* of scope, allowing for custom allocation/freeing of the data's contents.
|
||||
*/
|
||||
typedef void (*ReleaseProc)(const void* ptr, size_t length, void* context);
|
||||
typedef void (*ReleaseProc)(const void* ptr, void* context);
|
||||
|
||||
/**
|
||||
* Create a new dataref by copying the specified data
|
||||
*/
|
||||
static SkData* NewWithCopy(const void* data, size_t length);
|
||||
|
||||
/**
|
||||
* Create a new data with uninitialized contents. The caller should call writable_data()
|
||||
* to write into the buffer, but this must be done before another ref() is made.
|
||||
*/
|
||||
static SkData* NewUninitialized(size_t length);
|
||||
|
||||
/**
|
||||
* Create a new dataref by copying the specified c-string
|
||||
* (a null-terminated array of bytes). The returned SkData will have size()
|
||||
@@ -78,11 +94,18 @@ public:
|
||||
static SkData* NewWithCString(const char cstr[]);
|
||||
|
||||
/**
|
||||
* Create a new dataref, taking the data ptr as is, and using the
|
||||
* Create a new dataref, taking the ptr as is, and using the
|
||||
* releaseproc to free it. The proc may be NULL.
|
||||
*/
|
||||
static SkData* NewWithProc(const void* data, size_t length,
|
||||
ReleaseProc proc, void* context);
|
||||
static SkData* NewWithProc(const void* ptr, size_t length, ReleaseProc proc, void* context);
|
||||
|
||||
/**
|
||||
* Call this when the data parameter is already const and will outlive the lifetime of the
|
||||
* SkData. Suitable for with const globals.
|
||||
*/
|
||||
static SkData* NewWithoutCopy(const void* data, size_t length) {
|
||||
return NewWithProc(data, length, DummyReleaseProc, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new dataref from a pointer allocated by malloc. The Data object
|
||||
@@ -97,13 +120,13 @@ public:
|
||||
static SkData* NewFromFileName(const char path[]);
|
||||
|
||||
/**
|
||||
* Create a new dataref from a SkFILE.
|
||||
* This does not take ownership of the SkFILE, nor close it.
|
||||
* The caller is free to close the SkFILE at its convenience.
|
||||
* The SkFILE must be open for reading only.
|
||||
* Create a new dataref from a stdio FILE.
|
||||
* This does not take ownership of the FILE, nor close it.
|
||||
* The caller is free to close the FILE at its convenience.
|
||||
* The FILE must be open for reading only.
|
||||
* Returns NULL on failure.
|
||||
*/
|
||||
static SkData* NewFromFILE(SkFILE* f);
|
||||
static SkData* NewFromFILE(FILE* f);
|
||||
|
||||
/**
|
||||
* Create a new dataref from a file descriptor.
|
||||
@@ -114,6 +137,13 @@ public:
|
||||
*/
|
||||
static SkData* NewFromFD(int fd);
|
||||
|
||||
/**
|
||||
* Attempt to read size bytes into a SkData. If the read succeeds, return the data,
|
||||
* else return NULL. Either way the stream's cursor may have been changed as a result
|
||||
* of calling read().
|
||||
*/
|
||||
static SkData* NewFromStream(SkStream*, size_t size);
|
||||
|
||||
/**
|
||||
* Create a new dataref using a subset of the data in the specified
|
||||
* src dataref.
|
||||
@@ -129,16 +159,29 @@ public:
|
||||
private:
|
||||
ReleaseProc fReleaseProc;
|
||||
void* fReleaseProcContext;
|
||||
|
||||
const void* fPtr;
|
||||
void* fPtr;
|
||||
size_t fSize;
|
||||
|
||||
SkData(const void* ptr, size_t size, ReleaseProc, void* context);
|
||||
explicit SkData(size_t size); // inplace new/delete
|
||||
virtual ~SkData();
|
||||
|
||||
|
||||
// Objects of this type are sometimes created in a custom fashion using sk_malloc_throw and
|
||||
// therefore must be sk_freed. We overload new to also call sk_malloc_throw so that memory
|
||||
// can be unconditionally released using sk_free in an overloaded delete. Overloading regular
|
||||
// new means we must also overload placement new.
|
||||
void* operator new(size_t size) { return sk_malloc_throw(size); }
|
||||
void* operator new(size_t, void* p) { return p; }
|
||||
void operator delete(void* p) { sk_free(p); }
|
||||
|
||||
// Called the first time someone calls NewEmpty to initialize the singleton.
|
||||
static SkData* NewEmptyImpl();
|
||||
static void DeleteEmpty(SkData*);
|
||||
friend SkData* sk_new_empty_data();
|
||||
|
||||
// shared internal factory
|
||||
static SkData* PrivateNewWithCopy(const void* srcOrNull, size_t length);
|
||||
|
||||
static void DummyReleaseProc(const void*, void*) {}
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
*/
|
||||
class SK_API SkDataTable : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkDataTable)
|
||||
|
||||
/**
|
||||
* Returns true if the table is empty (i.e. has no entries).
|
||||
*/
|
||||
|
||||
@@ -9,47 +9,31 @@
|
||||
#define SkDevice_DEFINED
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkDeviceProperties.h"
|
||||
#include "SkImageFilter.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
|
||||
class SkBitmap;
|
||||
class SkClipStack;
|
||||
class SkDraw;
|
||||
class SkDrawFilter;
|
||||
struct SkIRect;
|
||||
class SkMatrix;
|
||||
class SkMetaData;
|
||||
class SkRegion;
|
||||
|
||||
class GrRenderTarget;
|
||||
|
||||
class SK_API SkBaseDevice : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkBaseDevice)
|
||||
|
||||
/**
|
||||
* Construct a new device.
|
||||
*/
|
||||
SkBaseDevice();
|
||||
|
||||
/**
|
||||
* Construct a new device.
|
||||
*/
|
||||
SkBaseDevice(const SkDeviceProperties& deviceProperties);
|
||||
|
||||
explicit SkBaseDevice(const SkSurfaceProps&);
|
||||
virtual ~SkBaseDevice();
|
||||
|
||||
SkBaseDevice* createCompatibleDevice(const SkImageInfo&);
|
||||
|
||||
SkMetaData& getMetaData();
|
||||
|
||||
/** Return the image properties of the device. */
|
||||
virtual const SkDeviceProperties& getDeviceProperties() const {
|
||||
//Currently, all the properties are leaky.
|
||||
return fLeakyProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ImageInfo for this device. If the canvas is not backed by pixels
|
||||
* (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType.
|
||||
@@ -67,6 +51,12 @@ public:
|
||||
bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height());
|
||||
}
|
||||
|
||||
SkIRect getGlobalBounds() const {
|
||||
SkIRect bounds;
|
||||
this->getGlobalBounds(&bounds);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
int width() const {
|
||||
return this->imageInfo().width();
|
||||
}
|
||||
@@ -89,7 +79,22 @@ public:
|
||||
|
||||
bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, int y);
|
||||
|
||||
void* accessPixels(SkImageInfo* info, size_t* rowBytes);
|
||||
/**
|
||||
* Try to get write-access to the pixels behind the device. If successful, this returns true
|
||||
* and fills-out the pixmap parameter. On success it also bumps the genID of the underlying
|
||||
* bitmap.
|
||||
*
|
||||
* On failure, returns false and ignores the pixmap parameter.
|
||||
*/
|
||||
bool accessPixels(SkPixmap* pmap);
|
||||
|
||||
/**
|
||||
* Try to get read-only-access to the pixels behind the device. If successful, this returns
|
||||
* true and fills-out the pixmap parameter.
|
||||
*
|
||||
* On failure, returns false and ignores the pixmap parameter.
|
||||
*/
|
||||
bool peekPixels(SkPixmap*);
|
||||
|
||||
/**
|
||||
* Return the device's associated gpu render target, or NULL.
|
||||
@@ -111,7 +116,6 @@ public:
|
||||
*/
|
||||
virtual void onAttachToCanvas(SkCanvas*) {
|
||||
SkASSERT(!fAttachedToCanvas);
|
||||
this->lockPixels();
|
||||
#ifdef SK_DEBUG
|
||||
fAttachedToCanvas = true;
|
||||
#endif
|
||||
@@ -125,30 +129,28 @@ public:
|
||||
*/
|
||||
virtual void onDetachFromCanvas() {
|
||||
SkASSERT(fAttachedToCanvas);
|
||||
this->unlockPixels();
|
||||
#ifdef SK_DEBUG
|
||||
fAttachedToCanvas = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
protected:
|
||||
enum Usage {
|
||||
kGeneral_Usage,
|
||||
kSaveLayer_Usage // <! internal use only
|
||||
enum TileUsage {
|
||||
kPossible_TileUsage, //!< the created device may be drawn tiled
|
||||
kNever_TileUsage, //!< the created device will never be drawn tiled
|
||||
};
|
||||
|
||||
struct TextFlags {
|
||||
uint32_t fFlags; // SkPaint::getFlags()
|
||||
SkPaint::Hinting fHinting;
|
||||
uint32_t fFlags; // SkPaint::getFlags()
|
||||
};
|
||||
|
||||
/**
|
||||
* Device may filter the text flags for drawing text here. If it wants to
|
||||
* make a change to the specified values, it should write them into the
|
||||
* textflags parameter (output) and return true. If the paint is fine as
|
||||
* is, then ignore the textflags parameter and return false.
|
||||
* Returns the text-related flags, possibly modified based on the state of the
|
||||
* device (e.g. support for LCD).
|
||||
*/
|
||||
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) { return false; }
|
||||
uint32_t filterTextFlags(const SkPaint&) const;
|
||||
|
||||
virtual bool onShouldDisableLCD(const SkPaint&) const { return false; }
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -169,14 +171,6 @@ protected:
|
||||
virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
|
||||
const SkClipStack&) {};
|
||||
|
||||
/** Clears the entire device to the specified color (including alpha).
|
||||
* Ignores the clip.
|
||||
*/
|
||||
virtual void clear(SkColor color) = 0;
|
||||
|
||||
SK_ATTR_DEPRECATED("use clear() instead")
|
||||
void eraseColor(SkColor eraseColor) { this->clear(eraseColor); }
|
||||
|
||||
/** These are called inside the per-device-layer loop for each draw call.
|
||||
When these are called, we have already applied any saveLayer operations,
|
||||
and are handling any looping from the paint, and any effects from the
|
||||
@@ -223,7 +217,15 @@ protected:
|
||||
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
|
||||
const SkRect* srcOrNull, const SkRect& dst,
|
||||
const SkPaint& paint,
|
||||
SkCanvas::DrawBitmapRectFlags flags) = 0;
|
||||
SkCanvas::SrcRectConstraint) = 0;
|
||||
virtual void drawBitmapNine(const SkDraw&, const SkBitmap&, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint&);
|
||||
|
||||
virtual void drawImage(const SkDraw&, const SkImage*, SkScalar x, SkScalar y, const SkPaint&);
|
||||
virtual void drawImageRect(const SkDraw&, const SkImage*, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint&, SkCanvas::SrcRectConstraint);
|
||||
virtual void drawImageNine(const SkDraw&, const SkImage*, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint&);
|
||||
|
||||
/**
|
||||
* Does not handle text decoration.
|
||||
@@ -232,22 +234,33 @@ protected:
|
||||
virtual void drawText(const SkDraw&, const void* text, size_t len,
|
||||
SkScalar x, SkScalar y, const SkPaint& paint) = 0;
|
||||
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
|
||||
const SkScalar pos[], SkScalar constY,
|
||||
int scalarsPerPos, const SkPaint& paint) = 0;
|
||||
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint) = 0;
|
||||
const SkScalar pos[], int scalarsPerPos,
|
||||
const SkPoint& offset, const SkPaint& paint) = 0;
|
||||
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
|
||||
const SkPoint verts[], const SkPoint texs[],
|
||||
const SkColor colors[], SkXfermode* xmode,
|
||||
const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint) = 0;
|
||||
// default implementation unrolls the blob runs.
|
||||
virtual void drawTextBlob(const SkDraw&, const SkTextBlob*, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint, SkDrawFilter* drawFilter);
|
||||
// default implementation calls drawVertices
|
||||
virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColor colors[4],
|
||||
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
|
||||
|
||||
// default implementation calls drawPath
|
||||
virtual void drawAtlas(const SkDraw&, const SkImage* atlas, const SkRSXform[], const SkRect[],
|
||||
const SkColor[], int count, SkXfermode::Mode, const SkPaint&);
|
||||
|
||||
/** The SkDevice passed will be an SkDevice which was returned by a call to
|
||||
onCreateDevice on this device with kSaveLayer_Usage.
|
||||
onCreateDevice on this device with kNeverTile_TileExpectation.
|
||||
*/
|
||||
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
|
||||
const SkPaint&) = 0;
|
||||
|
||||
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, const SkPath&,
|
||||
const SkMatrix*, const SkPaint&);
|
||||
|
||||
bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -258,20 +271,6 @@ protected:
|
||||
*/
|
||||
virtual const SkBitmap& onAccessBitmap() = 0;
|
||||
|
||||
/** Called when this device is installed into a Canvas. Balanced by a call
|
||||
to unlockPixels() when the device is removed from a Canvas.
|
||||
*/
|
||||
virtual void lockPixels() {}
|
||||
virtual void unlockPixels() {}
|
||||
|
||||
/**
|
||||
* Returns true if the device allows processing of this imagefilter. If
|
||||
* false is returned, then the filter is ignored. This may happen for
|
||||
* some subclasses that do not support pixel manipulations after drawing
|
||||
* has occurred (e.g. printing). The default implementation returns true.
|
||||
*/
|
||||
virtual bool allowImageFilter(const SkImageFilter*) { return true; }
|
||||
|
||||
/**
|
||||
* Override and return true for filters that the device can handle
|
||||
* intrinsically. Doing so means that SkCanvas will pass-through this
|
||||
@@ -289,17 +288,14 @@ protected:
|
||||
* it just returns false and leaves result and offset unchanged.
|
||||
*/
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
|
||||
const SkImageFilter::Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) {
|
||||
const SkImageFilter::Context&,
|
||||
SkBitmap* /*result*/, SkIPoint* /*offset*/) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
// default impl returns NULL
|
||||
virtual SkSurface* newSurface(const SkImageInfo&);
|
||||
|
||||
// default impl returns NULL
|
||||
virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes);
|
||||
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) { return NULL; }
|
||||
virtual bool onPeekPixels(SkPixmap*) { return false; }
|
||||
|
||||
/**
|
||||
* The caller is responsible for "pre-clipping" the dst. The impl can assume that the dst
|
||||
@@ -317,24 +313,11 @@ protected:
|
||||
*/
|
||||
virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y);
|
||||
|
||||
/**
|
||||
* Default impl returns NULL.
|
||||
*/
|
||||
virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes);
|
||||
virtual bool onAccessPixels(SkPixmap*) { return false; }
|
||||
|
||||
/**
|
||||
* Leaky properties are those which the device should be applying but it isn't.
|
||||
* These properties will be applied by the draw, when and as it can.
|
||||
* If the device does handle a property, that property should be set to the identity value
|
||||
* for that property, effectively making it non-leaky.
|
||||
*/
|
||||
SkDeviceProperties fLeakyProperties;
|
||||
|
||||
/**
|
||||
* PRIVATE / EXPERIMENTAL -- do not call
|
||||
* Construct an acceleration object and attach it to 'picture'
|
||||
*/
|
||||
virtual void EXPERIMENTAL_optimize(const SkPicture* picture);
|
||||
const SkSurfaceProps& surfaceProps() const {
|
||||
return fSurfaceProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* PRIVATE / EXPERIMENTAL -- do not call
|
||||
@@ -346,7 +329,42 @@ protected:
|
||||
* to perform some device-specific warm up tasks and then let SkCanvas
|
||||
* perform the main rendering loop (by return false from here).
|
||||
*/
|
||||
virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture);
|
||||
virtual bool EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const SkMatrix*,
|
||||
const SkPaint*);
|
||||
|
||||
struct CreateInfo {
|
||||
static SkPixelGeometry AdjustGeometry(const SkImageInfo&, TileUsage, SkPixelGeometry);
|
||||
|
||||
// The constructor may change the pixel geometry based on other parameters.
|
||||
CreateInfo(const SkImageInfo& info,
|
||||
TileUsage tileUsage,
|
||||
SkPixelGeometry geo,
|
||||
bool forImageFilter = false)
|
||||
: fInfo(info)
|
||||
, fTileUsage(tileUsage)
|
||||
, fPixelGeometry(AdjustGeometry(info, tileUsage, geo))
|
||||
, fForImageFilter(forImageFilter) {}
|
||||
|
||||
const SkImageInfo fInfo;
|
||||
const TileUsage fTileUsage;
|
||||
const SkPixelGeometry fPixelGeometry;
|
||||
const bool fForImageFilter;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new device based on CreateInfo. If the paint is not null, then it represents a
|
||||
* preview of how the new device will be composed with its creator device (this).
|
||||
*
|
||||
* The subclass may be handed this device in drawDevice(), so it must always return
|
||||
* a device that it knows how to draw, and that it knows how to identify if it is not of the
|
||||
* same subclass (since drawDevice is passed a SkBaseDevice*). If the subclass cannot fulfill
|
||||
* that contract (e.g. PDF cannot support some settings on the paint) it should return NULL,
|
||||
* and the caller may then decide to explicitly create a bitmapdevice, knowing that later
|
||||
* it could not call drawDevice with it (but it could call drawSprite or drawBitmap).
|
||||
*/
|
||||
virtual SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class SkCanvas;
|
||||
@@ -354,8 +372,8 @@ private:
|
||||
friend class SkDraw;
|
||||
friend class SkDrawIter;
|
||||
friend class SkDeviceFilteredPaint;
|
||||
friend class SkDeviceImageFilterProxy;
|
||||
friend class SkDeferredDevice; // for newSurface
|
||||
friend class SkImageFilter::DeviceProxy;
|
||||
friend class SkNoPixelsBitmapDevice;
|
||||
|
||||
friend class SkSurface_Raster;
|
||||
|
||||
@@ -365,21 +383,20 @@ private:
|
||||
// TODO: move to SkBitmapDevice
|
||||
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) {}
|
||||
|
||||
virtual bool forceConservativeRasterClip() const { return false; }
|
||||
|
||||
// just called by SkCanvas when built as a layer
|
||||
void setOrigin(int x, int y) { fOrigin.set(x, y); }
|
||||
// just called by SkCanvas for saveLayer
|
||||
SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&);
|
||||
|
||||
virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Causes any deferred drawing to the device to be completed.
|
||||
*/
|
||||
virtual void flush() {}
|
||||
|
||||
virtual SkImageFilter::Cache* getImageFilterCache() { return NULL; }
|
||||
|
||||
SkIPoint fOrigin;
|
||||
SkMetaData* fMetaData;
|
||||
SkSurfaceProps fSurfaceProps;
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
bool fAttachedToCanvas;
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
#ifndef SkDeviceProperties_DEFINED
|
||||
#define SkDeviceProperties_DEFINED
|
||||
|
||||
//TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and remove this import.
|
||||
#include "SkFontLCDConfig.h"
|
||||
|
||||
struct SkDeviceProperties {
|
||||
struct Geometry {
|
||||
/** The orientation of the pixel specifies the interpretation of the
|
||||
* layout. If the orientation is horizontal, the layout is interpreted as
|
||||
* left to right. It the orientation is vertical, the layout is
|
||||
* interpreted top to bottom (rotated 90deg cw from horizontal).
|
||||
*/
|
||||
enum Orientation {
|
||||
kUnknown_Orientation = 0x0,
|
||||
kKnown_Orientation = 0x2,
|
||||
|
||||
kHorizontal_Orientation = 0x2, //!< this is the default
|
||||
kVertical_Orientation = 0x3,
|
||||
|
||||
kOrientationMask = 0x3,
|
||||
};
|
||||
|
||||
/** The layout of the pixel specifies its subpixel geometry.
|
||||
*
|
||||
* kUnknown_Layout means that the subpixel elements are not spatially
|
||||
* separated in any known or usable fashion.
|
||||
*/
|
||||
enum Layout {
|
||||
kUnknown_Layout = 0x0,
|
||||
kKnown_Layout = 0x8,
|
||||
|
||||
kRGB_Layout = 0x8, //!< this is the default
|
||||
kBGR_Layout = 0xC,
|
||||
|
||||
kLayoutMask = 0xC,
|
||||
};
|
||||
|
||||
Orientation getOrientation() {
|
||||
return static_cast<Orientation>(fGeometry & kOrientationMask);
|
||||
}
|
||||
Layout getLayout() {
|
||||
return static_cast<Layout>(fGeometry & kLayoutMask);
|
||||
}
|
||||
|
||||
bool isOrientationKnown() {
|
||||
return SkToBool(fGeometry & kKnown_Orientation);
|
||||
}
|
||||
bool isLayoutKnown() {
|
||||
return SkToBool(fGeometry & kKnown_Layout);
|
||||
}
|
||||
|
||||
private:
|
||||
//TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and replace these calls with constants.
|
||||
static Orientation fromOldOrientation(SkFontLCDConfig::LCDOrientation orientation) {
|
||||
switch (orientation) {
|
||||
case SkFontLCDConfig::kHorizontal_LCDOrientation: return kHorizontal_Orientation;
|
||||
case SkFontLCDConfig::kVertical_LCDOrientation: return kVertical_Orientation;
|
||||
default: return kUnknown_Orientation;
|
||||
}
|
||||
}
|
||||
static Layout fromOldLayout(SkFontLCDConfig::LCDOrder order) {
|
||||
switch (order) {
|
||||
case SkFontLCDConfig::kRGB_LCDOrder: return kRGB_Layout;
|
||||
case SkFontLCDConfig::kBGR_LCDOrder: return kBGR_Layout;
|
||||
default: return kUnknown_Layout;
|
||||
}
|
||||
}
|
||||
public:
|
||||
static Geometry MakeDefault() {
|
||||
Orientation orientation = fromOldOrientation(SkFontLCDConfig::GetSubpixelOrientation()); //kHorizontal_Orientation
|
||||
Layout layout = fromOldLayout(SkFontLCDConfig::GetSubpixelOrder()); //kRGB_Layout
|
||||
Geometry ret = { SkToU8(orientation | layout) };
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Geometry Make(Orientation orientation, Layout layout) {
|
||||
Geometry ret = { SkToU8(orientation | layout) };
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t fGeometry;
|
||||
};
|
||||
|
||||
static SkDeviceProperties MakeDefault() {
|
||||
SkDeviceProperties ret = { Geometry::MakeDefault(), SK_GAMMA_EXPONENT };
|
||||
return ret;
|
||||
}
|
||||
|
||||
static SkDeviceProperties Make(Geometry geometry, SkScalar gamma) {
|
||||
SkDeviceProperties ret = { geometry, gamma };
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Each pixel of an image will have some number of channels.
|
||||
* Can the layout of those channels be exploited? */
|
||||
Geometry fGeometry;
|
||||
|
||||
/** Represents the color space of the image. This is a woefully inadequate beginning. */
|
||||
SkScalar fGamma;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "SkPicture.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkString.h"
|
||||
#include "SkTime.h"
|
||||
|
||||
class SkCanvas;
|
||||
class SkWStream;
|
||||
@@ -30,56 +32,50 @@ class SkWStream;
|
||||
* c. doc->endPage();
|
||||
* 3. Close the document with doc->close().
|
||||
*/
|
||||
class SkDocument : public SkRefCnt {
|
||||
class SK_API SkDocument : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkDocument)
|
||||
/**
|
||||
* Create a PDF-backed document, writing the results into a SkWStream.
|
||||
*
|
||||
* PDF pages are sized in point units. 1 pt == 1/72 inch == 127/360 mm.
|
||||
*
|
||||
* @param SkWStream* A PDF document will be written to this
|
||||
* stream. The document may write to the stream at
|
||||
* anytime during its lifetime, until either close() is
|
||||
* called or the document is deleted.
|
||||
* @param dpi The DPI (pixels-per-inch) at which features without
|
||||
* native PDF support will be rasterized (e.g. draw image
|
||||
* with perspective, draw text with perspective, ...) A
|
||||
* larger DPI would create a PDF that reflects the
|
||||
* original intent with better fidelity, but it can make
|
||||
* for larger PDF files too, which would use more memory
|
||||
* while rendering, and it would be slower to be processed
|
||||
* or sent online or to printer.
|
||||
* @returns NULL if there is an error, otherwise a newly created
|
||||
* PDF-backed SkDocument.
|
||||
*/
|
||||
static SkDocument* CreatePDF(SkWStream*,
|
||||
SkScalar dpi = SK_ScalarDefaultRasterDPI);
|
||||
|
||||
/**
|
||||
* Create a PDF-backed document, writing the results into a file.
|
||||
* If there is an error trying to create the doc, returns NULL.
|
||||
* encoder sets the DCTEncoder for images, to encode a bitmap
|
||||
* as JPEG (DCT).
|
||||
* rasterDpi - the DPI at which features without native PDF support
|
||||
* will be rasterized (e.g. draw image with perspective,
|
||||
* draw text with perspective, ...)
|
||||
* A larger DPI would create a PDF that reflects the original
|
||||
* intent with better fidelity, but it can make for larger
|
||||
* PDF files too, which would use more memory while rendering,
|
||||
* and it would be slower to be processed or sent online or
|
||||
* to printer.
|
||||
*/
|
||||
static SkDocument* CreatePDF(
|
||||
const char filename[],
|
||||
SkPicture::EncodeBitmap encoder = NULL,
|
||||
SkScalar rasterDpi = SK_ScalarDefaultRasterDPI);
|
||||
static SkDocument* CreatePDF(const char outputFilePath[],
|
||||
SkScalar dpi = SK_ScalarDefaultRasterDPI);
|
||||
|
||||
/**
|
||||
* Create a PDF-backed document, writing the results into a stream.
|
||||
* If there is an error trying to create the doc, returns NULL.
|
||||
*
|
||||
* The document may write to the stream at anytime during its lifetime,
|
||||
* until either close() is called or the document is deleted. Once close()
|
||||
* has been called, and all of the data has been written to the stream,
|
||||
* if there is a Done proc provided, it will be called with the stream.
|
||||
* The proc can delete the stream, or whatever it needs to do.
|
||||
* encoder sets the DCTEncoder for images, to encode a bitmap
|
||||
* as JPEG (DCT).
|
||||
* Done - clean up method intended to allow deletion of the stream.
|
||||
* Its aborted parameter is true if the cleanup is due to an abort
|
||||
* call. It is false otherwise.
|
||||
* rasterDpi - the DPI at which features without native PDF support
|
||||
* will be rasterized (e.g. draw image with perspective,
|
||||
* draw text with perspective, ...)
|
||||
* A larger DPI would create a PDF that reflects the original
|
||||
* intent with better fidelity, but it can make for larger
|
||||
* PDF files too, which would use more memory while rendering,
|
||||
* and it would be slower to be processed or sent online or
|
||||
* to printer. */
|
||||
static SkDocument* CreatePDF(
|
||||
SkWStream*, void (*Done)(SkWStream*,bool aborted) = NULL,
|
||||
SkPicture::EncodeBitmap encoder = NULL,
|
||||
SkScalar rasterDpi = SK_ScalarDefaultRasterDPI);
|
||||
* Create a XPS-backed document, writing the results into the stream.
|
||||
* Returns NULL if XPS is not supported.
|
||||
*/
|
||||
static SkDocument* CreateXPS(SkWStream* stream,
|
||||
SkScalar dpi = SK_ScalarDefaultRasterDPI);
|
||||
|
||||
/**
|
||||
* Create a XPS-backed document, writing the results into a file.
|
||||
* Returns NULL if XPS is not supported.
|
||||
*/
|
||||
static SkDocument* CreateXPS(const char path[],
|
||||
SkScalar dpi = SK_ScalarDefaultRasterDPI);
|
||||
/**
|
||||
* Begin a new page for the document, returning the canvas that will draw
|
||||
* into the page. The document owns this canvas, and it will go out of
|
||||
@@ -110,8 +106,36 @@ public:
|
||||
*/
|
||||
void abort();
|
||||
|
||||
/**
|
||||
* Set the document's metadata, if supported by the document
|
||||
* type. The creationDate and modifiedDate parameters can be
|
||||
* nullptr. For example:
|
||||
*
|
||||
* SkDocument* make_doc(SkWStream* output) {
|
||||
* SkTArray<SkDocument::Attribute> info;
|
||||
* info.emplace_back(SkString("Title"), SkString("..."));
|
||||
* info.emplace_back(SkString("Author"), SkString("..."));
|
||||
* info.emplace_back(SkString("Subject"), SkString("..."));
|
||||
* info.emplace_back(SkString("Keywords"), SkString("..."));
|
||||
* info.emplace_back(SkString("Creator"), SkString("..."));
|
||||
* SkTime::DateTime now;
|
||||
* SkTime::GetDateTime(&now);
|
||||
* SkDocument* doc = SkDocument::CreatePDF(output);
|
||||
* doc->setMetadata(info, &now, &now);
|
||||
* return doc;
|
||||
* }
|
||||
*/
|
||||
struct Attribute {
|
||||
SkString fKey, fValue;
|
||||
Attribute(const SkString& k, const SkString& v) : fKey(k), fValue(v) {}
|
||||
};
|
||||
virtual void setMetadata(const SkTArray<SkDocument::Attribute>&,
|
||||
const SkTime::DateTime* /* creationDate */,
|
||||
const SkTime::DateTime* /* modifiedDate */) {}
|
||||
|
||||
protected:
|
||||
SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted));
|
||||
|
||||
// note: subclasses must call close() in their destructor, as the base class
|
||||
// cannot do this for them.
|
||||
virtual ~SkDocument();
|
||||
@@ -122,6 +146,9 @@ protected:
|
||||
virtual bool onClose(SkWStream*) = 0;
|
||||
virtual void onAbort() = 0;
|
||||
|
||||
// Allows subclasses to write to the stream as pages are written.
|
||||
SkWStream* getStream() { return fStream; }
|
||||
|
||||
enum State {
|
||||
kBetweenPages_State,
|
||||
kInPage_State,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
class SkBitmap;
|
||||
class SkClipStack;
|
||||
class SkBaseDevice;
|
||||
class SkBlitter;
|
||||
class SkMatrix;
|
||||
class SkPath;
|
||||
class SkRegion;
|
||||
@@ -33,7 +34,11 @@ public:
|
||||
void drawPaint(const SkPaint&) const;
|
||||
void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint[],
|
||||
const SkPaint&, bool forceUseDevice = false) const;
|
||||
void drawRect(const SkRect&, const SkPaint&) const;
|
||||
void drawRect(const SkRect& prePaintRect, const SkPaint&, const SkMatrix* paintMatrix,
|
||||
const SkRect* postPaintRect) const;
|
||||
void drawRect(const SkRect& rect, const SkPaint& paint) const {
|
||||
this->drawRect(rect, paint, NULL, NULL);
|
||||
}
|
||||
void drawRRect(const SkRRect&, const SkPaint&) const;
|
||||
/**
|
||||
* To save on mallocs, we allow a flag that tells us that srcPath is
|
||||
@@ -49,19 +54,20 @@ public:
|
||||
this->drawPath(path, paint, prePathMatrix, pathIsMutable, false);
|
||||
}
|
||||
|
||||
void drawPath(const SkPath& path, const SkPaint& paint) const {
|
||||
this->drawPath(path, paint, NULL, false, false);
|
||||
void drawPath(const SkPath& path, const SkPaint& paint,
|
||||
SkBlitter* customBlitter = NULL) const {
|
||||
this->drawPath(path, paint, NULL, false, false, customBlitter);
|
||||
}
|
||||
|
||||
void drawBitmap(const SkBitmap&, const SkMatrix&, const SkPaint&) const;
|
||||
/* If dstOrNull is null, computes a dst by mapping the bitmap's bounds through the matrix. */
|
||||
void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
|
||||
const SkPaint&) const;
|
||||
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
|
||||
void drawText(const char text[], size_t byteLength, SkScalar x,
|
||||
SkScalar y, const SkPaint& paint) const;
|
||||
void drawPosText(const char text[], size_t byteLength,
|
||||
const SkScalar pos[], SkScalar constY,
|
||||
int scalarsPerPosition, const SkPaint& paint) const;
|
||||
void drawTextOnPath(const char text[], size_t byteLength,
|
||||
const SkPath&, const SkMatrix*, const SkPaint&) const;
|
||||
const SkScalar pos[], int scalarsPerPosition,
|
||||
const SkPoint& offset, const SkPaint& paint) const;
|
||||
void drawVertices(SkCanvas::VertexMode mode, int count,
|
||||
const SkPoint vertices[], const SkPoint textures[],
|
||||
const SkColor colors[], SkXfermode* xmode,
|
||||
@@ -74,8 +80,9 @@ public:
|
||||
*
|
||||
* Only device A8 is supported right now.
|
||||
*/
|
||||
void drawPathCoverage(const SkPath& src, const SkPaint& paint) const {
|
||||
this->drawPath(src, paint, NULL, false, true);
|
||||
void drawPathCoverage(const SkPath& src, const SkPaint& paint,
|
||||
SkBlitter* customBlitter = NULL) const {
|
||||
this->drawPath(src, paint, NULL, false, true, customBlitter);
|
||||
}
|
||||
|
||||
/** Helper function that creates a mask from a path and an optional maskfilter.
|
||||
@@ -110,15 +117,16 @@ public:
|
||||
void drawText_asPaths(const char text[], size_t byteLength,
|
||||
SkScalar x, SkScalar y, const SkPaint&) const;
|
||||
void drawPosText_asPaths(const char text[], size_t byteLength,
|
||||
const SkScalar pos[], SkScalar constY,
|
||||
int scalarsPerPosition, const SkPaint&) const;
|
||||
const SkScalar pos[], int scalarsPerPosition,
|
||||
const SkPoint& offset, const SkPaint&) const;
|
||||
|
||||
private:
|
||||
void drawDevMask(const SkMask& mask, const SkPaint&) const;
|
||||
void drawBitmapAsMask(const SkBitmap&, const SkPaint&) const;
|
||||
|
||||
void drawPath(const SkPath&, const SkPaint&, const SkMatrix* preMatrix,
|
||||
bool pathIsMutable, bool drawCoverage) const;
|
||||
bool pathIsMutable, bool drawCoverage,
|
||||
SkBlitter* customBlitter = NULL) const;
|
||||
|
||||
/**
|
||||
* Return the current clip bounds, in local coordinates, with slop to account
|
||||
@@ -132,14 +140,13 @@ private:
|
||||
computeConservativeLocalClipBounds(SkRect* bounds) const;
|
||||
|
||||
public:
|
||||
const SkBitmap* fBitmap; // required
|
||||
SkPixmap fDst;
|
||||
const SkMatrix* fMatrix; // required
|
||||
const SkRegion* fClip; // DEPRECATED
|
||||
const SkRasterClip* fRC; // required
|
||||
|
||||
const SkClipStack* fClipStack; // optional
|
||||
SkBaseDevice* fDevice; // optional
|
||||
SkDrawProcs* fProcs; // optional
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void validate() const;
|
||||
|
||||
@@ -23,8 +23,6 @@ class SkPaint;
|
||||
*/
|
||||
class SK_API SkDrawFilter : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkDrawFilter)
|
||||
|
||||
enum Type {
|
||||
kPaint_Type,
|
||||
kPoint_Type,
|
||||
|
||||
@@ -30,8 +30,6 @@ class SkString;
|
||||
*/
|
||||
class SK_API SkDrawLooper : public SkFlattenable {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkDrawLooper)
|
||||
|
||||
/**
|
||||
* Holds state during a draw. Users call next() until it returns false.
|
||||
*
|
||||
@@ -87,9 +85,8 @@ public:
|
||||
* storage rect, where the storage rect is with the union of the src rect
|
||||
* and the looper's bounding rect.
|
||||
*/
|
||||
virtual bool canComputeFastBounds(const SkPaint& paint) const;
|
||||
virtual void computeFastBounds(const SkPaint& paint,
|
||||
const SkRect& src, SkRect* dst) const;
|
||||
bool canComputeFastBounds(const SkPaint& paint) const;
|
||||
void computeFastBounds(const SkPaint& paint, const SkRect& src, SkRect* dst) const;
|
||||
|
||||
struct BlurShadowRec {
|
||||
SkScalar fSigma;
|
||||
@@ -114,7 +111,6 @@ public:
|
||||
|
||||
protected:
|
||||
SkDrawLooper() {}
|
||||
SkDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
|
||||
private:
|
||||
typedef SkFlattenable INHERITED;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDrawPictureCallback_DEFINED
|
||||
#define SkDrawPictureCallback_DEFINED
|
||||
|
||||
/**
|
||||
* Subclasses of this can be passed to canvas.drawPicture(). During the drawing
|
||||
* of the picture, this callback will periodically be invoked. If its
|
||||
* abortDrawing() returns true, then picture playback will be interrupted.
|
||||
*
|
||||
* The resulting drawing is undefined, as there is no guarantee how often the
|
||||
* callback will be invoked. If the abort happens inside some level of nested
|
||||
* calls to save(), restore will automatically be called to return the state
|
||||
* to the same level it was before the drawPicture call was made.
|
||||
*/
|
||||
class SK_API SkDrawPictureCallback {
|
||||
public:
|
||||
SkDrawPictureCallback() {}
|
||||
virtual ~SkDrawPictureCallback() {}
|
||||
|
||||
virtual bool abortDrawing() = 0;
|
||||
};
|
||||
|
||||
#endif//SkDrawPictureCallback_DEFINED
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDrawable_DEFINED
|
||||
#define SkDrawable_DEFINED
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
class SkCanvas;
|
||||
class SkPicture;
|
||||
struct SkRect;
|
||||
|
||||
/**
|
||||
* Base-class for objects that draw into SkCanvas.
|
||||
*
|
||||
* The object has a generation ID, which is guaranteed to be unique across all drawables. To
|
||||
* allow for clients of the drawable that may want to cache the results, the drawable must
|
||||
* change its generation ID whenever its internal state changes such that it will draw differently.
|
||||
*/
|
||||
class SkDrawable : public SkRefCnt {
|
||||
public:
|
||||
SkDrawable();
|
||||
|
||||
/**
|
||||
* Draws into the specified content. The drawing sequence will be balanced upon return
|
||||
* (i.e. the saveLevel() on the canvas will match what it was when draw() was called,
|
||||
* and the current matrix and clip settings will not be changed.
|
||||
*/
|
||||
void draw(SkCanvas*, const SkMatrix* = NULL);
|
||||
void draw(SkCanvas*, SkScalar x, SkScalar y);
|
||||
|
||||
SkPicture* newPictureSnapshot();
|
||||
|
||||
/**
|
||||
* Return a unique value for this instance. If two calls to this return the same value,
|
||||
* it is presumed that calling the draw() method will render the same thing as well.
|
||||
*
|
||||
* Subclasses that change their state should call notifyDrawingChanged() to ensure that
|
||||
* a new value will be returned the next time it is called.
|
||||
*/
|
||||
uint32_t getGenerationID();
|
||||
|
||||
/**
|
||||
* Return the (conservative) bounds of what the drawable will draw. If the drawable can
|
||||
* change what it draws (e.g. animation or in response to some external change), then this
|
||||
* must return a bounds that is always valid for all possible states.
|
||||
*/
|
||||
SkRect getBounds();
|
||||
|
||||
/**
|
||||
* Calling this invalidates the previous generation ID, and causes a new one to be computed
|
||||
* the next time getGenerationID() is called. Typically this is called by the object itself,
|
||||
* in response to its internal state changing.
|
||||
*/
|
||||
void notifyDrawingChanged();
|
||||
|
||||
protected:
|
||||
virtual SkRect onGetBounds() = 0;
|
||||
virtual void onDraw(SkCanvas*) = 0;
|
||||
|
||||
/**
|
||||
* Default implementation calls onDraw() with a canvas that records into a picture. Subclasses
|
||||
* may override if they have a more efficient way to return a picture for the current state
|
||||
* of their drawable. Note: this picture must draw the same as what would be drawn from
|
||||
* onDraw().
|
||||
*/
|
||||
virtual SkPicture* onNewPictureSnapshot();
|
||||
|
||||
private:
|
||||
int32_t fGenerationID;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDynamicAnnotations_DEFINED
|
||||
#define SkDynamicAnnotations_DEFINED
|
||||
|
||||
// This file contains macros used to send out-of-band signals to dynamic instrumentation systems,
|
||||
// namely thread sanitizer. This is a cut-down version of the full dynamic_annotations library with
|
||||
// only the features used by Skia.
|
||||
|
||||
#if SK_DYNAMIC_ANNOTATIONS_ENABLED
|
||||
|
||||
extern "C" {
|
||||
// TSAN provides these hooks.
|
||||
void AnnotateIgnoreReadsBegin(const char* file, int line);
|
||||
void AnnotateIgnoreReadsEnd(const char* file, int line);
|
||||
void AnnotateIgnoreWritesBegin(const char* file, int line);
|
||||
void AnnotateIgnoreWritesEnd(const char* file, int line);
|
||||
void AnnotateBenignRaceSized(const char* file, int line,
|
||||
const volatile void* addr, long size, const char* desc);
|
||||
} // extern "C"
|
||||
|
||||
// SK_ANNOTATE_UNPROTECTED_READ can wrap any variable read to tell TSAN to ignore that it appears to
|
||||
// be a racy read. This should be used only when we can make an external guarantee that though this
|
||||
// particular read is racy, it is being used as part of a mechanism which is thread safe. Examples:
|
||||
// - the first check in double-checked locking;
|
||||
// - checking if a ref count is equal to 1.
|
||||
// Note that in both these cases, we must still add terrifyingly subtle memory barriers to provide
|
||||
// that overall thread safety guarantee. Using this macro to shut TSAN up without providing such an
|
||||
// external guarantee is pretty much never correct.
|
||||
template <typename T>
|
||||
inline T SK_ANNOTATE_UNPROTECTED_READ(const volatile T& x) {
|
||||
AnnotateIgnoreReadsBegin(__FILE__, __LINE__);
|
||||
T read = x;
|
||||
AnnotateIgnoreReadsEnd(__FILE__, __LINE__);
|
||||
return read;
|
||||
}
|
||||
|
||||
// Like SK_ANNOTATE_UNPROTECTED_READ, but for writes.
|
||||
template <typename T>
|
||||
inline void SK_ANNOTATE_UNPROTECTED_WRITE(T* ptr, const volatile T& val) {
|
||||
AnnotateIgnoreWritesBegin(__FILE__, __LINE__);
|
||||
*ptr = val;
|
||||
AnnotateIgnoreWritesEnd(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// Ignore racy reads and racy writes to this pointer, indefinitely.
|
||||
// If at all possible, use the more precise SK_ANNOTATE_UNPROTECTED_READ.
|
||||
template <typename T>
|
||||
void SK_ANNOTATE_BENIGN_RACE(T* ptr) {
|
||||
AnnotateBenignRaceSized(__FILE__, __LINE__, ptr, sizeof(*ptr), "SK_ANNOTATE_BENIGN_RACE");
|
||||
}
|
||||
|
||||
#else // !SK_DYNAMIC_ANNOTATIONS_ENABLED
|
||||
|
||||
#define SK_ANNOTATE_UNPROTECTED_READ(x) (x)
|
||||
#define SK_ANNOTATE_UNPROTECTED_WRITE(ptr, val) *(ptr) = (val)
|
||||
#define SK_ANNOTATE_BENIGN_RACE(ptr)
|
||||
|
||||
#endif
|
||||
|
||||
// Can be used to wrap values that are intentionally racy, usually small mutable cached values, e.g.
|
||||
// - SkMatrix type mask
|
||||
// - SkPixelRef genIDs
|
||||
template <typename T>
|
||||
class SkTRacy {
|
||||
public:
|
||||
operator const T() const {
|
||||
return SK_ANNOTATE_UNPROTECTED_READ(fVal);
|
||||
}
|
||||
|
||||
SkTRacy& operator=(const T& val) {
|
||||
SK_ANNOTATE_UNPROTECTED_WRITE(&fVal, val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
T fVal;
|
||||
};
|
||||
|
||||
// This is like SkTRacy, but allows you to return the value by reference.
|
||||
// TSAN is better at suppressing SkTRacy than SkTRacyReffable, so use SkTRacy when possible.
|
||||
//
|
||||
// We use this for SkPathRef bounds, which is an SkRect we pass around by reference publically.
|
||||
template <typename T>
|
||||
class SkTRacyReffable {
|
||||
public:
|
||||
SkTRacyReffable() { SK_ANNOTATE_BENIGN_RACE(&fVal); }
|
||||
|
||||
operator const T&() const {
|
||||
return fVal;
|
||||
}
|
||||
|
||||
SkTRacyReffable& operator=(const T& val) {
|
||||
fVal = val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const T* get() const { return &fVal; }
|
||||
T* get() { return &fVal; }
|
||||
|
||||
const T* operator->() const { return &fVal; }
|
||||
T* operator->() { return &fVal; }
|
||||
|
||||
private:
|
||||
T fVal;
|
||||
};
|
||||
|
||||
#endif//SkDynamicAnnotations_DEFINED
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkEndian_DEFINED
|
||||
#define SkEndian_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
/** \file SkEndian.h
|
||||
|
||||
Macros and helper functions for handling 16 and 32 bit values in
|
||||
big and little endian formats.
|
||||
*/
|
||||
|
||||
#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
|
||||
#error "can't have both LENDIAN and BENDIAN defined"
|
||||
#endif
|
||||
|
||||
#if !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
|
||||
#error "need either LENDIAN or BENDIAN defined"
|
||||
#endif
|
||||
|
||||
/** Swap the two bytes in the low 16bits of the parameters.
|
||||
e.g. 0x1234 -> 0x3412
|
||||
*/
|
||||
static inline uint16_t SkEndianSwap16(uint16_t value) {
|
||||
return static_cast<uint16_t>((value >> 8) | (value << 8));
|
||||
}
|
||||
|
||||
template<uint16_t N> struct SkTEndianSwap16 {
|
||||
static const uint16_t value = static_cast<uint16_t>((N >> 8) | ((N & 0xFF) << 8));
|
||||
};
|
||||
|
||||
/** Vector version of SkEndianSwap16(), which swaps the
|
||||
low two bytes of each value in the array.
|
||||
*/
|
||||
static inline void SkEndianSwap16s(uint16_t array[], int count) {
|
||||
SkASSERT(count == 0 || array != NULL);
|
||||
|
||||
while (--count >= 0) {
|
||||
*array = SkEndianSwap16(*array);
|
||||
array += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** Reverse all 4 bytes in a 32bit value.
|
||||
e.g. 0x12345678 -> 0x78563412
|
||||
*/
|
||||
static inline uint32_t SkEndianSwap32(uint32_t value) {
|
||||
return ((value & 0xFF) << 24) |
|
||||
((value & 0xFF00) << 8) |
|
||||
((value & 0xFF0000) >> 8) |
|
||||
(value >> 24);
|
||||
}
|
||||
|
||||
template<uint32_t N> struct SkTEndianSwap32 {
|
||||
static const uint32_t value = ((N & 0xFF) << 24) |
|
||||
((N & 0xFF00) << 8) |
|
||||
((N & 0xFF0000) >> 8) |
|
||||
(N >> 24);
|
||||
};
|
||||
|
||||
/** Vector version of SkEndianSwap32(), which swaps the
|
||||
bytes of each value in the array.
|
||||
*/
|
||||
static inline void SkEndianSwap32s(uint32_t array[], int count) {
|
||||
SkASSERT(count == 0 || array != NULL);
|
||||
|
||||
while (--count >= 0) {
|
||||
*array = SkEndianSwap32(*array);
|
||||
array += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** Reverse all 8 bytes in a 64bit value.
|
||||
e.g. 0x1122334455667788 -> 0x8877665544332211
|
||||
*/
|
||||
static inline uint64_t SkEndianSwap64(uint64_t value) {
|
||||
return (((value & 0x00000000000000FFULL) << (8*7)) |
|
||||
((value & 0x000000000000FF00ULL) << (8*5)) |
|
||||
((value & 0x0000000000FF0000ULL) << (8*3)) |
|
||||
((value & 0x00000000FF000000ULL) << (8*1)) |
|
||||
((value & 0x000000FF00000000ULL) >> (8*1)) |
|
||||
((value & 0x0000FF0000000000ULL) >> (8*3)) |
|
||||
((value & 0x00FF000000000000ULL) >> (8*5)) |
|
||||
((value) >> (8*7)));
|
||||
}
|
||||
template<uint64_t N> struct SkTEndianSwap64 {
|
||||
static const uint64_t value = (((N & 0x00000000000000FFULL) << (8*7)) |
|
||||
((N & 0x000000000000FF00ULL) << (8*5)) |
|
||||
((N & 0x0000000000FF0000ULL) << (8*3)) |
|
||||
((N & 0x00000000FF000000ULL) << (8*1)) |
|
||||
((N & 0x000000FF00000000ULL) >> (8*1)) |
|
||||
((N & 0x0000FF0000000000ULL) >> (8*3)) |
|
||||
((N & 0x00FF000000000000ULL) >> (8*5)) |
|
||||
((N) >> (8*7)));
|
||||
};
|
||||
|
||||
/** Vector version of SkEndianSwap64(), which swaps the
|
||||
bytes of each value in the array.
|
||||
*/
|
||||
static inline void SkEndianSwap64s(uint64_t array[], int count) {
|
||||
SkASSERT(count == 0 || array != NULL);
|
||||
|
||||
while (--count >= 0) {
|
||||
*array = SkEndianSwap64(*array);
|
||||
array += 1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_CPU_LENDIAN
|
||||
#define SkEndian_SwapBE16(n) SkEndianSwap16(n)
|
||||
#define SkEndian_SwapBE32(n) SkEndianSwap32(n)
|
||||
#define SkEndian_SwapBE64(n) SkEndianSwap64(n)
|
||||
#define SkEndian_SwapLE16(n) (n)
|
||||
#define SkEndian_SwapLE32(n) (n)
|
||||
#define SkEndian_SwapLE64(n) (n)
|
||||
|
||||
#define SkTEndian_SwapBE16(n) SkTEndianSwap16<n>::value
|
||||
#define SkTEndian_SwapBE32(n) SkTEndianSwap32<n>::value
|
||||
#define SkTEndian_SwapBE64(n) SkTEndianSwap64<n>::value
|
||||
#define SkTEndian_SwapLE16(n) (n)
|
||||
#define SkTEndian_SwapLE32(n) (n)
|
||||
#define SkTEndian_SwapLE64(n) (n)
|
||||
#else // SK_CPU_BENDIAN
|
||||
#define SkEndian_SwapBE16(n) (n)
|
||||
#define SkEndian_SwapBE32(n) (n)
|
||||
#define SkEndian_SwapBE64(n) (n)
|
||||
#define SkEndian_SwapLE16(n) SkEndianSwap16(n)
|
||||
#define SkEndian_SwapLE32(n) SkEndianSwap32(n)
|
||||
#define SkEndian_SwapLE64(n) SkEndianSwap64(n)
|
||||
|
||||
#define SkTEndian_SwapBE16(n) (n)
|
||||
#define SkTEndian_SwapBE32(n) (n)
|
||||
#define SkTEndian_SwapBE64(n) (n)
|
||||
#define SkTEndian_SwapLE16(n) SkTEndianSwap16<n>::value
|
||||
#define SkTEndian_SwapLE32(n) SkTEndianSwap32<n>::value
|
||||
#define SkTEndian_SwapLE64(n) SkTEndianSwap64<n>::value
|
||||
#endif
|
||||
|
||||
// When a bytestream is embedded in a 32-bit word, how far we need to
|
||||
// shift the word to extract each byte from the low 8 bits by anding with 0xff.
|
||||
#ifdef SK_CPU_LENDIAN
|
||||
#define SkEndian_Byte0Shift 0
|
||||
#define SkEndian_Byte1Shift 8
|
||||
#define SkEndian_Byte2Shift 16
|
||||
#define SkEndian_Byte3Shift 24
|
||||
#else // SK_CPU_BENDIAN
|
||||
#define SkEndian_Byte0Shift 24
|
||||
#define SkEndian_Byte1Shift 16
|
||||
#define SkEndian_Byte2Shift 8
|
||||
#define SkEndian_Byte3Shift 0
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(SK_UINT8_BITFIELD_LENDIAN) && defined(SK_UINT8_BITFIELD_BENDIAN)
|
||||
#error "can't have both bitfield LENDIAN and BENDIAN defined"
|
||||
#endif
|
||||
|
||||
#if !defined(SK_UINT8_BITFIELD_LENDIAN) && !defined(SK_UINT8_BITFIELD_BENDIAN)
|
||||
#ifdef SK_CPU_LENDIAN
|
||||
#define SK_UINT8_BITFIELD_LENDIAN
|
||||
#else
|
||||
#define SK_UINT8_BITFIELD_BENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SK_UINT8_BITFIELD_LENDIAN
|
||||
#define SK_UINT8_BITFIELD(f0, f1, f2, f3, f4, f5, f6, f7) \
|
||||
SK_OT_BYTE f0 : 1; \
|
||||
SK_OT_BYTE f1 : 1; \
|
||||
SK_OT_BYTE f2 : 1; \
|
||||
SK_OT_BYTE f3 : 1; \
|
||||
SK_OT_BYTE f4 : 1; \
|
||||
SK_OT_BYTE f5 : 1; \
|
||||
SK_OT_BYTE f6 : 1; \
|
||||
SK_OT_BYTE f7 : 1;
|
||||
#else
|
||||
#define SK_UINT8_BITFIELD(f0, f1, f2, f3, f4, f5, f6, f7) \
|
||||
SK_OT_BYTE f7 : 1; \
|
||||
SK_OT_BYTE f6 : 1; \
|
||||
SK_OT_BYTE f5 : 1; \
|
||||
SK_OT_BYTE f4 : 1; \
|
||||
SK_OT_BYTE f3 : 1; \
|
||||
SK_OT_BYTE f2 : 1; \
|
||||
SK_OT_BYTE f1 : 1; \
|
||||
SK_OT_BYTE f0 : 1;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFilterQuality_DEFINED
|
||||
#define SkFilterQuality_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
/**
|
||||
* Controls how much filtering to be done when scaling/transforming complex colors
|
||||
* e.g. images
|
||||
*/
|
||||
enum SkFilterQuality {
|
||||
kNone_SkFilterQuality, //!< fastest but lowest quality, typically nearest-neighbor
|
||||
kLow_SkFilterQuality, //!< typically bilerp
|
||||
kMedium_SkFilterQuality, //!< typically bilerp + mipmaps for down-scaling
|
||||
kHigh_SkFilterQuality //!< slowest but highest quality, typically bicubic or better
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@ typedef int32_t SkFixed;
|
||||
#define SK_FixedTanPIOver8 (0x6A0A)
|
||||
#define SK_FixedRoot2Over2 (0xB505)
|
||||
|
||||
#define SkFixedToFloat(x) ((x) * 1.5258789e-5f)
|
||||
#define SkFixedToFloat(x) ((x) * 1.52587890625e-5f)
|
||||
#if 1
|
||||
#define SkFloatToFixed(x) ((SkFixed)((x) * SK_Fixed1))
|
||||
#else
|
||||
@@ -50,7 +50,7 @@ typedef int32_t SkFixed;
|
||||
#define SkFloatToFixed_Check(x) SkFloatToFixed(x)
|
||||
#endif
|
||||
|
||||
#define SkFixedToDouble(x) ((x) * 1.5258789e-5)
|
||||
#define SkFixedToDouble(x) ((x) * 1.52587890625e-5)
|
||||
#define SkDoubleToFixed(x) ((SkFixed)((x) * SK_Fixed1))
|
||||
|
||||
/** Converts an integer to a SkFixed, asserting that the result does not overflow
|
||||
@@ -60,11 +60,15 @@ typedef int32_t SkFixed;
|
||||
inline SkFixed SkIntToFixed(int n)
|
||||
{
|
||||
SkASSERT(n >= -32768 && n <= 32767);
|
||||
return n << 16;
|
||||
// Left shifting a negative value has undefined behavior in C, so we cast to unsigned before
|
||||
// shifting.
|
||||
return (unsigned)n << 16;
|
||||
}
|
||||
#else
|
||||
// force the cast to SkFixed to ensure that the answer is signed (like the debug version)
|
||||
#define SkIntToFixed(n) (SkFixed)((n) << 16)
|
||||
// Left shifting a negative value has undefined behavior in C, so we cast to unsigned before
|
||||
// shifting. Then we force the cast to SkFixed to ensure that the answer is signed (like the
|
||||
// debug version).
|
||||
#define SkIntToFixed(n) (SkFixed)((unsigned)(n) << 16)
|
||||
#endif
|
||||
|
||||
#define SkFixedRoundToInt(x) (((x) + SK_FixedHalf) >> 16)
|
||||
@@ -78,32 +82,23 @@ typedef int32_t SkFixed;
|
||||
#define SkFixedAbs(x) SkAbs32(x)
|
||||
#define SkFixedAve(a, b) (((a) + (b)) >> 1)
|
||||
|
||||
SkFixed SkFixedMul_portable(SkFixed, SkFixed);
|
||||
|
||||
#define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TODO: move fixed sin/cos into SkCosineMapper, as that is the only caller
|
||||
// or rewrite SkCosineMapper to not use it at all
|
||||
|
||||
SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValueOrNull);
|
||||
#define SkFixedSin(radians) SkFixedSinCos(radians, NULL)
|
||||
static inline SkFixed SkFixedCos(SkFixed radians) {
|
||||
SkFixed cosValue;
|
||||
(void)SkFixedSinCos(radians, &cosValue);
|
||||
return cosValue;
|
||||
}
|
||||
// Blink layout tests are baselined to Clang optimizing through undefined behavior in SkDivBits.
|
||||
#if defined(SK_SUPPORT_LEGACY_DIVBITS_UB)
|
||||
#define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
|
||||
#else
|
||||
// TODO(reed): this clamp shouldn't be needed. Use SkToS32().
|
||||
#define SkFixedDiv(numer, denom) \
|
||||
SkTPin<int32_t>(((int64_t)numer << 16) / denom, SK_MinS32, SK_MaxS32)
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Now look for ASM overrides for our portable versions (should consider putting this in its own file)
|
||||
|
||||
#ifdef SkLONGLONG
|
||||
inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b)
|
||||
{
|
||||
return (SkFixed)((int64_t)a * b >> 16);
|
||||
}
|
||||
#define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
|
||||
#endif
|
||||
inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) {
|
||||
return (SkFixed)((int64_t)a * b >> 16);
|
||||
}
|
||||
#define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
|
||||
|
||||
|
||||
#if defined(SK_CPU_ARM32)
|
||||
/* This guy does not handle NaN or other obscurities, but is faster than
|
||||
@@ -146,20 +141,31 @@ static inline SkFixed SkFixedCos(SkFixed radians) {
|
||||
#define SkFloatToFixed(x) SkFloatToFixed_arm(x)
|
||||
#endif
|
||||
|
||||
#ifndef SkFixedMul
|
||||
#define SkFixedMul(x, y) SkFixedMul_portable(x, y)
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef int64_t SkFixed3232; // 32.32
|
||||
|
||||
#define SkIntToFixed3232(x) ((SkFixed3232)(x) << 32)
|
||||
#define SkFixed3232ToInt(x) ((int)((x) >> 32))
|
||||
#define SkFixedToFixed3232(x) ((SkFixed3232)(x) << 16)
|
||||
#define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16))
|
||||
#define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f)))
|
||||
|
||||
#define SkScalarToFixed3232(x) SkFloatToFixed3232(x)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef int64_t SkFixed48;
|
||||
// 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so
|
||||
// we don't overflow along the way
|
||||
typedef int64_t Sk48Dot16;
|
||||
|
||||
#define SkIntToFixed48(x) ((SkFixed48)(x) << 48)
|
||||
#define SkFixed48ToInt(x) ((int)((x) >> 48))
|
||||
#define SkFixedToFixed48(x) ((SkFixed48)(x) << 32)
|
||||
#define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32))
|
||||
#define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.0f)))
|
||||
#define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16)
|
||||
|
||||
#define SkScalarToFixed48(x) SkFloatToFixed48(x)
|
||||
static inline float Sk48Dot16ToScalar(Sk48Dot16 x) {
|
||||
return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16))
|
||||
}
|
||||
#define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16)))
|
||||
|
||||
#define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@@ -6,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkFlattenable_DEFINED
|
||||
#define SkFlattenable_DEFINED
|
||||
|
||||
@@ -15,9 +13,26 @@
|
||||
class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
|
||||
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
||||
SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
|
||||
flattenable::GetFlattenableType());
|
||||
class SkPrivateEffectInitializer;
|
||||
|
||||
/*
|
||||
* Flattening is straight-forward:
|
||||
* 1. call getFactory() so we have a function-ptr to recreate the subclass
|
||||
* 2. call flatten(buffer) to write out enough data for the factory to read
|
||||
*
|
||||
* Unflattening is easy for the caller: new_instance = factory(buffer)
|
||||
*
|
||||
* The complexity of supporting this is as follows.
|
||||
*
|
||||
* If your subclass wants to control unflattening, use this macro in your declaration:
|
||||
* SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS
|
||||
* This will provide a getFactory(), and require that the subclass implements CreateProc.
|
||||
*
|
||||
* For older buffers (before the DEEPFLATTENING change, the macros below declare
|
||||
* a thin factory DeepCreateProc. It checks the version of the buffer, and if it is pre-deep,
|
||||
* then it calls through to a (usually protected) constructor, passing the buffer.
|
||||
* If the buffer is newer, then it directly calls the "real" factory: CreateProc.
|
||||
*/
|
||||
|
||||
#define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables();
|
||||
|
||||
@@ -27,14 +42,16 @@ class SkWriteBuffer;
|
||||
#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
|
||||
}
|
||||
|
||||
#define SK_DECLARE_UNFLATTENABLE_OBJECT() \
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
|
||||
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
||||
SkFlattenable::Register(#flattenable, flattenable::CreateProc, \
|
||||
flattenable::GetFlattenableType());
|
||||
|
||||
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \
|
||||
static SkFlattenable* CreateProc(SkReadBuffer& buffer) { \
|
||||
return SkNEW_ARGS(flattenable, (buffer)); \
|
||||
}
|
||||
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
||||
private: \
|
||||
static SkFlattenable* CreateProc(SkReadBuffer&); \
|
||||
friend class ::SkPrivateEffectInitializer; \
|
||||
public: \
|
||||
Factory getFactory() const override { return CreateProc; }
|
||||
|
||||
/** For SkFlattenable derived objects with a valid type
|
||||
This macro should only be used in base class objects in core
|
||||
@@ -65,8 +82,6 @@ public:
|
||||
kSkXfermode_Type,
|
||||
};
|
||||
|
||||
SK_DECLARE_INST_COUNT(SkFlattenable)
|
||||
|
||||
typedef SkFlattenable* (*Factory)(SkReadBuffer&);
|
||||
|
||||
SkFlattenable() {}
|
||||
@@ -87,21 +102,11 @@ public:
|
||||
|
||||
static void Register(const char name[], Factory, Type);
|
||||
|
||||
class Registrar {
|
||||
public:
|
||||
Registrar(const char name[], Factory factory, Type type) {
|
||||
SkFlattenable::Register(name, factory, type);
|
||||
}
|
||||
};
|
||||
|
||||
/** Override this to write data specific to your subclass into the buffer,
|
||||
being sure to call your super-class' version first. This data will later
|
||||
be passed to your Factory function, returned by getFactory().
|
||||
/**
|
||||
* Override this if your subclass needs to record data that it will need to recreate itself
|
||||
* from its CreateProc (returned by getFactory()).
|
||||
*/
|
||||
virtual void flatten(SkWriteBuffer&) const;
|
||||
|
||||
protected:
|
||||
SkFlattenable(SkReadBuffer&) {}
|
||||
virtual void flatten(SkWriteBuffer&) const {}
|
||||
|
||||
private:
|
||||
static void InitializeFlattenablesIfNeeded();
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// Temporary shim to keep a couple dependencies working in Chromium.
|
||||
#ifndef SkFlattenableBuffers_DEFINED
|
||||
#define SkFlattenableBuffers_DEFINED
|
||||
|
||||
#include "SkReadBuffer.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
typedef SkReadBuffer SkFlattenableReadBuffer;
|
||||
|
||||
#endif//SkFlattenableBuffers_DEFINED
|
||||
@@ -1,133 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2008 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkFloatBits_DEFINED
|
||||
#define SkFloatBits_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
/** Convert a sign-bit int (i.e. float interpreted as int) into a 2s compliement
|
||||
int. This also converts -0 (0x80000000) to 0. Doing this to a float allows
|
||||
it to be compared using normal C operators (<, <=, etc.)
|
||||
*/
|
||||
static inline int32_t SkSignBitTo2sCompliment(int32_t x) {
|
||||
if (x < 0) {
|
||||
x &= 0x7FFFFFFF;
|
||||
x = -x;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/** Convert a 2s compliment int to a sign-bit (i.e. int interpreted as float).
|
||||
This undoes the result of SkSignBitTo2sCompliment().
|
||||
*/
|
||||
static inline int32_t Sk2sComplimentToSignBit(int32_t x) {
|
||||
int sign = x >> 31;
|
||||
// make x positive
|
||||
x = (x ^ sign) - sign;
|
||||
// set the sign bit as needed
|
||||
x |= sign << 31;
|
||||
return x;
|
||||
}
|
||||
|
||||
/** Given the bit representation of a float, return its value cast to an int.
|
||||
If the value is out of range, or NaN, return return +/- SK_MaxS32
|
||||
*/
|
||||
int32_t SkFloatBits_toIntCast(int32_t floatBits);
|
||||
|
||||
/** Given the bit representation of a float, return its floor as an int.
|
||||
If the value is out of range, or NaN, return return +/- SK_MaxS32
|
||||
*/
|
||||
SK_API int32_t SkFloatBits_toIntFloor(int32_t floatBits);
|
||||
|
||||
/** Given the bit representation of a float, return it rounded to an int.
|
||||
If the value is out of range, or NaN, return return +/- SK_MaxS32
|
||||
*/
|
||||
SK_API int32_t SkFloatBits_toIntRound(int32_t floatBits);
|
||||
|
||||
/** Given the bit representation of a float, return its ceiling as an int.
|
||||
If the value is out of range, or NaN, return return +/- SK_MaxS32
|
||||
*/
|
||||
SK_API int32_t SkFloatBits_toIntCeil(int32_t floatBits);
|
||||
|
||||
|
||||
union SkFloatIntUnion {
|
||||
float fFloat;
|
||||
int32_t fSignBitInt;
|
||||
};
|
||||
|
||||
// Helper to see a float as its bit pattern (w/o aliasing warnings)
|
||||
static inline int32_t SkFloat2Bits(float x) {
|
||||
SkFloatIntUnion data;
|
||||
data.fFloat = x;
|
||||
return data.fSignBitInt;
|
||||
}
|
||||
|
||||
// Helper to see a bit pattern as a float (w/o aliasing warnings)
|
||||
static inline float SkBits2Float(int32_t floatAsBits) {
|
||||
SkFloatIntUnion data;
|
||||
data.fSignBitInt = floatAsBits;
|
||||
return data.fFloat;
|
||||
}
|
||||
|
||||
/** Return the float as a 2s compliment int. Just to be used to compare floats
|
||||
to each other or against positive float-bit-constants (like 0). This does
|
||||
not return the int equivalent of the float, just something cheaper for
|
||||
compares-only.
|
||||
*/
|
||||
static inline int32_t SkFloatAs2sCompliment(float x) {
|
||||
return SkSignBitTo2sCompliment(SkFloat2Bits(x));
|
||||
}
|
||||
|
||||
/** Return the 2s compliment int as a float. This undos the result of
|
||||
SkFloatAs2sCompliment
|
||||
*/
|
||||
static inline float Sk2sComplimentAsFloat(int32_t x) {
|
||||
return SkBits2Float(Sk2sComplimentToSignBit(x));
|
||||
}
|
||||
|
||||
/** Return x cast to a float (i.e. (float)x)
|
||||
*/
|
||||
float SkIntToFloatCast(int x);
|
||||
float SkIntToFloatCast_NoOverflowCheck(int x);
|
||||
|
||||
/** Return the float cast to an int.
|
||||
If the value is out of range, or NaN, return +/- SK_MaxS32
|
||||
*/
|
||||
static inline int32_t SkFloatToIntCast(float x) {
|
||||
return SkFloatBits_toIntCast(SkFloat2Bits(x));
|
||||
}
|
||||
|
||||
/** Return the floor of the float as an int.
|
||||
If the value is out of range, or NaN, return +/- SK_MaxS32
|
||||
*/
|
||||
static inline int32_t SkFloatToIntFloor(float x) {
|
||||
return SkFloatBits_toIntFloor(SkFloat2Bits(x));
|
||||
}
|
||||
|
||||
/** Return the float rounded to an int.
|
||||
If the value is out of range, or NaN, return +/- SK_MaxS32
|
||||
*/
|
||||
static inline int32_t SkFloatToIntRound(float x) {
|
||||
return SkFloatBits_toIntRound(SkFloat2Bits(x));
|
||||
}
|
||||
|
||||
/** Return the ceiling of the float as an int.
|
||||
If the value is out of range, or NaN, return +/- SK_MaxS32
|
||||
*/
|
||||
static inline int32_t SkFloatToIntCeil(float x) {
|
||||
return SkFloatBits_toIntCeil(SkFloat2Bits(x));
|
||||
}
|
||||
|
||||
// Scalar wrappers for float-bit routines
|
||||
|
||||
#define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x)
|
||||
#define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x)
|
||||
|
||||
#endif
|
||||
@@ -1,161 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkFloatingPoint_DEFINED
|
||||
#define SkFloatingPoint_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
// For _POSIX_VERSION
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "SkFloatBits.h"
|
||||
|
||||
// C++98 cmath std::pow seems to be the earliest portable way to get float pow.
|
||||
// However, on Linux including cmath undefines isfinite.
|
||||
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14608
|
||||
static inline float sk_float_pow(float base, float exp) {
|
||||
return powf(base, exp);
|
||||
}
|
||||
|
||||
static inline float sk_float_copysign(float x, float y) {
|
||||
// c++11 contains a 'float copysign(float, float)' function in <cmath>.
|
||||
#if (!defined(_MSC_VER) && __cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||
return copysign(x, y);
|
||||
|
||||
// Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6.
|
||||
#elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
|
||||
return copysignf(x, y);
|
||||
|
||||
// Visual studio prior to 13 only has 'double _copysign(double, double)'.
|
||||
#elif defined(_MSC_VER)
|
||||
return (float)_copysign(x, y);
|
||||
|
||||
// Otherwise convert to bits and extract sign.
|
||||
#else
|
||||
int32_t xbits = SkFloat2Bits(x);
|
||||
int32_t ybits = SkFloat2Bits(y);
|
||||
return SkBits2Float((xbits & 0x7FFFFFFF) | (ybits & 0x80000000));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_WINCE
|
||||
#define sk_float_sqrt(x) (float)::sqrt(x)
|
||||
#define sk_float_sin(x) (float)::sin(x)
|
||||
#define sk_float_cos(x) (float)::cos(x)
|
||||
#define sk_float_tan(x) (float)::tan(x)
|
||||
#define sk_float_acos(x) (float)::acos(x)
|
||||
#define sk_float_asin(x) (float)::asin(x)
|
||||
#define sk_float_atan2(y,x) (float)::atan2(y,x)
|
||||
#define sk_float_abs(x) (float)::fabs(x)
|
||||
#define sk_float_mod(x,y) (float)::fmod(x,y)
|
||||
#define sk_float_exp(x) (float)::exp(x)
|
||||
#define sk_float_log(x) (float)::log(x)
|
||||
#define sk_float_floor(x) (float)::floor(x)
|
||||
#define sk_float_ceil(x) (float)::ceil(x)
|
||||
#else
|
||||
#define sk_float_sqrt(x) sqrtf(x)
|
||||
#define sk_float_sin(x) sinf(x)
|
||||
#define sk_float_cos(x) cosf(x)
|
||||
#define sk_float_tan(x) tanf(x)
|
||||
#define sk_float_floor(x) floorf(x)
|
||||
#define sk_float_ceil(x) ceilf(x)
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
#define sk_float_acos(x) static_cast<float>(acos(x))
|
||||
#define sk_float_asin(x) static_cast<float>(asin(x))
|
||||
#else
|
||||
#define sk_float_acos(x) acosf(x)
|
||||
#define sk_float_asin(x) asinf(x)
|
||||
#endif
|
||||
#define sk_float_atan2(y,x) atan2f(y,x)
|
||||
#define sk_float_abs(x) fabsf(x)
|
||||
#define sk_float_mod(x,y) fmodf(x,y)
|
||||
#define sk_float_exp(x) expf(x)
|
||||
#define sk_float_log(x) logf(x)
|
||||
#endif
|
||||
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
#define sk_float_isfinite(x) _finite(x)
|
||||
#define sk_float_isnan(x) _isnan(x)
|
||||
static inline int sk_float_isinf(float x) {
|
||||
int32_t bits = SkFloat2Bits(x);
|
||||
return (bits << 1) == (0xFF << 24);
|
||||
}
|
||||
#else
|
||||
#define sk_float_isfinite(x) isfinite(x)
|
||||
#define sk_float_isnan(x) isnan(x)
|
||||
#define sk_float_isinf(x) isinf(x)
|
||||
#endif
|
||||
|
||||
#define sk_double_isnan(a) sk_float_isnan(a)
|
||||
|
||||
#ifdef SK_USE_FLOATBITS
|
||||
#define sk_float_floor2int(x) SkFloatToIntFloor(x)
|
||||
#define sk_float_round2int(x) SkFloatToIntRound(x)
|
||||
#define sk_float_ceil2int(x) SkFloatToIntCeil(x)
|
||||
#else
|
||||
#define sk_float_floor2int(x) (int)sk_float_floor(x)
|
||||
#define sk_float_round2int(x) (int)sk_float_floor((x) + 0.5f)
|
||||
#define sk_float_ceil2int(x) (int)sk_float_ceil(x)
|
||||
#endif
|
||||
|
||||
extern const uint32_t gIEEENotANumber;
|
||||
extern const uint32_t gIEEEInfinity;
|
||||
extern const uint32_t gIEEENegativeInfinity;
|
||||
|
||||
#define SK_FloatNaN (*SkTCast<const float*>(&gIEEENotANumber))
|
||||
#define SK_FloatInfinity (*SkTCast<const float*>(&gIEEEInfinity))
|
||||
#define SK_FloatNegativeInfinity (*SkTCast<const float*>(&gIEEENegativeInfinity))
|
||||
|
||||
#if defined(__SSE__)
|
||||
#include <xmmintrin.h>
|
||||
#elif defined(__ARM_NEON__)
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
// Fast, approximate inverse square root.
|
||||
// Compare to name-brand "1.0f / sk_float_sqrt(x)". Should be around 10x faster on SSE, 2x on NEON.
|
||||
static inline float sk_float_rsqrt(const float x) {
|
||||
// We want all this inlined, so we'll inline SIMD and just take the hit when we don't know we've got
|
||||
// it at compile time. This is going to be too fast to productively hide behind a function pointer.
|
||||
//
|
||||
// We do one step of Newton's method to refine the estimates in the NEON and null paths. No
|
||||
// refinement is faster, but very innacurate. Two steps is more accurate, but slower than 1/sqrt.
|
||||
#if defined(__SSE__)
|
||||
float result;
|
||||
_mm_store_ss(&result, _mm_rsqrt_ss(_mm_set_ss(x)));
|
||||
return result;
|
||||
#elif defined(__ARM_NEON__)
|
||||
// Get initial estimate.
|
||||
const float32x2_t xx = vdup_n_f32(x); // Clever readers will note we're doing everything 2x.
|
||||
float32x2_t estimate = vrsqrte_f32(xx);
|
||||
|
||||
// One step of Newton's method to refine.
|
||||
const float32x2_t estimate_sq = vmul_f32(estimate, estimate);
|
||||
estimate = vmul_f32(estimate, vrsqrts_f32(xx, estimate_sq));
|
||||
return vget_lane_f32(estimate, 0); // 1 will work fine too; the answer's in both places.
|
||||
#else
|
||||
// Get initial estimate.
|
||||
int i = *SkTCast<int*>(&x);
|
||||
i = 0x5f3759df - (i>>1);
|
||||
float estimate = *SkTCast<float*>(&i);
|
||||
|
||||
// One step of Newton's method to refine.
|
||||
const float estimate_sq = estimate*estimate;
|
||||
estimate *= (1.5f-0.5f*x*estimate_sq);
|
||||
return estimate;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -75,8 +75,8 @@ public:
|
||||
enum Flags {
|
||||
/**
|
||||
* Use the system's automatic hinting mechanism to hint the typeface.
|
||||
* If both bytecode and auto hints are specified, attempt to use the bytecodes first.
|
||||
* If that fails (e.g. there are no codes), then attempt to autohint.
|
||||
* This is a last resort hinting method applied only if other hinting methods do not apply.
|
||||
* TODO: where to put auto-normal vs auto-light?
|
||||
*/
|
||||
kEnableAutoHints_Flag = 1 << 0,
|
||||
|
||||
@@ -87,6 +87,13 @@ public:
|
||||
*/
|
||||
kEnableByteCodeHints_Flag = 1 << 1,
|
||||
|
||||
/**
|
||||
* If the typeface contains explicit bitmaps for hinting, use them.
|
||||
* If both bytecode and auto hints are also specified, attempt to use the bitmaps first;
|
||||
* if that fails (e.g. there are no bitmaps), then attempt to bytecode or autohint.
|
||||
*/
|
||||
kEmbeddedBitmaps_Flag = 1 << 2,
|
||||
|
||||
/**
|
||||
* Use rounded metric values (e.g. advance).
|
||||
* If either auto or bytecode hinting was used, apply those results to the metrics of the
|
||||
@@ -96,10 +103,9 @@ public:
|
||||
* This applies to calls that return metrics (e.g. measureText) and to drawing the glyphs
|
||||
* (see SkCanvas drawText and drawPosText).
|
||||
*/
|
||||
kUseNonlinearMetrics_Flag = 1 << 2,
|
||||
kUseNonlinearMetrics_Flag = 1 << 3,
|
||||
|
||||
kVertical_Flag = 1 << 3,
|
||||
kEmbeddedBitmaps_Flag = 1 << 4,
|
||||
kVertical_Flag = 1 << 4,
|
||||
kGenA8FromLCD_Flag = 1 << 5,
|
||||
kEmbolden_Flag = 1 << 6,
|
||||
kDevKern_Flag = 1 << 7, // ifdef ANDROID ?
|
||||
|
||||
@@ -90,42 +90,6 @@ public:
|
||||
static void SetSubpixelOrder(LCDOrder order);
|
||||
/** @deprecated get from Device. */
|
||||
static LCDOrder GetSubpixelOrder();
|
||||
|
||||
private:
|
||||
/** Return a new, closest matching typeface given either an existing family
|
||||
(specified by a typeface in that family) or by a familyName and a
|
||||
requested style.
|
||||
1) If familyFace is null, use familyName.
|
||||
2) If familyName is null, use data (UTF-16 to cover).
|
||||
3) If all are null, return the default font that best matches style
|
||||
*/
|
||||
static SkTypeface* CreateTypeface(const SkTypeface* familyFace,
|
||||
const char familyName[],
|
||||
SkTypeface::Style style);
|
||||
|
||||
/** Return a new typeface given the data buffer. If the data does not
|
||||
represent a valid font, returns null.
|
||||
|
||||
If a typeface instance is returned, the caller is responsible for
|
||||
calling unref() on the typeface when they are finished with it.
|
||||
|
||||
The returned typeface may or may not have called ref() on the stream
|
||||
parameter. If the typeface has not called ref(), then it may have made
|
||||
a copy of the releveant data. In either case, the caller is still
|
||||
responsible for its refcnt ownership of the stream.
|
||||
*/
|
||||
static SkTypeface* CreateTypefaceFromStream(SkStream*);
|
||||
|
||||
/** Return a new typeface from the specified file path. If the file does not
|
||||
represent a valid font, this returns null. If a typeface is returned,
|
||||
the caller is responsible for calling unref() when it is no longer used.
|
||||
*/
|
||||
static SkTypeface* CreateTypefaceFromFile(const char path[]);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
friend class SkScalerContext;
|
||||
friend class SkTypeface;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontStyle_DEFINED
|
||||
#define SkFontStyle_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
class SK_API SkFontStyle {
|
||||
public:
|
||||
enum Weight {
|
||||
kThin_Weight = 100,
|
||||
kExtraLight_Weight = 200,
|
||||
kLight_Weight = 300,
|
||||
kNormal_Weight = 400,
|
||||
kMedium_Weight = 500,
|
||||
kSemiBold_Weight = 600,
|
||||
kBold_Weight = 700,
|
||||
kExtraBold_Weight = 800,
|
||||
kBlack_Weight = 900
|
||||
};
|
||||
|
||||
enum Width {
|
||||
kUltraCondensed_Width = 1,
|
||||
kExtraCondensed_Width = 2,
|
||||
kCondensed_Width = 3,
|
||||
kSemiCondensed_Width = 4,
|
||||
kNormal_Width = 5,
|
||||
kSemiExpanded_Width = 6,
|
||||
kExpanded_Width = 7,
|
||||
kExtraExpanded_Width = 8,
|
||||
kUltaExpanded_Width = 9
|
||||
};
|
||||
|
||||
enum Slant {
|
||||
kUpright_Slant,
|
||||
kItalic_Slant,
|
||||
};
|
||||
|
||||
SkFontStyle();
|
||||
SkFontStyle(int weight, int width, Slant);
|
||||
/** oldStyle means the style-bits in SkTypeface::Style: bold=1, italic=2 */
|
||||
explicit SkFontStyle(unsigned oldStyle);
|
||||
|
||||
bool operator==(const SkFontStyle& rhs) const {
|
||||
return fUnion.fU32 == rhs.fUnion.fU32;
|
||||
}
|
||||
|
||||
int weight() const { return fUnion.fR.fWeight; }
|
||||
int width() const { return fUnion.fR.fWidth; }
|
||||
Slant slant() const { return (Slant)fUnion.fR.fSlant; }
|
||||
|
||||
bool isItalic() const {
|
||||
return kItalic_Slant == fUnion.fR.fSlant;
|
||||
}
|
||||
|
||||
private:
|
||||
union {
|
||||
struct {
|
||||
uint16_t fWeight; // 100 .. 900
|
||||
uint8_t fWidth; // 1 .. 9
|
||||
uint8_t fSlant; // 0 .. 2
|
||||
} fR;
|
||||
uint32_t fU32;
|
||||
} fUnion;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@@ -6,25 +5,26 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkGraphics_DEFINED
|
||||
#define SkGraphics_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
class SkData;
|
||||
class SkImageGenerator;
|
||||
class SkTraceMemoryDump;
|
||||
|
||||
class SK_API SkGraphics {
|
||||
public:
|
||||
/**
|
||||
* Call this at process initialization time if your environment does not
|
||||
* permit static global initializers that execute code. Note that
|
||||
* Init() is not thread-safe.
|
||||
* permit static global initializers that execute code.
|
||||
* Init() is thread-safe and idempotent.
|
||||
*/
|
||||
static void Init();
|
||||
|
||||
/**
|
||||
* Call this to release any memory held privately, such as the font cache.
|
||||
*/
|
||||
static void Term();
|
||||
// We're in the middle of cleaning this up.
|
||||
static void Term() {}
|
||||
|
||||
/**
|
||||
* Return the version numbers for the library. If the parameter is not
|
||||
@@ -80,46 +80,44 @@ public:
|
||||
static void PurgeFontCache();
|
||||
|
||||
/**
|
||||
* Scaling bitmaps with the SkPaint::kHigh_FilterLevel setting is
|
||||
* Scaling bitmaps with the kHigh_SkFilterQuality setting is
|
||||
* expensive, so the result is saved in the global Scaled Image
|
||||
* Cache.
|
||||
*
|
||||
* This function returns the memory usage of the Scaled Image Cache.
|
||||
*/
|
||||
static size_t GetImageCacheTotalBytesUsed();
|
||||
/**
|
||||
* These functions get/set the memory usage limit for the Scaled
|
||||
* Image Cache. Bitmaps are purged from the cache when the
|
||||
* memory useage exceeds this limit.
|
||||
*/
|
||||
static size_t GetImageCacheTotalByteLimit();
|
||||
static size_t SetImageCacheTotalByteLimit(size_t newLimit);
|
||||
|
||||
// DEPRECATED
|
||||
static size_t GetImageCacheBytesUsed() {
|
||||
return GetImageCacheTotalBytesUsed();
|
||||
}
|
||||
// DEPRECATED
|
||||
static size_t GetImageCacheByteLimit() {
|
||||
return GetImageCacheTotalByteLimit();
|
||||
}
|
||||
// DEPRECATED
|
||||
static size_t SetImageCacheByteLimit(size_t newLimit) {
|
||||
return SetImageCacheTotalByteLimit(newLimit);
|
||||
}
|
||||
static size_t GetResourceCacheTotalBytesUsed();
|
||||
|
||||
/**
|
||||
* Scaling bitmaps with the SkPaint::kHigh_FilterLevel setting is
|
||||
* expensive, so the result is saved in the global Scaled Image
|
||||
* Cache. When the resulting bitmap is too large, this can
|
||||
* overload the cache. If the ImageCacheSingleAllocationByteLimit
|
||||
* is set to a non-zero number, and the resulting bitmap would be
|
||||
* larger than that value, the bitmap scaling algorithm falls
|
||||
* back onto a cheaper algorithm and does not cache the result.
|
||||
* Zero is the default value.
|
||||
* These functions get/set the memory usage limit for the resource cache, used for temporary
|
||||
* bitmaps and other resources. Entries are purged from the cache when the memory useage
|
||||
* exceeds this limit.
|
||||
*/
|
||||
static size_t GetImageCacheSingleAllocationByteLimit();
|
||||
static size_t SetImageCacheSingleAllocationByteLimit(size_t newLimit);
|
||||
static size_t GetResourceCacheTotalByteLimit();
|
||||
static size_t SetResourceCacheTotalByteLimit(size_t newLimit);
|
||||
|
||||
/**
|
||||
* For debugging purposes, this will attempt to purge the resource cache. It
|
||||
* does not change the limit.
|
||||
*/
|
||||
static void PurgeResourceCache();
|
||||
|
||||
/**
|
||||
* When the cachable entry is very lage (e.g. a large scaled bitmap), adding it to the cache
|
||||
* can cause most/all of the existing entries to be purged. To avoid the, the client can set
|
||||
* a limit for a single allocation. If a cacheable entry would have been cached, but its size
|
||||
* exceeds this limit, then we do not attempt to cache it at all.
|
||||
*
|
||||
* Zero is the default value, meaning we always attempt to cache entries.
|
||||
*/
|
||||
static size_t GetResourceCacheSingleAllocationByteLimit();
|
||||
static size_t SetResourceCacheSingleAllocationByteLimit(size_t newLimit);
|
||||
|
||||
/**
|
||||
* Dumps memory usage of caches using the SkTraceMemoryDump interface. See SkTraceMemoryDump
|
||||
* for usage of this method.
|
||||
*/
|
||||
static void DumpMemoryStatistics(SkTraceMemoryDump* dump);
|
||||
|
||||
/**
|
||||
* Applications with command line options may pass optional state, such
|
||||
@@ -151,12 +149,17 @@ public:
|
||||
*/
|
||||
static void SetTLSFontCacheLimit(size_t bytes);
|
||||
|
||||
private:
|
||||
/** This is automatically called by SkGraphics::Init(), and must be
|
||||
implemented by the host OS. This allows the host OS to register a callback
|
||||
with the C++ runtime to call SkGraphics::FreeCaches()
|
||||
*/
|
||||
static void InstallNewHandler();
|
||||
typedef SkImageGenerator* (*ImageGeneratorFromEncodedFactory)(SkData*);
|
||||
|
||||
/**
|
||||
* To instantiate images from encoded data, first looks at this runtime function-ptr. If it
|
||||
* exists, it is called to create an SkImageGenerator from SkData. If there is no function-ptr
|
||||
* or there is, but it returns NULL, then skia will call its internal default implementation.
|
||||
*
|
||||
* Returns the previous factory (which could be NULL).
|
||||
*/
|
||||
static ImageGeneratorFromEncodedFactory
|
||||
SetImageGeneratorFromEncodedFactory(ImageGeneratorFromEncodedFactory);
|
||||
};
|
||||
|
||||
class SkAutoGraphics {
|
||||
@@ -164,9 +167,6 @@ public:
|
||||
SkAutoGraphics() {
|
||||
SkGraphics::Init();
|
||||
}
|
||||
~SkAutoGraphics() {
|
||||
SkGraphics::Term();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef SkImage_DEFINED
|
||||
#define SkImage_DEFINED
|
||||
|
||||
#include "SkFilterQuality.h"
|
||||
#include "SkImageInfo.h"
|
||||
#include "SkImageEncoder.h"
|
||||
#include "SkRefCnt.h"
|
||||
@@ -16,7 +17,13 @@
|
||||
|
||||
class SkData;
|
||||
class SkCanvas;
|
||||
class SkColorTable;
|
||||
class SkImageGenerator;
|
||||
class SkPaint;
|
||||
class SkPicture;
|
||||
class SkPixelSerializer;
|
||||
class SkString;
|
||||
class SkSurface;
|
||||
class GrContext;
|
||||
class GrTexture;
|
||||
|
||||
@@ -29,50 +36,128 @@ class GrTexture;
|
||||
* The content of SkImage is always immutable, though the actual storage may
|
||||
* change, if for example that image can be re-created via encoded data or
|
||||
* other means.
|
||||
*
|
||||
* SkImage always has a non-zero dimensions. If there is a request to create a new image, either
|
||||
* directly or via SkSurface, and either of the requested dimensions are zero, then NULL will be
|
||||
* returned.
|
||||
*/
|
||||
class SK_API SkImage : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkImage)
|
||||
|
||||
typedef SkImageInfo Info;
|
||||
typedef void* ReleaseContext;
|
||||
|
||||
static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowBytes);
|
||||
static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowBytes,
|
||||
SkColorTable* ctable = NULL);
|
||||
static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes);
|
||||
static SkImage* NewEncodedData(SkData*);
|
||||
|
||||
typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext);
|
||||
|
||||
/**
|
||||
* GrTexture is a more logical parameter for this factory, but its
|
||||
* interactions with scratch cache still has issues, so for now we take
|
||||
* SkBitmap instead. This will be changed in the future. skbug.com/1449
|
||||
* Return a new Image referencing the specified pixels. These must remain valid and unchanged
|
||||
* until the specified release-proc is called, indicating that Skia no longer has a reference
|
||||
* to the pixels.
|
||||
*
|
||||
* Returns NULL if the requested Info is unsupported.
|
||||
*/
|
||||
static SkImage* NewTexture(const SkBitmap&);
|
||||
static SkImage* NewFromRaster(const Info&, const void* pixels, size_t rowBytes,
|
||||
RasterReleaseProc, ReleaseContext);
|
||||
|
||||
/**
|
||||
* Construct a new image from the specified bitmap. If the bitmap is marked immutable, and
|
||||
* its pixel memory is shareable, it may be shared instead of copied.
|
||||
*/
|
||||
static SkImage* NewFromBitmap(const SkBitmap&);
|
||||
|
||||
/**
|
||||
* Construct a new SkImage based on the given ImageGenerator.
|
||||
* This function will always take ownership of the passed
|
||||
* ImageGenerator. Returns NULL on error.
|
||||
*
|
||||
* If a subset is specified, it must be contained within the generator's bounds.
|
||||
*/
|
||||
static SkImage* NewFromGenerator(SkImageGenerator*, const SkIRect* subset = NULL);
|
||||
|
||||
/**
|
||||
* Construct a new SkImage based on the specified encoded data. Returns NULL on failure,
|
||||
* which can mean that the format of the encoded data was not recognized/supported.
|
||||
*
|
||||
* If a subset is specified, it must be contained within the encoded data's bounds.
|
||||
*
|
||||
* Regardless of success or failure, the caller is responsible for managing their ownership
|
||||
* of the data.
|
||||
*/
|
||||
static SkImage* NewFromEncoded(SkData* encoded, const SkIRect* subset = NULL);
|
||||
|
||||
/**
|
||||
* Create a new image from the specified descriptor. Note - the caller is responsible for
|
||||
* managing the lifetime of the underlying platform texture.
|
||||
*
|
||||
* Will return NULL if the specified descriptor is unsupported.
|
||||
*/
|
||||
static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc) {
|
||||
return NewFromTexture(ctx, desc, kPremul_SkAlphaType, NULL, NULL);
|
||||
}
|
||||
|
||||
static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& de, SkAlphaType at) {
|
||||
return NewFromTexture(ctx, de, at, NULL, NULL);
|
||||
}
|
||||
|
||||
typedef void (*TextureReleaseProc)(ReleaseContext);
|
||||
|
||||
/**
|
||||
* Create a new image from the specified descriptor. The underlying platform texture must stay
|
||||
* valid and unaltered until the specified release-proc is invoked, indicating that Skia
|
||||
* no longer is holding a reference to it.
|
||||
*
|
||||
* Will return NULL if the specified descriptor is unsupported.
|
||||
*/
|
||||
static SkImage* NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType,
|
||||
TextureReleaseProc, ReleaseContext);
|
||||
|
||||
/**
|
||||
* Create a new image from the specified descriptor. Note - Skia will delete or recycle the
|
||||
* texture when the image is released.
|
||||
*
|
||||
* Will return NULL if the specified descriptor is unsupported.
|
||||
*/
|
||||
static SkImage* NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
|
||||
SkAlphaType = kPremul_SkAlphaType);
|
||||
|
||||
/**
|
||||
* Create a new image by copying the pixels from the specified descriptor. No reference is
|
||||
* kept to the original platform texture.
|
||||
*
|
||||
* Will return NULL if the specified descriptor is unsupported.
|
||||
*/
|
||||
static SkImage* NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&,
|
||||
SkAlphaType = kPremul_SkAlphaType);
|
||||
|
||||
/**
|
||||
* Create a new image by copying the pixels from the specified y, u, v textures. The data
|
||||
* from the textures is immediately ingested into the image and the textures can be modified or
|
||||
* deleted after the function returns. The image will have the dimensions of the y texture.
|
||||
*/
|
||||
static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace,
|
||||
const GrBackendObject yuvTextureHandles[3],
|
||||
const SkISize yuvSizes[3],
|
||||
GrSurfaceOrigin);
|
||||
|
||||
static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions,
|
||||
const SkMatrix*, const SkPaint*);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int width() const { return fWidth; }
|
||||
int height() const { return fHeight; }
|
||||
SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); }
|
||||
SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); }
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
/**
|
||||
* Return the GrTexture that stores the image pixels. Calling getTexture
|
||||
* does not affect the reference count of the GrTexture object.
|
||||
* Will return NULL if the image does not use a texture.
|
||||
*/
|
||||
GrTexture* getTexture();
|
||||
virtual bool isOpaque() const { return false; }
|
||||
|
||||
virtual SkShader* newShader(SkShader::TileMode,
|
||||
SkShader::TileMode,
|
||||
const SkMatrix* localMatrix = NULL) const;
|
||||
|
||||
void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*);
|
||||
|
||||
/**
|
||||
* Draw the image, cropped to the src rect, to the dst rect of a canvas.
|
||||
* If src is larger than the bounds of the image, the rest of the image is
|
||||
* filled with transparent black pixels.
|
||||
*
|
||||
* See SkCanvas::drawBitmapRectToRect for similar behavior.
|
||||
*/
|
||||
void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*);
|
||||
|
||||
/**
|
||||
* If the image has direct access to its pixels (i.e. they are in local
|
||||
* RAM) return the (const) address of those pixels, and if not null, return
|
||||
@@ -84,57 +169,192 @@ public:
|
||||
*/
|
||||
const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const;
|
||||
|
||||
/**
|
||||
* If the image has direct access to its pixels (i.e. they are in local
|
||||
* RAM) return the (const) address of those pixels, and if not null, return
|
||||
* true, and if pixmap is not NULL, set it to point into the image.
|
||||
*
|
||||
* On failure, return false and ignore the pixmap parameter.
|
||||
*/
|
||||
bool peekPixels(SkPixmap* pixmap) const;
|
||||
|
||||
/**
|
||||
* Some images have to perform preliminary work in preparation for drawing. This can be
|
||||
* decoding, uploading to a GPU, or other tasks. These happen automatically when an image
|
||||
* is drawn, and often they are cached so that the cost is only paid the first time.
|
||||
*
|
||||
* Preroll() can be called before drawing to try to perform this prepatory work ahead of time.
|
||||
* For images that have no such work, this returns instantly. Others may do some thing to
|
||||
* prepare their cache and then return.
|
||||
*
|
||||
* If the image will drawn to a GPU-backed canvas or surface, pass the associated GrContext.
|
||||
* If the image will be drawn to any other type of canvas or surface, pass null.
|
||||
*/
|
||||
void preroll(GrContext* = nullptr) const;
|
||||
|
||||
// DEPRECATED
|
||||
GrTexture* getTexture() const;
|
||||
|
||||
/**
|
||||
* Returns true if the image is texture backed.
|
||||
*/
|
||||
bool isTextureBacked() const;
|
||||
|
||||
/**
|
||||
* Retrieves the backend API handle of the texture. If flushPendingGrContextIO then the
|
||||
* GrContext will issue to the backend API any deferred IO operations on the texture before
|
||||
* returning.
|
||||
*/
|
||||
GrBackendObject getTextureHandle(bool flushPendingGrContextIO) const;
|
||||
|
||||
/**
|
||||
* Hints to image calls where the system might cache computed intermediates (e.g. the results
|
||||
* of decoding or a read-back from the GPU. Passing kAllow signals that the system's default
|
||||
* behavior is fine. Passing kDisallow signals that caching should be avoided.
|
||||
*/
|
||||
enum CachingHint {
|
||||
kAllow_CachingHint,
|
||||
kDisallow_CachingHint,
|
||||
};
|
||||
|
||||
/**
|
||||
* Copy the pixels from the image into the specified buffer (pixels + rowBytes),
|
||||
* converting them into the requested format (dstInfo). The image pixels are read
|
||||
* starting at the specified (srcX,srcY) location.
|
||||
*
|
||||
* The specified ImageInfo and (srcX,srcY) offset specifies a source rectangle
|
||||
*
|
||||
* srcR.setXYWH(srcX, srcY, dstInfo.width(), dstInfo.height());
|
||||
*
|
||||
* srcR is intersected with the bounds of the image. If this intersection is not empty,
|
||||
* then we have two sets of pixels (of equal size). Replace the dst pixels with the
|
||||
* corresponding src pixels, performing any colortype/alphatype transformations needed
|
||||
* (in the case where the src and dst have different colortypes or alphatypes).
|
||||
*
|
||||
* This call can fail, returning false, for several reasons:
|
||||
* - If srcR does not intersect the image bounds.
|
||||
* - If the requested colortype/alphatype cannot be converted from the image's types.
|
||||
*/
|
||||
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
||||
int srcX, int srcY, CachingHint = kAllow_CachingHint) const;
|
||||
|
||||
bool readPixels(const SkPixmap& dst, int srcX, int srcY,
|
||||
CachingHint = kAllow_CachingHint) const;
|
||||
|
||||
/**
|
||||
* Copy the pixels from this image into the dst pixmap, converting as needed into dst's
|
||||
* colortype/alphatype. If the conversion cannot be performed, false is returned.
|
||||
*
|
||||
* If dst's dimensions differ from the src dimension, the image will be scaled, applying the
|
||||
* specified filter-quality.
|
||||
*/
|
||||
bool scalePixels(const SkPixmap& dst, SkFilterQuality, CachingHint = kAllow_CachingHint) const;
|
||||
|
||||
/**
|
||||
* Encode the image's pixels and return the result as a new SkData, which
|
||||
* the caller must manage (i.e. call unref() when they are done).
|
||||
*
|
||||
* If the image type cannot be encoded, or the requested encoder type is
|
||||
* not supported, this will return NULL.
|
||||
*
|
||||
* Note: this will attempt to encode the image's pixels in the specified format,
|
||||
* even if the image returns a data from refEncoded(). That data will be ignored.
|
||||
*/
|
||||
SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type,
|
||||
int quality = 80) const;
|
||||
SkData* encode(SkImageEncoder::Type, int quality) const;
|
||||
|
||||
/**
|
||||
* Encode the image and return the result as a caller-managed SkData. This will
|
||||
* attempt to reuse existing encoded data (as returned by refEncoded).
|
||||
*
|
||||
* We defer to the SkPixelSerializer both for vetting existing encoded data
|
||||
* (useEncodedData) and for encoding the image (encodePixels) when no such data is
|
||||
* present or is rejected by the serializer.
|
||||
*
|
||||
* If not specified, we use a default serializer which 1) always accepts existing data
|
||||
* (in any format) and 2) encodes to PNG.
|
||||
*
|
||||
* If no compatible encoded data exists and encoding fails, this method will also
|
||||
* fail (return NULL).
|
||||
*/
|
||||
SkData* encode(SkPixelSerializer* = nullptr) const;
|
||||
|
||||
/**
|
||||
* If the image already has its contents in encoded form (e.g. PNG or JPEG), return a ref
|
||||
* to that data (which the caller must call unref() on). The caller is responsible for calling
|
||||
* unref on the data when they are done.
|
||||
*
|
||||
* If the image does not already has its contents in encoded form, return NULL.
|
||||
*
|
||||
* Note: to force the image to return its contents as encoded data, try calling encode(...).
|
||||
*/
|
||||
SkData* refEncoded() const;
|
||||
|
||||
const char* toString(SkString*) const;
|
||||
|
||||
/**
|
||||
* Return a new image that is a subset of this image. The underlying implementation may
|
||||
* share the pixels, or it may make a copy.
|
||||
*
|
||||
* If subset does not intersect the bounds of this image, or the copy/share cannot be made,
|
||||
* NULL will be returned.
|
||||
*/
|
||||
SkImage* newSubset(const SkIRect& subset) const;
|
||||
|
||||
// Helper functions to convert to SkBitmap
|
||||
|
||||
enum LegacyBitmapMode {
|
||||
kRO_LegacyBitmapMode,
|
||||
kRW_LegacyBitmapMode,
|
||||
};
|
||||
|
||||
/**
|
||||
* Attempt to create a bitmap with the same pixels as the image. The result will always be
|
||||
* a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not supported here).
|
||||
*
|
||||
* If the mode is kRO (read-only), the resulting bitmap will be marked as immutable.
|
||||
*
|
||||
* On succcess, returns true. On failure, returns false and the bitmap parameter will be reset
|
||||
* to empty.
|
||||
*/
|
||||
bool asLegacyBitmap(SkBitmap*, LegacyBitmapMode) const;
|
||||
|
||||
/**
|
||||
* Returns true if the image is backed by an image-generator or other src that creates
|
||||
* (and caches) its pixels / texture on-demand.
|
||||
*/
|
||||
bool isLazyGenerated() const;
|
||||
|
||||
/**
|
||||
* Apply the specified filter to this image, and return the result as a new image.
|
||||
*
|
||||
* if forceResultToOriginalSize is true, then the resulting image will be the same size as the
|
||||
* src, regardless of the normal output of the filter.
|
||||
*
|
||||
* If offset is non-null, it is set to the relative offset needed to draw the resulting image
|
||||
* in the same logical place as the original.
|
||||
*
|
||||
* e.g.
|
||||
* If the filter makes the result larger by a margin of 4 the output would be:
|
||||
* result->width() == this->width + 8
|
||||
* result->height() == this->height + 8
|
||||
* offset.x() == -4
|
||||
* offset.y() == -4
|
||||
*
|
||||
* If the filter fails to create a resulting image, null is returned, and the offset parameter
|
||||
* (if specified) will be undefined.
|
||||
*/
|
||||
SkImage* applyFilter(SkImageFilter* filter, SkIPoint* offset,
|
||||
bool forceResultToOriginalSize) const;
|
||||
|
||||
protected:
|
||||
SkImage(int width, int height) :
|
||||
fWidth(width),
|
||||
fHeight(height),
|
||||
fUniqueID(NextUniqueID()) {
|
||||
|
||||
SkASSERT(width >= 0);
|
||||
SkASSERT(height >= 0);
|
||||
}
|
||||
SkImage(int width, int height, uint32_t uniqueID);
|
||||
|
||||
private:
|
||||
const int fWidth;
|
||||
const int fHeight;
|
||||
const uint32_t fUniqueID;
|
||||
|
||||
static uint32_t NextUniqueID();
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
|
||||
/**
|
||||
* Return a copy of the image's pixels, limiting them to the subset
|
||||
* rectangle's intersection wit the image bounds. If subset is NULL, then
|
||||
* the entire image will be considered.
|
||||
*
|
||||
* If the bitmap's pixels have already been allocated, then readPixels()
|
||||
* will succeed only if it can support converting the image's pixels into
|
||||
* the bitmap's ColorType/AlphaType. Any pixels in the bitmap that do not
|
||||
* intersect with the image's bounds and the subset (if not null) will be
|
||||
* left untouched.
|
||||
*
|
||||
* If the bitmap is initially empty/unallocated, then it will be allocated
|
||||
* using the default allocator, and the ColorType/AlphaType will be chosen
|
||||
* to most closely fit the image's configuration.
|
||||
*
|
||||
* On failure, false will be returned, and bitmap will unmodified.
|
||||
*/
|
||||
// On ice for now:
|
||||
// - should it respect the particular colortype/alphatype of the src
|
||||
// - should it have separate entrypoints for preallocated and not bitmaps?
|
||||
// - isn't it enough to allow the caller to draw() the image into a canvas?
|
||||
bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,11 +10,14 @@
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkImage.h"
|
||||
#include "SkPngChunkReader.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkTRegistry.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
//#define SK_LEGACY_PEEKER
|
||||
|
||||
class SkStream;
|
||||
class SkStreamRewindable;
|
||||
|
||||
@@ -26,6 +29,7 @@ class SkImageDecoder : SkNoncopyable {
|
||||
public:
|
||||
virtual ~SkImageDecoder();
|
||||
|
||||
// TODO (scroggo): Merge with SkEncodedFormat
|
||||
enum Format {
|
||||
kUnknown_Format,
|
||||
kBMP_Format,
|
||||
@@ -37,6 +41,7 @@ public:
|
||||
kWEBP_Format,
|
||||
kPKM_Format,
|
||||
kKTX_Format,
|
||||
kASTC_Format,
|
||||
|
||||
kLastKnownFormat = kKTX_Format,
|
||||
};
|
||||
@@ -46,6 +51,15 @@ public:
|
||||
*/
|
||||
virtual Format getFormat() const;
|
||||
|
||||
/** If planes or rowBytes is NULL, decodes the header and computes componentSizes
|
||||
for memory allocation.
|
||||
Otherwise, decodes the YUV planes into the provided image planes and
|
||||
updates componentSizes to the final image size.
|
||||
Returns whether the decoding was successful.
|
||||
*/
|
||||
bool decodeYUV8Planes(SkStream* stream, SkISize componentSizes[3], void* planes[3],
|
||||
size_t rowBytes[3], SkYUVColorSpace*);
|
||||
|
||||
/** Return the format of the SkStreamRewindable or kUnknown_Format if it cannot be determined.
|
||||
Rewinds the stream before returning.
|
||||
*/
|
||||
@@ -115,95 +129,20 @@ public:
|
||||
*/
|
||||
bool getRequireUnpremultipliedColors() const { return fRequireUnpremultipliedColors; }
|
||||
|
||||
/** \class Peeker
|
||||
|
||||
Base class for optional callbacks to retrieve meta/chunk data out of
|
||||
an image as it is being decoded.
|
||||
*/
|
||||
class Peeker : public SkRefCnt {
|
||||
#ifdef SK_LEGACY_PEEKER
|
||||
// Android subclasses SkImageDecoder::Peeker, which has been changed into SkPngChunkReader.
|
||||
// Temporarily use this class until Android can be updated to directly inherit from
|
||||
// SkPngChunkReader.
|
||||
class Peeker : public SkPngChunkReader {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(Peeker)
|
||||
|
||||
/** Return true to continue decoding, or false to indicate an error, which
|
||||
will cause the decoder to not return the image.
|
||||
*/
|
||||
bool readChunk(const char tag[], const void* data, size_t length) final {
|
||||
return this->peek(tag, data, length);
|
||||
}
|
||||
virtual bool peek(const char tag[], const void* data, size_t length) = 0;
|
||||
private:
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
Peeker* getPeeker() const { return fPeeker; }
|
||||
Peeker* setPeeker(Peeker*);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
|
||||
/** \class Chooser
|
||||
|
||||
Base class for optional callbacks to choose an image from a format that
|
||||
contains multiple images.
|
||||
*/
|
||||
class Chooser : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(Chooser)
|
||||
|
||||
virtual void begin(int count) {}
|
||||
virtual void inspect(int index, SkBitmap::Config config, int width, int height) {}
|
||||
/** Return the index of the subimage you want, or -1 to choose none of them.
|
||||
*/
|
||||
virtual int choose() = 0;
|
||||
|
||||
private:
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
Chooser* getChooser() const { return fChooser; }
|
||||
Chooser* setChooser(Chooser*);
|
||||
#endif
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
|
||||
/**
|
||||
* Optional table describing the caller's preferred config based on
|
||||
* information about the src data. Each field should be set to the
|
||||
* preferred config for a src described in the name of the field. The
|
||||
* src attributes are described in terms of depth (8-index,
|
||||
* 8bit-grayscale, or 8-bits/component) and whether there is per-pixel
|
||||
* alpha (does not apply to grayscale). If the caller has no preference
|
||||
* for a particular src type, its slot should be set to kNo_Config.
|
||||
*
|
||||
* NOTE ABOUT PREFERRED CONFIGS:
|
||||
* If a config is preferred, either using a pref table or as a parameter
|
||||
* to some flavor of decode, it is still at the discretion of the codec
|
||||
* as to what output config is actually returned, as it may not be able
|
||||
* to support the caller's preference.
|
||||
*
|
||||
* If a bitmap is decoded into SkBitmap::A8_Config, the resulting bitmap
|
||||
* will either be a conversion of the grayscale in the case of a
|
||||
* grayscale source or the alpha channel in the case of a source with
|
||||
* an alpha channel.
|
||||
*/
|
||||
struct PrefConfigTable {
|
||||
SkBitmap::Config fPrefFor_8Index_NoAlpha_src;
|
||||
SkBitmap::Config fPrefFor_8Index_YesAlpha_src;
|
||||
SkBitmap::Config fPrefFor_8Gray_src;
|
||||
SkBitmap::Config fPrefFor_8bpc_NoAlpha_src;
|
||||
SkBitmap::Config fPrefFor_8bpc_YesAlpha_src;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set an optional table for specifying the caller's preferred config
|
||||
* based on information about the src data.
|
||||
*
|
||||
* The default is no preference, which will assume the config set by
|
||||
* decode is preferred.
|
||||
*/
|
||||
void setPrefConfigTable(const PrefConfigTable&);
|
||||
|
||||
/**
|
||||
* Do not use a PrefConfigTable to determine the output config. This
|
||||
* is the default, so there is no need to call unless a PrefConfigTable
|
||||
* was previously set.
|
||||
*/
|
||||
void resetPrefConfigTable() { fUsePrefTable = false; }
|
||||
#endif
|
||||
SkPngChunkReader* getPeeker() const { return fPeeker; }
|
||||
SkPngChunkReader* setPeeker(SkPngChunkReader*);
|
||||
|
||||
/**
|
||||
* By default, the codec will try to comply with the "pref" colortype
|
||||
@@ -261,13 +200,26 @@ public:
|
||||
kDecodePixels_Mode //!< return entire bitmap (including pixels)
|
||||
};
|
||||
|
||||
/** Result of a decode. If read as a boolean, a partial success is
|
||||
considered a success (true).
|
||||
*/
|
||||
enum Result {
|
||||
kFailure = 0, //!< Image failed to decode. bitmap will be
|
||||
// unchanged.
|
||||
kPartialSuccess = 1, //!< Part of the image decoded. The rest is
|
||||
// filled in automatically
|
||||
kSuccess = 2 //!< The entire image was decoded, if Mode is
|
||||
// kDecodePixels_Mode, or the bounds were
|
||||
// decoded, in kDecodeBounds_Mode.
|
||||
};
|
||||
|
||||
/** Given a stream, decode it into the specified bitmap.
|
||||
If the decoder can decompress the image, it calls bitmap.setInfo(),
|
||||
and then if the Mode is kDecodePixels_Mode, call allocPixelRef(),
|
||||
which will allocated a pixelRef. To access the pixel memory, the codec
|
||||
needs to call lockPixels/unlockPixels on the
|
||||
bitmap. It can then set the pixels with the decompressed image.
|
||||
* If the image cannot be decompressed, return false. After the
|
||||
* If the image cannot be decompressed, return kFailure. After the
|
||||
* decoding, the function converts the decoded colortype in bitmap
|
||||
* to pref if possible. Whether a conversion is feasible is
|
||||
* tested by Bitmap::canCopyTo(pref).
|
||||
@@ -277,32 +229,14 @@ public:
|
||||
to allocate the memory from a cache, volatile memory, or even from
|
||||
an existing bitmap's memory.
|
||||
|
||||
If a Peeker is installed via setPeeker, it may be used to peek into
|
||||
meta data during the decode.
|
||||
If an SkPngChunkReader is installed via setPeeker, it may be used to
|
||||
peek into meta data during the decode.
|
||||
*/
|
||||
bool decode(SkStream*, SkBitmap* bitmap, SkColorType pref, Mode);
|
||||
bool decode(SkStream* stream, SkBitmap* bitmap, Mode mode) {
|
||||
Result decode(SkStream*, SkBitmap* bitmap, SkColorType pref, Mode);
|
||||
Result decode(SkStream* stream, SkBitmap* bitmap, Mode mode) {
|
||||
return this->decode(stream, bitmap, kUnknown_SkColorType, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a stream, build an index for doing tile-based decode.
|
||||
* The built index will be saved in the decoder, and the image size will
|
||||
* be returned in width and height.
|
||||
*
|
||||
* Return true for success or false on failure.
|
||||
*/
|
||||
bool buildTileIndex(SkStreamRewindable*, int *width, int *height);
|
||||
|
||||
/**
|
||||
* Decode a rectangle subset in the image.
|
||||
* The method can only be called after buildTileIndex().
|
||||
*
|
||||
* Return true for success.
|
||||
* Return false if the index is never built or failing in decoding.
|
||||
*/
|
||||
bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkColorType pref);
|
||||
|
||||
/** Given a stream, this will try to find an appropriate decoder object.
|
||||
If none is found, the method returns NULL.
|
||||
*/
|
||||
@@ -311,8 +245,7 @@ public:
|
||||
/** Decode the image stored in the specified file, and store the result
|
||||
in bitmap. Return true for success or false on failure.
|
||||
|
||||
@param pref If the PrefConfigTable is not set, prefer this colortype.
|
||||
See NOTE ABOUT PREFERRED CONFIGS.
|
||||
@param pref Prefer this colortype.
|
||||
|
||||
@param format On success, if format is non-null, it is set to the format
|
||||
of the decoded file. On failure it is ignored.
|
||||
@@ -326,8 +259,7 @@ public:
|
||||
/** Decode the image stored in the specified memory buffer, and store the
|
||||
result in bitmap. Return true for success or false on failure.
|
||||
|
||||
@param pref If the PrefConfigTable is not set, prefer this colortype.
|
||||
See NOTE ABOUT PREFERRED CONFIGS.
|
||||
@param pref Prefer this colortype.
|
||||
|
||||
@param format On success, if format is non-null, it is set to the format
|
||||
of the decoded buffer. On failure it is ignored.
|
||||
@@ -338,26 +270,10 @@ public:
|
||||
return DecodeMemory(buffer, size, bitmap, kUnknown_SkColorType, kDecodePixels_Mode, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Struct containing information about a pixel destination.
|
||||
*/
|
||||
struct Target {
|
||||
/**
|
||||
* Pre-allocated memory.
|
||||
*/
|
||||
void* fAddr;
|
||||
|
||||
/**
|
||||
* Rowbytes of the allocated memory.
|
||||
*/
|
||||
size_t fRowBytes;
|
||||
};
|
||||
|
||||
/** Decode the image stored in the specified SkStreamRewindable, and store the result
|
||||
in bitmap. Return true for success or false on failure.
|
||||
|
||||
@param pref If the PrefConfigTable is not set, prefer this colortype.
|
||||
See NOTE ABOUT PREFERRED CONFIGS.
|
||||
@param pref Prefer this colortype.
|
||||
|
||||
@param format On success, if format is non-null, it is set to the format
|
||||
of the decoded stream. On failure it is ignored.
|
||||
@@ -370,39 +286,20 @@ public:
|
||||
|
||||
protected:
|
||||
// must be overridden in subclasses. This guy is called by decode(...)
|
||||
virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0;
|
||||
virtual Result onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0;
|
||||
|
||||
// If the decoder wants to support tiled based decoding,
|
||||
// this method must be overridden. This guy is called by buildTileIndex(...)
|
||||
virtual bool onBuildTileIndex(SkStreamRewindable*, int *width, int *height) {
|
||||
/** If planes or rowBytes is NULL, decodes the header and computes componentSizes
|
||||
for memory allocation.
|
||||
Otherwise, decodes the YUV planes into the provided image planes and
|
||||
updates componentSizes to the final image size.
|
||||
Returns whether the decoding was successful.
|
||||
*/
|
||||
virtual bool onDecodeYUV8Planes(SkStream*, SkISize[3] /*componentSizes*/,
|
||||
void*[3] /*planes*/, size_t[3] /*rowBytes*/,
|
||||
SkYUVColorSpace*) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the decoder wants to support tiled based decoding,
|
||||
// this method must be overridden. This guy is called by decodeRegion(...)
|
||||
virtual bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Crop a rectangle from the src Bitmap to the dest Bitmap. src and dst are
|
||||
* both sampled by sampleSize from an original Bitmap.
|
||||
*
|
||||
* @param dst the destination bitmap.
|
||||
* @param src the source bitmap that is sampled by sampleSize from the
|
||||
* original bitmap.
|
||||
* @param sampleSize the sample size that src is sampled from the original bitmap.
|
||||
* @param (dstX, dstY) the upper-left point of the dest bitmap in terms of
|
||||
* the coordinate in the original bitmap.
|
||||
* @param (width, height) the width and height of the unsampled dst.
|
||||
* @param (srcX, srcY) the upper-left point of the src bitmap in terms of
|
||||
* the coordinate in the original bitmap.
|
||||
* @return bool Whether or not it succeeded.
|
||||
*/
|
||||
bool cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize,
|
||||
int dstX, int dstY, int width, int height,
|
||||
int srcX, int srcY);
|
||||
|
||||
/**
|
||||
* Copy all fields on this decoder to the other decoder. Used by subclasses
|
||||
* to decode a subimage using a different decoder, but with the same settings.
|
||||
@@ -428,12 +325,6 @@ protected:
|
||||
* Return the default preference being used by the current or latest call to decode.
|
||||
*/
|
||||
SkColorType getDefaultPref() { return fDefaultPref; }
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
|
||||
// helper function for decoders to handle the (common) case where there is only
|
||||
// once choice available in the image file.
|
||||
bool chooseFromOneChoice(SkColorType, int width, int height) const;
|
||||
#endif
|
||||
|
||||
/* Helper for subclasses. Call this to allocate the pixel memory given the bitmap's info.
|
||||
Returns true on success. This method handles checking for an optional Allocator.
|
||||
@@ -459,17 +350,10 @@ protected:
|
||||
SkColorType getPrefColorType(SrcDepth, bool hasAlpha) const;
|
||||
|
||||
private:
|
||||
Peeker* fPeeker;
|
||||
#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
|
||||
Chooser* fChooser;
|
||||
#endif
|
||||
SkPngChunkReader* fPeeker;
|
||||
SkBitmap::Allocator* fAllocator;
|
||||
int fSampleSize;
|
||||
SkColorType fDefaultPref; // use if fUsePrefTable is false
|
||||
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
|
||||
PrefConfigTable fPrefTable; // use if fUsePrefTable is true
|
||||
bool fUsePrefTable;
|
||||
#endif
|
||||
bool fPreserveSrcDepth;
|
||||
bool fDitherImage;
|
||||
bool fSkipWritingZeroes;
|
||||
@@ -486,7 +370,7 @@ private:
|
||||
*/
|
||||
class SkImageDecoderFactory : public SkRefCnt {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkImageDecoderFactory)
|
||||
|
||||
|
||||
virtual SkImageDecoder* newDecoder(SkStreamRewindable*) = 0;
|
||||
|
||||
@@ -509,10 +393,8 @@ public:
|
||||
|
||||
// This macro defines the global creation entry point for each decoder. Each
|
||||
// decoder implementation that registers with the decoder factory must call it.
|
||||
#define DEFINE_DECODER_CREATOR(codec) \
|
||||
SkImageDecoder *Create ## codec () { \
|
||||
return SkNEW( Sk ## codec ); \
|
||||
}
|
||||
#define DEFINE_DECODER_CREATOR(codec) \
|
||||
SkImageDecoder* Create##codec() { return new Sk##codec; }
|
||||
|
||||
// All the decoders known by Skia. Note that, depending on the compiler settings,
|
||||
// not all of these will be available
|
||||
@@ -525,6 +407,7 @@ DECLARE_DECODER_CREATOR(WBMPImageDecoder);
|
||||
DECLARE_DECODER_CREATOR(WEBPImageDecoder);
|
||||
DECLARE_DECODER_CREATOR(PKMImageDecoder);
|
||||
DECLARE_DECODER_CREATOR(KTXImageDecoder);
|
||||
DECLARE_DECODER_CREATOR(ASTCImageDecoder);
|
||||
|
||||
// Typedefs to make registering decoder and formatter callbacks easier.
|
||||
// These have to be defined outside SkImageDecoder. :(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user