From 74564b40bcd476320f41342e54ebb8980d2bcdf8 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Mon, 15 May 2017 13:27:02 -0400 Subject: [PATCH] check for no_paint and remove some drawdrawable special-casing Bug: skia: Change-Id: I824980a47ddd7c8c7627dabb5efd40f8f0889b67 Reviewed-on: https://skia-review.googlesource.com/16900 Commit-Queue: Mike Reed Reviewed-by: Mike Klein --- include/private/SkRecords.h | 2 ++ src/core/SkPictureCommon.h | 6 +++--- src/core/SkRecordPattern.h | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/private/SkRecords.h b/include/private/SkRecords.h index f26b6ba..6af4aad 100644 --- a/include/private/SkRecords.h +++ b/include/private/SkRecords.h @@ -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. diff --git a/src/core/SkPictureCommon.h b/src/core/SkPictureCommon.h index a400264..43805fd 100644 --- a/src/core/SkPictureCommon.h +++ b/src/core/SkPictureCommon.h @@ -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 - 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 - 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; }; diff --git a/src/core/SkRecordPattern.h b/src/core/SkRecordPattern.h index 73fe763..dcce993 100644 --- a/src/core/SkRecordPattern.h +++ b/src/core/SkRecordPattern.h @@ -49,13 +49,13 @@ public: type* get() { return fPaint; } template - 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 + SK_WHEN((T::kTags & kDrawWithPaint_Tag) == kDraw_Tag, bool) operator()(T* draw) { fPaint = nullptr; return true; } -- 2.7.4