OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 // Some shared code used by both SkBigPicture and SkMiniPicture. | 8 // Some shared code used by both SkBigPicture and SkMiniPicture. |
9 // SkTextHunter -- SkRecord visitor that returns true when the op draws text
. | 9 // SkTextHunter -- SkRecord visitor that returns true when the op draws text
. |
10 // SkBitmapHunter -- SkRecord visitor that returns true when the op draws a bi
tmap or image. | 10 // SkBitmapHunter -- SkRecord visitor that returns true when the op draws a bi
tmap or image. |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 // If not, look for one in its paint (if it has a paint). | 40 // If not, look for one in its paint (if it has a paint). |
41 template <typename T> | 41 template <typename T> |
42 static SK_WHEN(!(T::kTags & SkRecords::kHasImage_Tag), bool) CheckBitmap(con
st T& op) { | 42 static SK_WHEN(!(T::kTags & SkRecords::kHasImage_Tag), bool) CheckBitmap(con
st T& op) { |
43 return CheckPaint(op); | 43 return CheckPaint(op); |
44 } | 44 } |
45 | 45 |
46 // Most draws-type ops have paints. | 46 // Most draws-type ops have paints. |
47 template <typename T> | 47 template <typename T> |
48 static SK_WHEN(T::kTags & SkRecords::kDraw_Tag, bool) CheckPaint(const T& op
) { | 48 static SK_WHEN(T::kTags & SkRecords::kHasPaint_Tag, bool) CheckPaint(const T
& op) { |
49 return PaintHasBitmap(AsPtr(op.paint)); | 49 return PaintHasBitmap(AsPtr(op.paint)); |
50 } | 50 } |
51 | 51 |
52 // SaveLayers also have a paint to check. | |
53 static bool CheckPaint(const SkRecords::SaveLayer& op) { | |
54 return PaintHasBitmap(AsPtr(op.paint)); | |
55 } | |
56 | |
57 // Shouldn't be any non-Draw non-SaveLayer ops with paints. | |
58 template <typename T> | 52 template <typename T> |
59 static SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), bool) CheckPaint(const T&
) { | 53 static SK_WHEN(!(T::kTags & SkRecords::kHasPaint_Tag), bool) CheckPaint(cons
t T&) { |
60 return false; | 54 return false; |
61 } | 55 } |
62 | 56 |
63 private: | 57 private: |
64 static bool PaintHasBitmap(const SkPaint* paint) { | 58 static bool PaintHasBitmap(const SkPaint* paint) { |
65 if (paint) { | 59 if (paint) { |
66 const SkShader* shader = paint->getShader(); | 60 const SkShader* shader = paint->getShader(); |
67 if (shader && shader->isABitmap()) { | 61 if (shader && shader->isABitmap()) { |
68 return true; | 62 return true; |
69 } | 63 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 template <typename T> | 131 template <typename T> |
138 SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) { | 132 SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) { |
139 this->checkPaint(AsPtr(op.paint)); | 133 this->checkPaint(AsPtr(op.paint)); |
140 } | 134 } |
141 | 135 |
142 template <typename T> | 136 template <typename T> |
143 SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), void) operator()(const T& op) {
/* do nothing */ } | 137 SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), void) operator()(const T& op) {
/* do nothing */ } |
144 | 138 |
145 int fNumSlowPathsAndDashEffects; | 139 int fNumSlowPathsAndDashEffects; |
146 }; | 140 }; |
OLD | NEW |