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