OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkPaint.h" | 8 #include "SkPaint.h" |
9 #include "SkPathEffect.h" | 9 #include "SkPathEffect.h" |
10 #include "SkPictureContentInfo.h" | 10 #include "SkPictureContentInfo.h" |
11 | 11 |
12 bool SkPictureContentInfo::suitableForGpuRasterization(GrContext* context, const
char **reason, | 12 bool SkPictureContentInfo::suitableForGpuRasterization(GrContext* context, const
char **reason, |
13 int sampleCount) const { | 13 int sampleCount) const { |
14 // TODO: the heuristic used here needs to be refined | 14 // TODO: the heuristic used here needs to be refined |
15 static const int kNumPaintWithPathEffectUsesTol = 1; | 15 static const int kNumPaintWithPathEffectUsesTol = 1; |
16 static const int kNumAAConcavePaths = 5; | 16 static const int kNumAAConcavePaths = 5; |
17 | 17 |
18 SkASSERT(fNumAAHairlineConcavePaths <= fNumAAConcavePaths); | 18 SkASSERT(fNumAAHairlineConcavePaths <= fNumAAConcavePaths); |
19 | 19 |
20 int numNonDashedPathEffects = fNumPaintWithPathEffectUses - | 20 int numNonDashedPathEffects = fNumPaintWithPathEffectUses - |
21 fNumFastPathDashEffects; | 21 fNumFastPathDashEffects; |
22 | 22 |
23 bool suitableForDash = (0 == fNumPaintWithPathEffectUses) || | 23 bool suitableForDash = (0 == fNumPaintWithPathEffectUses) || |
24 (numNonDashedPathEffects < kNumPaintWithPathEffectUse
sTol | 24 (numNonDashedPathEffects < kNumPaintWithPathEffectUse
sTol |
25 && 0 == sampleCount); | 25 && 0 == sampleCount); |
26 | 26 |
27 bool ret = suitableForDash && | 27 bool ret = suitableForDash && |
28 (fNumAAConcavePaths - fNumAAHairlineConcavePaths) | 28 (fNumAAConcavePaths - fNumAAHairlineConcavePaths) |
29 < kNumAAConcavePaths; | 29 < kNumAAConcavePaths; |
30 if (!ret && NULL != reason) { | 30 if (!ret && reason) { |
31 if (!suitableForDash) { | 31 if (!suitableForDash) { |
32 if (0 != sampleCount) { | 32 if (0 != sampleCount) { |
33 *reason = "Can't use multisample on dash effect."; | 33 *reason = "Can't use multisample on dash effect."; |
34 } else { | 34 } else { |
35 *reason = "Too many non dashed path effects."; | 35 *reason = "Too many non dashed path effects."; |
36 } | 36 } |
37 } else if ((fNumAAConcavePaths - fNumAAHairlineConcavePaths) | 37 } else if ((fNumAAConcavePaths - fNumAAHairlineConcavePaths) |
38 >= kNumAAConcavePaths) { | 38 >= kNumAAConcavePaths) { |
39 *reason = "Too many anti-aliased concave paths."; | 39 *reason = "Too many anti-aliased concave paths."; |
40 } else { | 40 } else { |
(...skipping 18 matching lines...) Expand all Loading... |
59 if (paint.isAntiAlias() && !path.isConvex()) { | 59 if (paint.isAntiAlias() && !path.isConvex()) { |
60 ++fNumAAConcavePaths; | 60 ++fNumAAConcavePaths; |
61 | 61 |
62 if (SkPaint::kStroke_Style == paint.getStyle() && 0 == paint.getStrokeWi
dth()) { | 62 if (SkPaint::kStroke_Style == paint.getStyle() && 0 == paint.getStrokeWi
dth()) { |
63 ++fNumAAHairlineConcavePaths; | 63 ++fNumAAHairlineConcavePaths; |
64 } | 64 } |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) { | 68 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) { |
69 if (NULL != paint && NULL != paint->getPathEffect()) { | 69 if (paint && paint->getPathEffect()) { |
70 ++fNumPaintWithPathEffectUses; | 70 ++fNumPaintWithPathEffectUses; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void SkPictureContentInfo::onSaveLayer() { | 74 void SkPictureContentInfo::onSaveLayer() { |
75 *fSaveStack.append() = kSaveLayer_Flag; | 75 *fSaveStack.append() = kSaveLayer_Flag; |
76 } | 76 } |
77 | 77 |
78 void SkPictureContentInfo::onSave() { | 78 void SkPictureContentInfo::onSave() { |
79 *fSaveStack.append() = kSave_Flag; | 79 *fSaveStack.append() = kSave_Flag; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 SkTSwap(fNumTexts, other->fNumTexts); | 158 SkTSwap(fNumTexts, other->fNumTexts); |
159 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses); | 159 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses); |
160 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects); | 160 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects); |
161 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths); | 161 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths); |
162 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths); | 162 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths); |
163 SkTSwap(fNumLayers, other->fNumLayers); | 163 SkTSwap(fNumLayers, other->fNumLayers); |
164 SkTSwap(fNumInteriorLayers, other->fNumInteriorLayers); | 164 SkTSwap(fNumInteriorLayers, other->fNumInteriorLayers); |
165 SkTSwap(fNumLeafLayers, other->fNumLeafLayers); | 165 SkTSwap(fNumLeafLayers, other->fNumLeafLayers); |
166 fSaveStack.swap(other->fSaveStack); | 166 fSaveStack.swap(other->fSaveStack); |
167 } | 167 } |
OLD | NEW |