diff options
author | mtklein <mtklein@chromium.org> | 2015-08-26 08:14:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-26 08:14:52 -0700 |
commit | a16af21b17885c517a587482e9062efb99c19306 (patch) | |
tree | 6fdf739b6a92e3aee692d6a034a03d5faa898088 /src/core | |
parent | bcf33d5c06f7560039797b6023f14466c75598ed (diff) |
Have SkPicture::willPlayBackBitmaps() count SkImages too.
New unit test fails at head but passes with this patch.
BUG=skia:4225
Review URL: https://codereview.chromium.org/1319723002
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPictureCommon.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/core/SkPictureCommon.h b/src/core/SkPictureCommon.h index 3d64888641..c9c023d2bb 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> |