OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 SkRect ovalRect; | 1127 SkRect ovalRect; |
1128 bool isOval = path.isOval(&ovalRect); | 1128 bool isOval = path.isOval(&ovalRect); |
1129 | 1129 |
1130 if (!isOval || path.isInverseFillType() | 1130 if (!isOval || path.isInverseFillType() |
1131 || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect,
stroke)) { | 1131 || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect,
stroke)) { |
1132 this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); | 1132 this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); |
1133 } | 1133 } |
1134 } | 1134 } |
1135 | 1135 |
1136 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
path, | 1136 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
path, |
1137 const SkStrokeRec& stroke) { | 1137 const SkStrokeRec& origStroke) { |
1138 SkASSERT(!path.isEmpty()); | 1138 SkASSERT(!path.isEmpty()); |
1139 | 1139 |
1140 // An Assumption here is that path renderer would use some form of tweaking | 1140 // An Assumption here is that path renderer would use some form of tweaking |
1141 // the src color (either the input alpha or in the frag shader) to implement | 1141 // the src color (either the input alpha or in the frag shader) to implement |
1142 // aa. If we have some future driver-mojo path AA that can do the right | 1142 // aa. If we have some future driver-mojo path AA that can do the right |
1143 // thing WRT to the blend then we'll need some query on the PR. | 1143 // thing WRT to the blend then we'll need some query on the PR. |
1144 bool useCoverageAA = useAA && | 1144 bool useCoverageAA = useAA && |
1145 !target->getDrawState().getRenderTarget()->isMultisampled() && | 1145 !target->getDrawState().getRenderTarget()->isMultisampled() && |
1146 !target->shouldDisableCoverageAAForBlend(); | 1146 !target->shouldDisableCoverageAAForBlend(); |
1147 | 1147 |
1148 | 1148 |
1149 GrPathRendererChain::DrawType type = | 1149 GrPathRendererChain::DrawType type = |
1150 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : | 1150 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : |
1151 GrPathRendererChain::kColor_DrawType; | 1151 GrPathRendererChain::kColor_DrawType; |
1152 | 1152 |
1153 const SkPath* pathPtr = &path; | 1153 const SkPath* pathPtr = &path; |
1154 SkPath tmpPath; | 1154 SkTLazy<SkPath> tmpPath; |
1155 SkStrokeRec strokeRec(stroke); | 1155 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); |
1156 | 1156 |
1157 // Try a 1st time without stroking the path and without allowing the SW rend
erer | 1157 // Try a 1st time without stroking the path and without allowing the SW rend
erer |
1158 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, strokeRec, target, fals
e, type); | 1158 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, *stroke, target, false,
type); |
1159 | 1159 |
1160 if (NULL == pr) { | 1160 if (NULL == pr) { |
1161 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(strokeRec, this->getMa
trix(), NULL)) { | 1161 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatr
ix(), NULL)) { |
1162 // It didn't work the 1st time, so try again with the stroked path | 1162 // It didn't work the 1st time, so try again with the stroked path |
1163 if (strokeRec.applyToPath(&tmpPath, *pathPtr)) { | 1163 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { |
1164 pathPtr = &tmpPath; | 1164 pathPtr = tmpPath.get(); |
1165 strokeRec.setFillStyle(); | 1165 stroke.writable()->setFillStyle(); |
1166 if (pathPtr->isEmpty()) { | 1166 if (pathPtr->isEmpty()) { |
1167 return; | 1167 return; |
1168 } | 1168 } |
1169 } | 1169 } |
1170 } | 1170 } |
1171 | 1171 |
1172 // This time, allow SW renderer | 1172 // This time, allow SW renderer |
1173 pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type); | 1173 pr = this->getPathRenderer(*pathPtr, *stroke, target, true, type); |
1174 } | 1174 } |
1175 | 1175 |
1176 if (NULL == pr) { | 1176 if (NULL == pr) { |
1177 #ifdef SK_DEBUG | 1177 #ifdef SK_DEBUG |
1178 GrPrintf("Unable to find path renderer compatible with path.\n"); | 1178 GrPrintf("Unable to find path renderer compatible with path.\n"); |
1179 #endif | 1179 #endif |
1180 return; | 1180 return; |
1181 } | 1181 } |
1182 | 1182 |
1183 pr->drawPath(*pathPtr, strokeRec, target, useCoverageAA); | 1183 pr->drawPath(*pathPtr, *stroke, target, useCoverageAA); |
1184 } | 1184 } |
1185 | 1185 |
1186 //////////////////////////////////////////////////////////////////////////////// | 1186 //////////////////////////////////////////////////////////////////////////////// |
1187 | 1187 |
1188 void GrContext::flush(int flagsBitfield) { | 1188 void GrContext::flush(int flagsBitfield) { |
1189 if (NULL == fDrawBuffer) { | 1189 if (NULL == fDrawBuffer) { |
1190 return; | 1190 return; |
1191 } | 1191 } |
1192 | 1192 |
1193 if (kDiscard_FlushBit & flagsBitfield) { | 1193 if (kDiscard_FlushBit & flagsBitfield) { |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 } | 1789 } |
1790 return path; | 1790 return path; |
1791 } | 1791 } |
1792 | 1792 |
1793 /////////////////////////////////////////////////////////////////////////////// | 1793 /////////////////////////////////////////////////////////////////////////////// |
1794 #if GR_CACHE_STATS | 1794 #if GR_CACHE_STATS |
1795 void GrContext::printCacheStats() const { | 1795 void GrContext::printCacheStats() const { |
1796 fTextureCache->printStats(); | 1796 fTextureCache->printStats(); |
1797 } | 1797 } |
1798 #endif | 1798 #endif |
OLD | NEW |