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

Unified Diff: src/core/SkPictureCommon.h

Issue 1319723002: Have SkPicture::willPlayBackBitmaps() count SkImages too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | tests/PictureTest.cpp » ('j') | tests/PictureTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureCommon.h
diff --git a/src/core/SkPictureCommon.h b/src/core/SkPictureCommon.h
index 3d64888641df2e6e09013f24908af8aef39223c6..c9c023d2bb1249ce1b955647a4c1a6f4d9ebedd9 100644
--- a/src/core/SkPictureCommon.h
+++ b/src/core/SkPictureCommon.h
@@ -7,7 +7,7 @@
// Some shared code used by both SkBigPicture and SkMiniPicture.
// SkTextHunter -- SkRecord visitor that returns true when the op draws text.
-// SkBitmapHunter -- SkRecord visitor that returns true when the op draws a bitmap.
+// SkBitmapHunter -- SkRecord visitor that returns true when the op draws a bitmap or image.
// SkPathCounter -- SkRecord visitor that counts paths that draw slowly on the GPU.
#include "SkPathEffect.h"
@@ -26,18 +26,25 @@ struct SkTextHunter {
};
+// N.B. This name is slightly historical: hunting season is now open for SkImages too.
struct SkBitmapHunter {
- // Helpers. These create HasMember_bitmap and HasMember_paint.
+ // Helpers. These let us detect the presence of struct members with particular names.
SK_CREATE_MEMBER_DETECTOR(bitmap);
+ SK_CREATE_MEMBER_DETECTOR(image);
SK_CREATE_MEMBER_DETECTOR(paint);
+ template <typename T>
+ struct HasMember_bitmap_or_image {
+ static const bool value = HasMember_bitmap<T>::value || HasMember_image<T>::value;
+ };
+
// Some ops have a paint, some have an optional paint. Either way, get back a pointer.
static const SkPaint* AsPtr(const SkPaint& p) { return &p; }
static const SkPaint* AsPtr(const SkRecords::Optional<SkPaint>& p) { return p; }
// Main entry for visitor:
// If the op is a DrawPicture, recurse.
- // If the op has a bitmap directly, return true.
+ // If the op has a bitmap or image directly, return true.
// If the op has a paint and the paint has a bitmap, return true.
// Otherwise, return false.
bool operator()(const SkRecords::DrawPicture& op) { return op.picture->willPlayBackBitmaps(); }
@@ -47,11 +54,15 @@ struct SkBitmapHunter {
// If the op has a bitmap, of course we're going to play back bitmaps.
template <typename T>
- static SK_WHEN(HasMember_bitmap<T>, bool) CheckBitmap(const T&) { return true; }
+ static SK_WHEN(HasMember_bitmap_or_image<T>, bool) CheckBitmap(const T&) {
+ return true;
+ }
// If not, look for one in its paint (if it has a paint).
template <typename T>
- static SK_WHEN(!HasMember_bitmap<T>, bool) CheckBitmap(const T& r) { return CheckPaint(r); }
+ static SK_WHEN(!HasMember_bitmap_or_image<T>, bool) CheckBitmap(const T& r) {
+ return CheckPaint(r);
+ }
// If we have a paint, dig down into the effects looking for a bitmap.
template <typename T>
« no previous file with comments | « no previous file | tests/PictureTest.cpp » ('j') | tests/PictureTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698