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. |
11 // SkPathCounter -- SkRecord visitor that counts paths that draw slowly on th
e GPU. | 11 // SkPathCounter -- SkRecord visitor that counts paths that draw slowly on th
e GPU. |
12 | 12 |
13 #include "SkPathEffect.h" | 13 #include "SkPathEffect.h" |
14 #include "SkRecords.h" | 14 #include "SkRecords.h" |
15 #include "SkTLogic.h" | 15 #include "SkTLogic.h" |
16 | 16 |
17 struct SkTextHunter { | |
18 // Most ops never have text. Some always do. Subpictures know themeselves. | |
19 bool operator()(const SkRecords::DrawPicture& op) { return op.picture->hasTe
xt(); } | |
20 bool operator()(const SkRecords::DrawDrawable&) { /*TODO*/ return false; } | |
21 | |
22 template <typename T> | |
23 SK_WHEN(T::kTags & SkRecords::kHasText_Tag, bool) operator()(const T&) { ret
urn true; } | |
24 template <typename T> | |
25 SK_WHEN(!(T::kTags & SkRecords::kHasText_Tag), bool) operator()(const T&) {
return false; } | |
26 }; | |
27 | |
28 | |
29 // N.B. This name is slightly historical: hunting season is now open for SkImage
s too. | 17 // N.B. This name is slightly historical: hunting season is now open for SkImage
s too. |
30 struct SkBitmapHunter { | 18 struct SkBitmapHunter { |
31 // Some ops have a paint, some have an optional paint. Either way, get back
a pointer. | 19 // Some ops have a paint, some have an optional paint. Either way, get back
a pointer. |
32 static const SkPaint* AsPtr(const SkPaint& p) { return &p; } | 20 static const SkPaint* AsPtr(const SkPaint& p) { return &p; } |
33 static const SkPaint* AsPtr(const SkRecords::Optional<SkPaint>& p) { return
p; } | 21 static const SkPaint* AsPtr(const SkRecords::Optional<SkPaint>& p) { return
p; } |
34 | 22 |
35 // Main entry for visitor: | 23 // Main entry for visitor: |
36 // If the op is a DrawPicture, recurse. | 24 // If the op is a DrawPicture, recurse. |
37 // If the op has a bitmap or image directly, return true. | 25 // If the op has a bitmap or image directly, return true. |
38 // If the op has a paint and the paint has a bitmap, return true. | 26 // If the op has a paint and the paint has a bitmap, return true. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 template <typename T> | 130 template <typename T> |
143 SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) { | 131 SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) { |
144 this->checkPaint(AsPtr(op.paint)); | 132 this->checkPaint(AsPtr(op.paint)); |
145 } | 133 } |
146 | 134 |
147 template <typename T> | 135 template <typename T> |
148 SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), void) operator()(const T& op) {
/* do nothing */ } | 136 SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), void) operator()(const T& op) {
/* do nothing */ } |
149 | 137 |
150 int fNumSlowPathsAndDashEffects; | 138 int fNumSlowPathsAndDashEffects; |
151 }; | 139 }; |
OLD | NEW |