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

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

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

Powered by Google App Engine
This is Rietveld 408576698