Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: src/core/SkPicture.cpp

Issue 495793002: Our SkPicture::Analysis visitors should recurse into nested pictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkRecords.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicture.cpp
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 160dd4b420df044adc9e03d761db7307cbcba459..515f28d0791097f1df693e11606151bd82d7c0c9 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -68,9 +68,12 @@ struct BitmapTester {
// Main entry for visitor:
+ // If the command is a DrawPicture, recurse.
// If the command has a bitmap directly, return true.
// If the command has a paint and the paint has a bitmap, return true.
// Otherwise, return false.
+ bool operator()(const SkRecords::DrawPicture& op) { return op.picture->willPlayBackBitmaps(); }
+
template <typename T>
bool operator()(const T& r) { return CheckBitmap(r); }
@@ -112,10 +115,21 @@ bool WillPlaybackBitmaps(const SkRecord& record) {
return false;
}
+// SkRecord visitor to find recorded text.
+struct TextHunter {
+ // All ops with text have that text as a char array member named "text".
+ SK_CREATE_MEMBER_DETECTOR(text);
+ bool operator()(const SkRecords::DrawPicture& op) { return op.picture->hasText(); }
+ template <typename T> SK_WHEN(HasMember_text<T>, bool) operator()(const T&) { return true; }
+ template <typename T> SK_WHEN(!HasMember_text<T>, bool) operator()(const T&) { return false; }
+};
+
+} // namespace
+
/** SkRecords visitor to determine heuristically whether or not a SkPicture
will be performant when rasterized on the GPU.
*/
-struct PathCounter {
+struct SkPicture::PathCounter {
SK_CREATE_MEMBER_DETECTOR(paint);
PathCounter()
@@ -125,6 +139,18 @@ struct PathCounter {
, numAAHairlineConcavePaths (0) {
}
+ // Recurse into nested pictures.
+ void operator()(const SkRecords::DrawPicture& op) {
+ // If you're not also SkRecord-backed, tough luck. Get on the bandwagon.
+ if (op.picture->fRecord.get() == NULL) {
+ return;
+ }
+ const SkRecord& nested = *op.picture->fRecord;
+ for (unsigned i = 0; i < nested.count(); i++) {
+ nested.visit<void>(i, *this);
+ }
+ }
+
void checkPaint(const SkPaint* paint) {
if (paint && paint->getPathEffect()) {
numPaintWithPathEffectUses++;
@@ -164,23 +190,12 @@ struct PathCounter {
template <typename T>
SK_WHEN(!HasMember_paint<T>, void) operator()(const T& op) { /* do nothing */ }
-
int numPaintWithPathEffectUses;
int numFastPathDashEffects;
int numAAConcavePaths;
int numAAHairlineConcavePaths;
};
-// SkRecord visitor to find recorded text.
-struct TextHunter {
- // All ops with text have that text as a char array member named "text".
- SK_CREATE_MEMBER_DETECTOR(text);
- template <typename T> SK_WHEN(HasMember_text<T>, bool) operator()(const T&) { return true; }
- template <typename T> SK_WHEN(!HasMember_text<T>, bool) operator()(const T&) { return false; }
-};
-
-} // namespace
-
SkPicture::Analysis::Analysis(const SkRecord& record) {
fWillPlaybackBitmaps = WillPlaybackBitmaps(record);
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkRecords.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698