check for no_paint and remove some drawdrawable special-casing
authorMike Reed <reed@google.com>
Mon, 15 May 2017 17:27:02 +0000 (13:27 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 15 May 2017 19:03:11 +0000 (19:03 +0000)
Bug: skia:
Change-Id: I824980a47ddd7c8c7627dabb5efd40f8f0889b67
Reviewed-on: https://skia-review.googlesource.com/16900
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
include/private/SkRecords.h
src/core/SkPictureCommon.h
src/core/SkRecordPattern.h

index f26b6ba..6af4aad 100644 (file)
@@ -159,6 +159,8 @@ enum Tags {
     kHasImage_Tag  = 2,   // Contains an SkImage or SkBitmap.
     kHasText_Tag   = 4,   // Contains text.
     kHasPaint_Tag  = 8,   // May have an SkPaint field, at least optionally.
+
+    kDrawWithPaint_Tag = kDraw_Tag | kHasPaint_Tag,
 };
 
 // A macro to make it a little easier to define a struct that can be stored in SkRecord.
index a400264..43805fd 100644 (file)
@@ -81,7 +81,6 @@ struct SkPathCounter {
     void operator()(const SkRecords::DrawPicture& op) {
         fNumSlowPathsAndDashEffects += op.picture->numSlowPaths();
     }
-    void operator()(const SkRecords::DrawDrawable&) { /* TODO */ }
 
     void checkPaint(const SkPaint* paint) {
         if (paint && paint->getPathEffect()) {
@@ -132,12 +131,13 @@ struct SkPathCounter {
     }
 
     template <typename T>
-    SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) {
+    SK_WHEN(T::kTags & SkRecords::kHasPaint_Tag, void) operator()(const T& op) {
         this->checkPaint(AsPtr(op.paint));
     }
 
     template <typename T>
-    SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), void) operator()(const T& op) { /* do nothing */ }
+    SK_WHEN(!(T::kTags & SkRecords::kHasPaint_Tag), void)
+      operator()(const T& op) { /* do nothing */ }
 
     int fNumSlowPathsAndDashEffects;
 };
index 73fe763..dcce993 100644 (file)
@@ -49,13 +49,13 @@ public:
     type* get() { return fPaint; }
 
     template <typename T>
-    SK_WHEN(T::kTags & kDraw_Tag, bool) operator()(T* draw) {
+    SK_WHEN((T::kTags & kDrawWithPaint_Tag) == kDrawWithPaint_Tag, bool) operator()(T* draw) {
         fPaint = AsPtr(draw->paint);
         return true;
     }
 
-    bool operator()(DrawDrawable*) {
-        static_assert(DrawDrawable::kTags & kDraw_Tag, "");
+    template <typename T>
+    SK_WHEN((T::kTags & kDrawWithPaint_Tag) == kDraw_Tag, bool) operator()(T* draw) {
         fPaint = nullptr;
         return true;
     }