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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SkTLazy<SkPath> tmpPath; | 1154 SkTLazy<SkPath> tmpPath; |
1155 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); | 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::AutoClearPath acp(this->getPathRenderer(*pathPtr, *stroke, | 1158 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, *stroke, target, false,
type); |
1159 target, false, type, | |
1160 pathPtr->getFillType())); | |
1161 | 1159 |
1162 if (NULL == acp.renderer()) { | 1160 if (NULL == pr) { |
1163 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatr
ix(), NULL)) { | 1161 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatr
ix(), NULL)) { |
1164 // 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 |
1165 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { | 1163 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { |
1166 pathPtr = tmpPath.get(); | 1164 pathPtr = tmpPath.get(); |
1167 stroke.writable()->setFillStyle(); | 1165 stroke.writable()->setFillStyle(); |
1168 if (pathPtr->isEmpty()) { | 1166 if (pathPtr->isEmpty()) { |
1169 return; | 1167 return; |
1170 } | 1168 } |
1171 } | 1169 } |
1172 } | 1170 } |
1173 | 1171 |
1174 // This time, allow SW renderer | 1172 // This time, allow SW renderer |
1175 acp.set(this->getPathRenderer(*pathPtr, *stroke, target, true, type, | 1173 pr = this->getPathRenderer(*pathPtr, *stroke, target, true, type); |
1176 pathPtr->getFillType())); | |
1177 } | 1174 } |
1178 | 1175 |
1179 if (NULL == acp.renderer()) { | 1176 if (NULL == pr) { |
1180 #ifdef SK_DEBUG | 1177 #ifdef SK_DEBUG |
1181 GrPrintf("Unable to find path renderer compatible with path.\n"); | 1178 GrPrintf("Unable to find path renderer compatible with path.\n"); |
1182 #endif | 1179 #endif |
1183 return; | 1180 return; |
1184 } | 1181 } |
1185 | 1182 |
1186 acp->drawPath(*stroke, target, useCoverageAA); | 1183 pr->drawPath(*pathPtr, *stroke, target, useCoverageAA); |
1187 } | 1184 } |
1188 | 1185 |
1189 //////////////////////////////////////////////////////////////////////////////// | 1186 //////////////////////////////////////////////////////////////////////////////// |
1190 | 1187 |
1191 void GrContext::flush(int flagsBitfield) { | 1188 void GrContext::flush(int flagsBitfield) { |
1192 if (NULL == fDrawBuffer) { | 1189 if (NULL == fDrawBuffer) { |
1193 return; | 1190 return; |
1194 } | 1191 } |
1195 | 1192 |
1196 if (kDiscard_FlushBit & flagsBitfield) { | 1193 if (kDiscard_FlushBit & flagsBitfield) { |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 * This method finds a path renderer that can draw the specified path on | 1669 * This method finds a path renderer that can draw the specified path on |
1673 * the provided target. | 1670 * the provided target. |
1674 * Due to its expense, the software path renderer has split out so it can | 1671 * Due to its expense, the software path renderer has split out so it can |
1675 * can be individually allowed/disallowed via the "allowSW" boolean. | 1672 * can be individually allowed/disallowed via the "allowSW" boolean. |
1676 */ | 1673 */ |
1677 GrPathRenderer* GrContext::getPathRenderer(const SkPath& path, | 1674 GrPathRenderer* GrContext::getPathRenderer(const SkPath& path, |
1678 const SkStrokeRec& stroke, | 1675 const SkStrokeRec& stroke, |
1679 const GrDrawTarget* target, | 1676 const GrDrawTarget* target, |
1680 bool allowSW, | 1677 bool allowSW, |
1681 GrPathRendererChain::DrawType drawTyp
e, | 1678 GrPathRendererChain::DrawType drawTyp
e, |
1682 SkPath::FillType fillType, | |
1683 GrPathRendererChain::StencilSupport*
stencilSupport) { | 1679 GrPathRendererChain::StencilSupport*
stencilSupport) { |
1684 | 1680 |
1685 if (NULL == fPathRendererChain) { | 1681 if (NULL == fPathRendererChain) { |
1686 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this)); | 1682 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this)); |
1687 } | 1683 } |
1688 | 1684 |
1689 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(path, | 1685 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(path, |
1690 stroke, | 1686 stroke, |
1691 target, | 1687 target, |
1692 drawType, | 1688 drawType, |
1693 fillType, | |
1694 stencilSupport); | 1689 stencilSupport); |
1695 | 1690 |
1696 if (NULL == pr && allowSW) { | 1691 if (NULL == pr && allowSW) { |
1697 if (NULL == fSoftwarePathRenderer) { | 1692 if (NULL == fSoftwarePathRenderer) { |
1698 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); | 1693 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); |
1699 } | 1694 } |
1700 pr = fSoftwarePathRenderer; | 1695 pr = fSoftwarePathRenderer; |
1701 pr->setPath(path, fillType); | |
1702 } | 1696 } |
1703 | 1697 |
1704 return pr; | 1698 return pr; |
1705 } | 1699 } |
1706 | 1700 |
1707 //////////////////////////////////////////////////////////////////////////////// | 1701 //////////////////////////////////////////////////////////////////////////////// |
1708 bool GrContext::isConfigRenderable(GrPixelConfig config, bool withMSAA) const { | 1702 bool GrContext::isConfigRenderable(GrPixelConfig config, bool withMSAA) const { |
1709 return fGpu->caps()->isConfigRenderable(config, withMSAA); | 1703 return fGpu->caps()->isConfigRenderable(config, withMSAA); |
1710 } | 1704 } |
1711 | 1705 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 } | 1789 } |
1796 return path; | 1790 return path; |
1797 } | 1791 } |
1798 | 1792 |
1799 /////////////////////////////////////////////////////////////////////////////// | 1793 /////////////////////////////////////////////////////////////////////////////// |
1800 #if GR_CACHE_STATS | 1794 #if GR_CACHE_STATS |
1801 void GrContext::printCacheStats() const { | 1795 void GrContext::printCacheStats() const { |
1802 fTextureCache->printStats(); | 1796 fTextureCache->printStats(); |
1803 } | 1797 } |
1804 #endif | 1798 #endif |
OLD | NEW |