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

Side by Side Diff: src/gpu/GrContext.cpp

Issue 23926019: Stateful PathRenderer implementation (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: clean up Created 7 years, 3 months 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 | Annotate | Revision Log
OLDNEW
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 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 } 1130 }
1131 1131
1132 GrPathRendererChain::DrawType type = useAA ? GrPathRendererChain::kColorAnti Alias_DrawType : 1132 GrPathRendererChain::DrawType type = useAA ? GrPathRendererChain::kColorAnti Alias_DrawType :
1133 GrPathRendererChain::kColor_Dra wType; 1133 GrPathRendererChain::kColor_Dra wType;
1134 1134
1135 const SkPath* pathPtr = &path; 1135 const SkPath* pathPtr = &path;
1136 SkPath tmpPath; 1136 SkPath tmpPath;
1137 SkStrokeRec strokeRec(stroke); 1137 SkStrokeRec strokeRec(stroke);
1138 1138
1139 // Try a 1st time without stroking the path and without allowing the SW rend erer 1139 // Try a 1st time without stroking the path and without allowing the SW rend erer
1140 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, strokeRec, target, fals e, type); 1140 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, strokeRec, target, fals e, type,
1141 pathPtr->getFillType());
1141 1142
1142 if (NULL == pr) { 1143 if (NULL == pr) {
1143 if (!strokeRec.isHairlineStyle()) { 1144 if (!strokeRec.isHairlineStyle()) {
1144 // It didn't work the 1st time, so try again with the stroked path 1145 // It didn't work the 1st time, so try again with the stroked path
1145 if (strokeRec.applyToPath(&tmpPath, *pathPtr)) { 1146 if (strokeRec.applyToPath(&tmpPath, *pathPtr)) {
1146 pathPtr = &tmpPath; 1147 pathPtr = &tmpPath;
1147 strokeRec.setFillStyle(); 1148 strokeRec.setFillStyle();
1148 } 1149 }
1149 } 1150 }
1150 if (pathPtr->isEmpty()) { 1151 if (pathPtr->isEmpty()) {
1151 return; 1152 return;
1152 } 1153 }
1153 1154
1154 // This time, allow SW renderer 1155 // This time, allow SW renderer
1155 pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type); 1156 pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type,
1157 pathPtr->getFillType());
1156 } 1158 }
1157 1159
1158 if (NULL == pr) { 1160 if (NULL == pr) {
1159 #ifdef SK_DEBUG 1161 #ifdef SK_DEBUG
1160 GrPrintf("Unable to find path renderer compatible with path.\n"); 1162 GrPrintf("Unable to find path renderer compatible with path.\n");
1161 #endif 1163 #endif
1162 return; 1164 return;
1163 } 1165 }
1164 1166
1165 pr->drawPath(*pathPtr, strokeRec, target, useAA); 1167 pr->drawPath(strokeRec, target, useAA);
1166 } 1168 }
1167 1169
1168 //////////////////////////////////////////////////////////////////////////////// 1170 ////////////////////////////////////////////////////////////////////////////////
1169 1171
1170 void GrContext::flush(int flagsBitfield) { 1172 void GrContext::flush(int flagsBitfield) {
1171 if (NULL == fDrawBuffer) { 1173 if (NULL == fDrawBuffer) {
1172 return; 1174 return;
1173 } 1175 }
1174 1176
1175 if (kDiscard_FlushBit & flagsBitfield) { 1177 if (kDiscard_FlushBit & flagsBitfield) {
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 * This method finds a path renderer that can draw the specified path on 1630 * This method finds a path renderer that can draw the specified path on
1629 * the provided target. 1631 * the provided target.
1630 * Due to its expense, the software path renderer has split out so it can 1632 * Due to its expense, the software path renderer has split out so it can
1631 * can be individually allowed/disallowed via the "allowSW" boolean. 1633 * can be individually allowed/disallowed via the "allowSW" boolean.
1632 */ 1634 */
1633 GrPathRenderer* GrContext::getPathRenderer(const SkPath& path, 1635 GrPathRenderer* GrContext::getPathRenderer(const SkPath& path,
1634 const SkStrokeRec& stroke, 1636 const SkStrokeRec& stroke,
1635 const GrDrawTarget* target, 1637 const GrDrawTarget* target,
1636 bool allowSW, 1638 bool allowSW,
1637 GrPathRendererChain::DrawType drawTyp e, 1639 GrPathRendererChain::DrawType drawTyp e,
1640 SkPath::FillType fillType,
1638 GrPathRendererChain::StencilSupport* stencilSupport) { 1641 GrPathRendererChain::StencilSupport* stencilSupport) {
1639 1642
1640 if (NULL == fPathRendererChain) { 1643 if (NULL == fPathRendererChain) {
1641 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this)); 1644 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this));
1642 } 1645 }
1643 1646
1644 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(path, 1647 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(path,
1645 stroke, 1648 stroke,
1646 target, 1649 target,
1647 drawType, 1650 drawType,
1651 fillType,
1648 stencilSupport); 1652 stencilSupport);
1649 1653
1650 if (NULL == pr && allowSW) { 1654 if (NULL == pr && allowSW) {
1651 if (NULL == fSoftwarePathRenderer) { 1655 if (NULL == fSoftwarePathRenderer) {
1652 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); 1656 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this));
1653 } 1657 }
1654 pr = fSoftwarePathRenderer; 1658 pr = fSoftwarePathRenderer;
1659 pr->setPath(path, fillType);
1655 } 1660 }
1656 1661
1657 return pr; 1662 return pr;
1658 } 1663 }
1659 1664
1660 //////////////////////////////////////////////////////////////////////////////// 1665 ////////////////////////////////////////////////////////////////////////////////
1661 1666
1662 bool GrContext::isConfigRenderable(GrPixelConfig config) const { 1667 bool GrContext::isConfigRenderable(GrPixelConfig config) const {
1663 return fGpu->isConfigRenderable(config); 1668 return fGpu->isConfigRenderable(config);
1664 } 1669 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 return NULL; 1748 return NULL;
1744 } 1749 }
1745 } 1750 }
1746 1751
1747 /////////////////////////////////////////////////////////////////////////////// 1752 ///////////////////////////////////////////////////////////////////////////////
1748 #if GR_CACHE_STATS 1753 #if GR_CACHE_STATS
1749 void GrContext::printCacheStats() const { 1754 void GrContext::printCacheStats() const {
1750 fTextureCache->printStats(); 1755 fTextureCache->printStats();
1751 } 1756 }
1752 #endif 1757 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698