Chromium Code Reviews| Index: src/core/SkPicture.cpp |
| diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp |
| index 469a2083a7d1cb92882d8a3abf0b3ee287a5af8b..00dc65b602cb01c3ee0ce28da0f7ff4fe6a2378c 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". |
|
reed1
2014/08/20 22:30:31
clever, and possible fragile. All the more reason
|
| + 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,15 @@ struct PathCounter { |
| , numAAHairlineConcavePaths (0) { |
| } |
| + // Recurse into nested pictures. |
| + void operator()(const SkRecords::DrawPicture& op) { |
| + SkASSERT(op.picture->fRecord.get() != NULL); |
| + 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 +187,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); |