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

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

Issue 858343002: Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits Created 5 years, 11 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
« no previous file with comments | « src/gpu/GrStencilAndCoverPathRenderer.h ('k') | src/gpu/GrStencilAndCoverTextContext.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 2012 Google Inc. 3 * Copyright 2012 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 "GrStencilAndCoverPathRenderer.h" 10 #include "GrStencilAndCoverPathRenderer.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 SkASSERT(gpu->caps()->pathRenderingSupport()); 44 SkASSERT(gpu->caps()->pathRenderingSupport());
45 fGpu = gpu; 45 fGpu = gpu;
46 gpu->ref(); 46 gpu->ref();
47 } 47 }
48 48
49 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() { 49 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() {
50 fGpu->unref(); 50 fGpu->unref();
51 } 51 }
52 52
53 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target, 53 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target,
54 const GrDrawState* drawState, 54 const GrPipelineBuilder* pipelin eBuilder,
55 const SkMatrix& viewMatrix, 55 const SkMatrix& viewMatrix,
56 const SkPath& path, 56 const SkPath& path,
57 const SkStrokeRec& stroke, 57 const SkStrokeRec& stroke,
58 bool antiAlias) const { 58 bool antiAlias) const {
59 return !stroke.isHairlineStyle() && 59 return !stroke.isHairlineStyle() &&
60 !antiAlias && // doesn't do per-path AA, relies on the target having MSAA 60 !antiAlias && // doesn't do per-path AA, relies on the target having MSAA
61 drawState->getRenderTarget()->getStencilBuffer() && 61 pipelineBuilder->getRenderTarget()->getStencilBuffer() &&
62 drawState->getStencil().isDisabled(); 62 pipelineBuilder->getStencil().isDisabled();
63 } 63 }
64 64
65 GrPathRenderer::StencilSupport 65 GrPathRenderer::StencilSupport
66 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, 66 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*,
67 const GrDrawState*, 67 const GrPipelineBuilder*,
68 const SkPath&, 68 const SkPath&,
69 const SkStrokeRec&) const { 69 const SkStrokeRec&) const {
70 return GrPathRenderer::kStencilOnly_StencilSupport; 70 return GrPathRenderer::kStencilOnly_StencilSupport;
71 } 71 }
72 72
73 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) { 73 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) {
74 GrContext* ctx = gpu->getContext(); 74 GrContext* ctx = gpu->getContext();
75 GrResourceKey resourceKey = GrPath::ComputeKey(skPath, stroke); 75 GrResourceKey resourceKey = GrPath::ComputeKey(skPath, stroke);
76 SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource (resourceKey))); 76 SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource (resourceKey)));
77 if (NULL == path || !path->isEqualTo(skPath, stroke)) { 77 if (NULL == path || !path->isEqualTo(skPath, stroke)) {
78 path.reset(gpu->pathRendering()->createPath(skPath, stroke)); 78 path.reset(gpu->pathRendering()->createPath(skPath, stroke));
79 ctx->addResourceToCache(resourceKey, path); 79 ctx->addResourceToCache(resourceKey, path);
80 } 80 }
81 return path.detach(); 81 return path.detach();
82 } 82 }
83 83
84 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, 84 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target,
85 GrDrawState* drawState, 85 GrPipelineBuilder* pipelineBui lder,
86 const SkMatrix& viewMatrix, 86 const SkMatrix& viewMatrix,
87 const SkPath& path, 87 const SkPath& path,
88 const SkStrokeRec& stroke) { 88 const SkStrokeRec& stroke) {
89 SkASSERT(!path.isInverseFillType()); 89 SkASSERT(!path.isInverseFillType());
90 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view Matrix)); 90 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view Matrix));
91 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); 91 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
92 target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFillTy pe())); 92 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get FillType()));
93 } 93 }
94 94
95 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, 95 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
96 GrDrawState* drawState, 96 GrPipelineBuilder* pipelineBuilde r,
97 GrColor color, 97 GrColor color,
98 const SkMatrix& viewMatrix, 98 const SkMatrix& viewMatrix,
99 const SkPath& path, 99 const SkPath& path,
100 const SkStrokeRec& stroke, 100 const SkStrokeRec& stroke,
101 bool antiAlias) { 101 bool antiAlias) {
102 SkASSERT(!antiAlias); 102 SkASSERT(!antiAlias);
103 SkASSERT(!stroke.isHairlineStyle()); 103 SkASSERT(!stroke.isHairlineStyle());
104 104
105 SkASSERT(drawState->getStencil().isDisabled()); 105 SkASSERT(pipelineBuilder->getStencil().isDisabled());
106 106
107 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); 107 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
108 108
109 if (path.isInverseFillType()) { 109 if (path.isInverseFillType()) {
110 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, 110 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass,
111 kZero_StencilOp, 111 kZero_StencilOp,
112 kZero_StencilOp, 112 kZero_StencilOp,
113 // We know our rect will hit pixels outside the clip and the user bi ts will be 0 113 // We know our rect will hit pixels outside the clip and the user bi ts will be 0
114 // outside the clip. So we can't just fill where the user bits are 0 . We also need to 114 // outside the clip. So we can't just fill where the user bits are 0 . We also need to
115 // check that the clip bit is set. 115 // check that the clip bit is set.
116 kEqualIfInClip_StencilFunc, 116 kEqualIfInClip_StencilFunc,
117 0xffff, 117 0xffff,
118 0x0000, 118 0x0000,
119 0xffff); 119 0xffff);
120 120
121 drawState->setStencil(kInvertedStencilPass); 121 pipelineBuilder->setStencil(kInvertedStencilPass);
122 122
123 // fake inverse with a stencil and cover 123 // fake inverse with a stencil and cover
124 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, viewMatrix)); 124 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, viewMatrix));
125 target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFi llType())); 125 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path .getFillType()));
126 126
127 SkMatrix invert = SkMatrix::I(); 127 SkMatrix invert = SkMatrix::I();
128 SkRect bounds = SkRect::MakeLTRB(0, 0, 128 SkRect bounds =
129 SkIntToScalar(drawState->getRenderTarge t()->width()), 129 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge t()->width()),
130 SkIntToScalar(drawState->getRenderTarge t()->height())); 130 SkIntToScalar(pipelineBuilder->getRenderTarget()->h eight()));
131 SkMatrix vmi; 131 SkMatrix vmi;
132 // mapRect through persp matrix may not be correct 132 // mapRect through persp matrix may not be correct
133 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { 133 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) {
134 vmi.mapRect(&bounds); 134 vmi.mapRect(&bounds);
135 // theoretically could set bloat = 0, instead leave it because of ma trix inversion 135 // theoretically could set bloat = 0, instead leave it because of ma trix inversion
136 // precision. 136 // precision.
137 SkScalar bloat = viewMatrix.getMaxScale() * SK_ScalarHalf; 137 SkScalar bloat = viewMatrix.getMaxScale() * SK_ScalarHalf;
138 bounds.outset(bloat, bloat); 138 bounds.outset(bloat, bloat);
139 } else { 139 } else {
140 if (!viewMatrix.invert(&invert)) { 140 if (!viewMatrix.invert(&invert)) {
141 return false; 141 return false;
142 } 142 }
143 } 143 }
144 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi ewMatrix; 144 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi ewMatrix;
145 target->drawRect(drawState, color, viewM, bounds, NULL, &invert); 145 target->drawRect(pipelineBuilder, color, viewM, bounds, NULL, &invert);
146 } else { 146 } else {
147 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, 147 GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
148 kZero_StencilOp, 148 kZero_StencilOp,
149 kZero_StencilOp, 149 kZero_StencilOp,
150 kNotEqual_StencilFunc, 150 kNotEqual_StencilFunc,
151 0xffff, 151 0xffff,
152 0x0000, 152 0x0000,
153 0xffff); 153 0xffff);
154 154
155 drawState->setStencil(kStencilPass); 155 pipelineBuilder->setStencil(kStencilPass);
156 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix)); 156 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix));
157 target->drawPath(drawState, pp, p, convert_skpath_filltype(path.getFillT ype())); 157 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType()));
158 } 158 }
159 159
160 drawState->stencil()->setDisabled(); 160 pipelineBuilder->stencil()->setDisabled();
161 return true; 161 return true;
162 } 162 }
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAndCoverPathRenderer.h ('k') | src/gpu/GrStencilAndCoverTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698