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

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

Issue 1440513002: Enable AA stencil clip for mixed samples (Closed) Base URL: https://skia.googlesource.com/skia.git@reverts2.2
Patch Set: Created 5 years, 1 month 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 | « no previous file | src/gpu/GrPipelineBuilder.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 * 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 "GrDrawingManager.h" 10 #include "GrDrawingManager.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // isect RR 341 // isect RR
342 // diff RR 342 // diff RR
343 // isect convex_poly 343 // isect convex_poly
344 // isect convex_poly 344 // isect convex_poly
345 // when drawing rounded div borders. This could probably be tuned based on a 345 // when drawing rounded div borders. This could probably be tuned based on a
346 // configuration's relative costs of switching RTs to generate a mask vs 346 // configuration's relative costs of switching RTs to generate a mask vs
347 // longer shaders. 347 // longer shaders.
348 if (elements.count() <= kMaxAnalyticElements) { 348 if (elements.count() <= kMaxAnalyticElements) {
349 SkVector clipToRTOffset = { SkIntToScalar(-clip.origin().fX), 349 SkVector clipToRTOffset = { SkIntToScalar(-clip.origin().fX),
350 SkIntToScalar(-clip.origin().fY) }; 350 SkIntToScalar(-clip.origin().fY) };
351 // When there are multiple color samples we want to do per-sample clippi ng, not compute 351 // When there are multiple samples we want to do per-sample clipping, no t compute a
352 // a fractional pixel coverage. 352 // fractional pixel coverage.
353 bool disallowAnalyticAA = pipelineBuilder.getRenderTarget()->isUnifiedMu ltisampled(); 353 bool disallowAnalyticAA = rt->isUnifiedMultisampled() || pipelineBuilder .hasMixedSamples();
354 const GrFragmentProcessor* clipFP = nullptr; 354 const GrFragmentProcessor* clipFP = nullptr;
355 if (elements.isEmpty() || 355 if (elements.isEmpty() ||
356 (requiresAA && 356 (requiresAA &&
357 this->getAnalyticClipProcessor(elements, disallowAnalyticAA, clipTo RTOffset, devBounds, 357 this->getAnalyticClipProcessor(elements, disallowAnalyticAA, clipTo RTOffset, devBounds,
358 &clipFP))) { 358 &clipFP))) {
359 SkIRect scissorSpaceIBounds(clipSpaceIBounds); 359 SkIRect scissorSpaceIBounds(clipSpaceIBounds);
360 scissorSpaceIBounds.offset(-clip.origin()); 360 scissorSpaceIBounds.offset(-clip.origin());
361 if (nullptr == devBounds || 361 if (nullptr == devBounds ||
362 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { 362 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
363 out->fScissorState.set(scissorSpaceIBounds); 363 out->fScissorState.set(scissorSpaceIBounds);
364 } 364 }
365 this->setPipelineBuilderStencil(pipelineBuilder, ars); 365 this->setPipelineBuilderStencil(pipelineBuilder, ars);
366 out->fClipCoverageFP.reset(clipFP); 366 out->fClipCoverageFP.reset(clipFP);
367 return true; 367 return true;
368 } 368 }
369 } 369 }
370 370
371 // If MSAA is enabled we can do everything in the stencil buffer. 371 // If the stencil buffer is multisampled we can use it to do everything.
372 if (0 == rt->numColorSamples() && requiresAA) { 372 if (!rt->isStencilBufferMultisampled() && requiresAA) {
373 SkAutoTUnref<GrTexture> result; 373 SkAutoTUnref<GrTexture> result;
374 374
375 // The top-left of the mask corresponds to the top-left corner of the bo unds. 375 // The top-left of the mask corresponds to the top-left corner of the bo unds.
376 SkVector clipToMaskOffset = { 376 SkVector clipToMaskOffset = {
377 SkIntToScalar(-clipSpaceIBounds.fLeft), 377 SkIntToScalar(-clipSpaceIBounds.fLeft),
378 SkIntToScalar(-clipSpaceIBounds.fTop) 378 SkIntToScalar(-clipSpaceIBounds.fTop)
379 }; 379 };
380 380
381 if (this->useSWOnlyPath(pipelineBuilder, rt, clipToMaskOffset, elements) ) { 381 if (this->useSWOnlyPath(pipelineBuilder, rt, clipToMaskOffset, elements) ) {
382 // The clip geometry is complex enough that it will be more efficien t to create it 382 // The clip geometry is complex enough that it will be more efficien t to create it
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge t(); iter.next()) { 700 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge t(); iter.next()) {
701 const Element* element = iter.get(); 701 const Element* element = iter.get();
702 702
703 GrPipelineBuilder pipelineBuilder; 703 GrPipelineBuilder pipelineBuilder;
704 pipelineBuilder.setClip(clip); 704 pipelineBuilder.setClip(clip);
705 pipelineBuilder.setRenderTarget(rt); 705 pipelineBuilder.setRenderTarget(rt);
706 706
707 pipelineBuilder.setDisableColorXPFactory(); 707 pipelineBuilder.setDisableColorXPFactory();
708 708
709 // if the target is MSAA then we want MSAA enabled when the clip is soft 709 // if the target is MSAA then we want MSAA enabled when the clip is soft
710 if (rt->isUnifiedMultisampled()) { 710 if (rt->isStencilBufferMultisampled()) {
711 pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, e lement->isAA()); 711 pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, e lement->isAA());
712 } 712 }
713 713
714 bool fillInverted = false; 714 bool fillInverted = false;
715 // enabled at bottom of loop 715 // enabled at bottom of loop
716 fClipMode = kIgnoreClip_StencilClipMode; 716 fClipMode = kIgnoreClip_StencilClipMode;
717 717
718 // This will be used to determine whether the clip shape can be rend ered into the 718 // This will be used to determine whether the clip shape can be rend ered into the
719 // stencil with arbitrary stencil settings. 719 // stencil with arbitrary stencil settings.
720 GrPathRenderer::StencilSupport stencilSupport; 720 GrPathRenderer::StencilSupport stencilSupport;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1096
1097 //////////////////////////////////////////////////////////////////////////////// 1097 ////////////////////////////////////////////////////////////////////////////////
1098 1098
1099 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment, 1099 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment,
1100 GrStencilSettings* settings) { 1100 GrStencilSettings* settings) {
1101 if (stencilAttachment) { 1101 if (stencilAttachment) {
1102 int stencilBits = stencilAttachment->bits(); 1102 int stencilBits = stencilAttachment->bits();
1103 this->adjustStencilParams(settings, fClipMode, stencilBits); 1103 this->adjustStencilParams(settings, fClipMode, stencilBits);
1104 } 1104 }
1105 } 1105 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrPipelineBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698