Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: src/core/SkPictureContentInfo.cpp

Issue 685113003: Enable distance field path rendering in Chrome. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase to ToT Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkPictureContentInfo.h ('k') | src/gpu/GrAddPathRenderers_default.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 - fNumAADFE ligibleConcavePaths)
29 < kNumAAConcavePaths; 29 < kNumAAConcavePaths;
30 if (!ret && 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 - fNumAADFEl igibleConcavePaths)
38 >= kNumAAConcavePaths) { 38 >= kNumAAConcavePaths) {
39 *reason = "Too many anti-aliased concave paths."; 39 *reason = "Too many anti-aliased concave paths.";
40 } else { 40 } else {
41 *reason = "Unknown reason for GPU unsuitability."; 41 *reason = "Unknown reason for GPU unsuitability.";
42 } 42 }
43 } 43 }
44 return ret; 44 return ret;
45 } 45 }
46 46
47 void SkPictureContentInfo::onDrawPoints(size_t count, const SkPaint& paint) { 47 void SkPictureContentInfo::onDrawPoints(size_t count, const SkPaint& paint) {
48 if (paint.getPathEffect() != NULL) { 48 if (paint.getPathEffect() != NULL) {
49 SkPathEffect::DashInfo info; 49 SkPathEffect::DashInfo info;
50 SkPathEffect::DashType dashType = paint.getPathEffect()->asADash(&info); 50 SkPathEffect::DashType dashType = paint.getPathEffect()->asADash(&info);
51 if (2 == count && SkPaint::kRound_Cap != paint.getStrokeCap() && 51 if (2 == count && SkPaint::kRound_Cap != paint.getStrokeCap() &&
52 SkPathEffect::kDash_DashType == dashType && 2 == info.fCount) { 52 SkPathEffect::kDash_DashType == dashType && 2 == info.fCount) {
53 ++fNumFastPathDashEffects; 53 ++fNumFastPathDashEffects;
54 } 54 }
55 } 55 }
56 } 56 }
57 57
58 void SkPictureContentInfo::onDrawPath(const SkPath& path, const SkPaint& paint) { 58 void SkPictureContentInfo::onDrawPath(const SkPath& path, const SkPaint& paint) {
59 if (paint.isAntiAlias() && !path.isConvex()) { 59 if (paint.isAntiAlias() && !path.isConvex()) {
60 ++fNumAAConcavePaths; 60 ++fNumAAConcavePaths;
61 61
62 SkPaint::Style paintStyle = paint.getStyle();
63 const SkRect& pathBounds = path.getBounds();
62 if (SkPaint::kStroke_Style == paint.getStyle() && 0 == paint.getStrokeWi dth()) { 64 if (SkPaint::kStroke_Style == paint.getStyle() && 0 == paint.getStrokeWi dth()) {
63 ++fNumAAHairlineConcavePaths; 65 ++fNumAAHairlineConcavePaths;
66 } else if (SkPaint::kFill_Style == paintStyle && pathBounds.width() < 64 .f &&
67 pathBounds.height() < 64.f && !path.isVolatile()) {
68 ++fNumAADFEligibleConcavePaths;
64 } 69 }
65 } 70 }
66 } 71 }
67 72
68 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) { 73 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) {
69 if (paint && paint->getPathEffect()) { 74 if (paint && paint->getPathEffect()) {
70 ++fNumPaintWithPathEffectUses; 75 ++fNumPaintWithPathEffectUses;
71 } 76 }
72 } 77 }
73 78
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 132 }
128 } 133 }
129 134
130 void SkPictureContentInfo::set(const SkPictureContentInfo& src) { 135 void SkPictureContentInfo::set(const SkPictureContentInfo& src) {
131 fNumOperations = src.fNumOperations; 136 fNumOperations = src.fNumOperations;
132 fNumTexts = src.fNumTexts; 137 fNumTexts = src.fNumTexts;
133 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses; 138 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
134 fNumFastPathDashEffects = src.fNumFastPathDashEffects; 139 fNumFastPathDashEffects = src.fNumFastPathDashEffects;
135 fNumAAConcavePaths = src.fNumAAConcavePaths; 140 fNumAAConcavePaths = src.fNumAAConcavePaths;
136 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths; 141 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
142 fNumAADFEligibleConcavePaths = src.fNumAADFEligibleConcavePaths;
137 fNumLayers = src.fNumLayers; 143 fNumLayers = src.fNumLayers;
138 fNumInteriorLayers = src.fNumInteriorLayers; 144 fNumInteriorLayers = src.fNumInteriorLayers;
139 fNumLeafLayers = src.fNumLeafLayers; 145 fNumLeafLayers = src.fNumLeafLayers;
140 fSaveStack = src.fSaveStack; 146 fSaveStack = src.fSaveStack;
141 } 147 }
142 148
143 void SkPictureContentInfo::reset() { 149 void SkPictureContentInfo::reset() {
144 fNumOperations = 0; 150 fNumOperations = 0;
145 fNumTexts = 0; 151 fNumTexts = 0;
146 fNumPaintWithPathEffectUses = 0; 152 fNumPaintWithPathEffectUses = 0;
147 fNumFastPathDashEffects = 0; 153 fNumFastPathDashEffects = 0;
148 fNumAAConcavePaths = 0; 154 fNumAAConcavePaths = 0;
149 fNumAAHairlineConcavePaths = 0; 155 fNumAAHairlineConcavePaths = 0;
156 fNumAADFEligibleConcavePaths = 0;
150 fNumLayers = 0; 157 fNumLayers = 0;
151 fNumInteriorLayers = 0; 158 fNumInteriorLayers = 0;
152 fNumLeafLayers = 0; 159 fNumLeafLayers = 0;
153 fSaveStack.rewind(); 160 fSaveStack.rewind();
154 } 161 }
155 162
156 void SkPictureContentInfo::swap(SkPictureContentInfo* other) { 163 void SkPictureContentInfo::swap(SkPictureContentInfo* other) {
157 SkTSwap(fNumOperations, other->fNumOperations); 164 SkTSwap(fNumOperations, other->fNumOperations);
158 SkTSwap(fNumTexts, other->fNumTexts); 165 SkTSwap(fNumTexts, other->fNumTexts);
159 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses); 166 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses);
160 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects); 167 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects);
161 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths); 168 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
162 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths); 169 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths);
170 SkTSwap(fNumAADFEligibleConcavePaths, other->fNumAADFEligibleConcavePaths);
163 SkTSwap(fNumLayers, other->fNumLayers); 171 SkTSwap(fNumLayers, other->fNumLayers);
164 SkTSwap(fNumInteriorLayers, other->fNumInteriorLayers); 172 SkTSwap(fNumInteriorLayers, other->fNumInteriorLayers);
165 SkTSwap(fNumLeafLayers, other->fNumLeafLayers); 173 SkTSwap(fNumLeafLayers, other->fNumLeafLayers);
166 fSaveStack.swap(other->fSaveStack); 174 fSaveStack.swap(other->fSaveStack);
167 } 175 }
OLDNEW
« no previous file with comments | « src/core/SkPictureContentInfo.h ('k') | src/gpu/GrAddPathRenderers_default.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698