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

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

Issue 1400343004: Fix clipping when all analytic FP creations can be skipped (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix speeling Created 5 years, 2 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/GrClipMaskManager.h ('k') | no next file » | 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 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrClipMaskManager.h" 8 #include "GrClipMaskManager.h"
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 element->asPath(&path); 101 element->asPath(&path);
102 if (path_needs_SW_renderer(this->getContext(), fDrawTarget, pipeline Builder, translate, 102 if (path_needs_SW_renderer(this->getContext(), fDrawTarget, pipeline Builder, translate,
103 path, stroke, element->isAA())) { 103 path, stroke, element->isAA())) {
104 return true; 104 return true;
105 } 105 }
106 } 106 }
107 } 107 }
108 return false; 108 return false;
109 } 109 }
110 110
111 const GrFragmentProcessor* GrClipMaskManager::getAnalyticClipProcessor( 111 bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis t& elements,
112 const GrReducedClip::Ele mentList& elements, 112 SkVector& clipToRTOffset,
113 const SkVector& clipToRT Offset, 113 const SkRect* drawBounds,
114 const SkRect* drawBounds ) { 114 const GrFragmentProcessor** res ultFP) {
115 SkRect boundsInClipSpace; 115 SkRect boundsInClipSpace;
116 if (drawBounds) { 116 if (drawBounds) {
117 boundsInClipSpace = *drawBounds; 117 boundsInClipSpace = *drawBounds;
118 boundsInClipSpace.offset(-clipToRTOffset.fX, -clipToRTOffset.fY); 118 boundsInClipSpace.offset(-clipToRTOffset.fX, -clipToRTOffset.fY);
119 } 119 }
120 SkASSERT(elements.count() <= kMaxAnalyticElements); 120 SkASSERT(elements.count() <= kMaxAnalyticElements);
121 const GrFragmentProcessor* fps[kMaxAnalyticElements]; 121 const GrFragmentProcessor* fps[kMaxAnalyticElements];
122 for (int i = 0; i < kMaxAnalyticElements; ++i) { 122 for (int i = 0; i < kMaxAnalyticElements; ++i) {
123 fps[i] = nullptr; 123 fps[i] = nullptr;
124 } 124 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 if (!fps[fpCnt]) { 184 if (!fps[fpCnt]) {
185 failed = true; 185 failed = true;
186 break; 186 break;
187 } 187 }
188 fpCnt++; 188 fpCnt++;
189 } 189 }
190 iter.next(); 190 iter.next();
191 } 191 }
192 192
193 const GrFragmentProcessor* resultFP = nullptr; 193 *resultFP = nullptr;
194 if (!failed) { 194 if (!failed && fpCnt) {
195 resultFP = GrFragmentProcessor::RunInSeries(fps, fpCnt); 195 *resultFP = GrFragmentProcessor::RunInSeries(fps, fpCnt);
196 } 196 }
197 for (int i = 0; i < fpCnt; ++i) { 197 for (int i = 0; i < fpCnt; ++i) {
198 fps[i]->unref(); 198 fps[i]->unref();
199 } 199 }
200 return resultFP; 200 return !failed;
201 } 201 }
202 202
203 //////////////////////////////////////////////////////////////////////////////// 203 ////////////////////////////////////////////////////////////////////////////////
204 // sort out what kind of clip mask needs to be created: alpha, stencil, 204 // sort out what kind of clip mask needs to be created: alpha, stencil,
205 // scissor, or entirely software 205 // scissor, or entirely software
206 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, 206 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
207 GrPipelineBuilder::AutoRestoreStencil* ars , 207 GrPipelineBuilder::AutoRestoreStencil* ars ,
208 GrScissorState* scissorState, 208 GrScissorState* scissorState,
209 const SkRect* devBounds, 209 const SkRect* devBounds,
210 GrAppliedClip* out) { 210 GrAppliedClip* out) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // longer shaders. 276 // longer shaders.
277 if (elements.count() <= kMaxAnalyticElements) { 277 if (elements.count() <= kMaxAnalyticElements) {
278 SkVector clipToRTOffset = { SkIntToScalar(-clip.origin().fX), 278 SkVector clipToRTOffset = { SkIntToScalar(-clip.origin().fX),
279 SkIntToScalar(-clip.origin().fY) }; 279 SkIntToScalar(-clip.origin().fY) };
280 // When there are multiple color samples we want to do per-sample clippi ng, not compute 280 // When there are multiple color samples we want to do per-sample clippi ng, not compute
281 // a fractional pixel coverage. 281 // a fractional pixel coverage.
282 bool disallowAnalyticAA = pipelineBuilder.getRenderTarget()->isUnifiedMu ltisampled(); 282 bool disallowAnalyticAA = pipelineBuilder.getRenderTarget()->isUnifiedMu ltisampled();
283 const GrFragmentProcessor* clipFP = nullptr; 283 const GrFragmentProcessor* clipFP = nullptr;
284 if (elements.isEmpty() || 284 if (elements.isEmpty() ||
285 (requiresAA && !disallowAnalyticAA && 285 (requiresAA && !disallowAnalyticAA &&
286 SkToBool(clipFP = this->getAnalyticClipProcessor(elements, clipToRT Offset, devBounds)))) { 286 this->getAnalyticClipProcessor(elements, clipToRTOffset, devBounds, &clipFP))) {
287 SkIRect scissorSpaceIBounds(clipSpaceIBounds); 287 SkIRect scissorSpaceIBounds(clipSpaceIBounds);
288 scissorSpaceIBounds.offset(-clip.origin()); 288 scissorSpaceIBounds.offset(-clip.origin());
289 if (nullptr == devBounds || 289 if (nullptr == devBounds ||
290 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { 290 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
291 scissorState->set(scissorSpaceIBounds); 291 scissorState->set(scissorSpaceIBounds);
292 } 292 }
293 this->setPipelineBuilderStencil(pipelineBuilder, ars); 293 this->setPipelineBuilderStencil(pipelineBuilder, ars);
294 out->fClipCoverageFP.reset(clipFP); 294 out->fClipCoverageFP.reset(clipFP);
295 return true; 295 return true;
296 } 296 }
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1111
1112 //////////////////////////////////////////////////////////////////////////////// 1112 ////////////////////////////////////////////////////////////////////////////////
1113 1113
1114 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment, 1114 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment,
1115 GrStencilSettings* settings) { 1115 GrStencilSettings* settings) {
1116 if (stencilAttachment) { 1116 if (stencilAttachment) {
1117 int stencilBits = stencilAttachment->bits(); 1117 int stencilBits = stencilAttachment->bits();
1118 this->adjustStencilParams(settings, fClipMode, stencilBits); 1118 this->adjustStencilParams(settings, fClipMode, stencilBits);
1119 } 1119 }
1120 } 1120 }
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698