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

Side by Side Diff: src/gpu/GrPathRendererChain.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/GrPathRenderer.h ('k') | src/gpu/GrSoftwarePathRenderer.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 "GrPathRendererChain.h" 10 #include "GrPathRendererChain.h"
(...skipping 17 matching lines...) Expand all
28 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { 28 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) {
29 fChain.push_back() = pr; 29 fChain.push_back() = pr;
30 pr->ref(); 30 pr->ref();
31 return pr; 31 return pr;
32 } 32 }
33 33
34 GrPathRenderer* GrPathRendererChain::getPathRenderer(const SkPath& path, 34 GrPathRenderer* GrPathRendererChain::getPathRenderer(const SkPath& path,
35 const SkStrokeRec& stroke, 35 const SkStrokeRec& stroke,
36 const GrDrawTarget* target, 36 const GrDrawTarget* target,
37 DrawType drawType, 37 DrawType drawType,
38 SkPath::FillType fillType,
38 StencilSupport* stencilSupp ort) { 39 StencilSupport* stencilSupp ort) {
39 if (!fInit) { 40 if (!fInit) {
40 this->init(); 41 this->init();
41 } 42 }
42 bool antiAlias = (kColorAntiAlias_DrawType == drawType || 43 bool antiAlias = (kColorAntiAlias_DrawType == drawType ||
43 kStencilAndColorAntiAlias_DrawType == drawType); 44 kStencilAndColorAntiAlias_DrawType == drawType);
44 45
45 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < 46 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport <
46 GrPathRenderer::kStencilOnly_StencilSupport); 47 GrPathRenderer::kStencilOnly_StencilSupport);
47 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < 48 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport <
48 GrPathRenderer::kNoRestriction_StencilSupport); 49 GrPathRenderer::kNoRestriction_StencilSupport);
49 GrPathRenderer::StencilSupport minStencilSupport; 50 GrPathRenderer::StencilSupport minStencilSupport;
50 if (kStencilOnly_DrawType == drawType) { 51 if (kStencilOnly_DrawType == drawType) {
51 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; 52 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport;
52 } else if (kStencilAndColor_DrawType == drawType || 53 } else if (kStencilAndColor_DrawType == drawType ||
53 kStencilAndColorAntiAlias_DrawType == drawType) { 54 kStencilAndColorAntiAlias_DrawType == drawType) {
54 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; 55 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
55 } else { 56 } else {
56 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; 57 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport;
57 } 58 }
58 59
59
60 for (int i = 0; i < fChain.count(); ++i) { 60 for (int i = 0; i < fChain.count(); ++i) {
61 if (fChain[i]->canDrawPath(path, stroke, target, antiAlias)) { 61 fChain[i]->setPath(path, fillType);
62 if (fChain[i]->canDrawPath(stroke, target, antiAlias)) {
62 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) { 63 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) {
63 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSu pport(path, 64 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSu pport(stroke,
64 stroke,
65 target); 65 target);
66 if (support < minStencilSupport) { 66 if (support < minStencilSupport) {
67 continue; 67 continue;
68 } else if (NULL != stencilSupport) { 68 } else if (NULL != stencilSupport) {
69 *stencilSupport = support; 69 *stencilSupport = support;
70 } 70 }
71 } 71 }
72 return fChain[i]; 72 return fChain[i];
73 } 73 }
74 fChain[i]->resetPath();
74 } 75 }
75 return NULL; 76 return NULL;
76 } 77 }
77 78
78 void GrPathRendererChain::init() { 79 void GrPathRendererChain::init() {
79 SkASSERT(!fInit); 80 SkASSERT(!fInit);
80 GrGpu* gpu = fOwner->getGpu(); 81 GrGpu* gpu = fOwner->getGpu();
81 bool twoSided = gpu->caps()->twoSidedStencilSupport(); 82 bool twoSided = gpu->caps()->twoSidedStencilSupport();
82 bool wrapOp = gpu->caps()->stencilWrapOpsSupport(); 83 bool wrapOp = gpu->caps()->stencilWrapOpsSupport();
83 GrPathRenderer::AddPathRenderers(fOwner, this); 84 GrPathRenderer::AddPathRenderers(fOwner, this);
84 this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer, 85 this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer,
85 (twoSided, wrapOp)))->unref(); 86 (twoSided, wrapOp)))->unref();
86 fInit = true; 87 fInit = true;
87 } 88 }
OLDNEW
« no previous file with comments | « src/gpu/GrPathRenderer.h ('k') | src/gpu/GrSoftwarePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698