From 9a4cfa81de1f485c630785eef5e305c60faab80a Mon Sep 17 00:00:00 2001 From: robertphillips Date: Fri, 8 Jul 2016 13:30:04 -0700 Subject: Revert of Add choke point for modifying non-AA rect draws (e.g., applying clipping) (patchset #6 id:100001 of https://codereview.chromium.org/2125333002/ ) Reason for revert: problems Original issue's description: > Add choke point for modifying non-AA rect draws (e.g., applying clipping) > > NOTREECHECKS=true > NOPRESUBMIT=true > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2125333002 > > Committed: https://skia.googlesource.com/skia/+/e5e3a7a5203f256083d015c923cc9c662877aba9 TBR=bsalomon@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2136643002 --- src/gpu/GrClipMaskManager.h | 7 ++ src/gpu/GrDrawContext.cpp | 141 ++++++++++++------------------ src/gpu/GrDrawTarget.cpp | 14 +-- src/gpu/batches/GrDefaultPathRenderer.cpp | 1 - src/gpu/batches/GrMSAAPathRenderer.cpp | 1 - 5 files changed, 73 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h index dc24d9f5b3..948ae62d77 100644 --- a/src/gpu/GrClipMaskManager.h +++ b/src/gpu/GrClipMaskManager.h @@ -47,6 +47,13 @@ public: const GrClipStackClip&, const SkRect* devBounds, GrAppliedClip*); private: + static void DrawNonAARect(GrDrawContext* drawContext, + const GrFixedClip& clip, + const SkMatrix& viewMatrix, + const SkRect& rect, + bool isAA, + const GrUserStencilSettings* stencilSettings); + static bool PathNeedsSWRenderer(GrContext* context, bool hasUserStencilSettings, const GrDrawContext*, diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 2832095618..430ae886f3 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -242,7 +242,11 @@ void GrDrawContext::drawPaint(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); - this->drawNonAAFilledRect(clip, *paint, SkMatrix::I(), r, nullptr, &localMatrix, nullptr); + SkAutoTUnref batch( + GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix::I(), r, nullptr, + &localMatrix)); + GrPipelineBuilder pipelineBuilder(*paint); // Create a pipeline builder without hwaa. + this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } } @@ -270,52 +274,33 @@ static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt, } } -bool GrDrawContext::drawFilledRect(const GrClip& clip, - const GrPaint& paint, - const SkMatrix& viewMatrix, - const SkRect& rect, - const GrUserStencilSettings* ss) { - - SkAutoTUnref batch; - bool useHWAA; - +GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, + const SkMatrix& viewMatrix, + const SkRect& rect, + bool* useHWAA) { if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { - batch.reset(ir->recordRect(rect, viewMatrix, paint.getColor(), - paint.isAntiAlias(), fInstancedPipelineInfo, - &useHWAA)); - if (batch) { - GrPipelineBuilder pipelineBuilder(paint, useHWAA); - if (ss) { - pipelineBuilder.setUserStencil(ss); - } - this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); - return true; + if (GrDrawBatch* batch = ir->recordRect(rect, viewMatrix, paint.getColor(), + paint.isAntiAlias(), fInstancedPipelineInfo, + useHWAA)) { + return batch; } } - if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { + if (should_apply_coverage_aa(paint, fRenderTarget.get(), useHWAA)) { // The fill path can handle rotation but not skew. if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { SkRect devBoundRect; viewMatrix.mapRect(&devBoundRect, rect); - - batch.reset(GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatrix, - rect, devBoundRect)); - if (batch) { - GrPipelineBuilder pipelineBuilder(paint, useHWAA); - if (ss) { - pipelineBuilder.setUserStencil(ss); - } - this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); - return true; - } + return GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatrix, + rect, devBoundRect); } } else { - this->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nullptr, ss); - return true; + // filled BW rect + return GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect, + nullptr, nullptr); } - return false; + return nullptr; } void GrDrawContext::drawRect(const GrClip& clip, @@ -337,6 +322,9 @@ void GrDrawContext::drawRect(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); const SkStrokeRec& stroke = style->strokeRec(); + bool useHWAA; + bool snapToPixelCenters = false; + SkAutoTUnref batch; if (stroke.getStyle() == SkStrokeRec::kFill_Style) { // Check if this is a full RT draw and can be replaced with a clear. We don't bother // checking cases where the RT is fully inside a stroke. @@ -363,10 +351,7 @@ void GrDrawContext::drawRect(const GrClip& clip, } } } - - if (this->drawFilledRect(clip, paint, viewMatrix, rect, nullptr)) { - return; - } + batch.reset(this->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style || stroke.getStyle() == SkStrokeRec::kHairline_Style) { if ((!rect.width() || !rect.height()) && @@ -400,11 +385,6 @@ void GrDrawContext::drawRect(const GrClip& clip, return; } } - - bool useHWAA; - bool snapToPixelCenters = false; - SkAutoTUnref batch; - GrColor color = paint.getColor(); if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { // The stroke path needs the rect to remain axis aligned (no rotation or skew). @@ -420,18 +400,18 @@ void GrDrawContext::drawRect(const GrClip& clip, batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, stroke, snapToPixelCenters)); } + } - if (batch) { - GrPipelineBuilder pipelineBuilder(paint, useHWAA); - - if (snapToPixelCenters) { - pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag, - snapToPixelCenters); - } + if (batch) { + GrPipelineBuilder pipelineBuilder(paint, useHWAA); - this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); - return; + if (snapToPixelCenters) { + pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag, + snapToPixelCenters); } + + this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); + return; } SkPath path; @@ -478,7 +458,13 @@ void GrDrawContextPriv::stencilRect(const GrFixedClip& clip, SkASSERT(!useHWAA || fDrawContext->isStencilBufferMultisampled()); - fDrawContext->drawFilledRect(clip, paint, viewMatrix, rect, ss); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); + pipelineBuilder.setUserStencil(ss); + + SkAutoTUnref batch( + GrRectBatchFactory::CreateNonAAFill(SK_ColorWHITE, viewMatrix, rect, nullptr, nullptr)); + + fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch); } bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, @@ -499,7 +485,14 @@ bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, paint.setAntiAlias(doAA); paint.setCoverageSetOpXPFactory(op, invert); - if (fDrawContext->drawFilledRect(clip, paint, viewMatrix, rect, ss)) { + bool useHWAA; + SkAutoTUnref batch( + fDrawContext->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); + if (batch) { + GrPipelineBuilder pipelineBuilder(paint, useHWAA); + pipelineBuilder.setUserStencil(ss); + + fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch); return true; } @@ -537,16 +530,15 @@ void GrDrawContext::fillRectToRect(const GrClip& clip, view_matrix_ok_for_aa_fill_rect(viewMatrix)) { batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix, rectToDraw, localRect)); - if (batch) { - GrPipelineBuilder pipelineBuilder(paint, useHWAA); - this->drawBatch(pipelineBuilder, clip, batch); - return; - } } else { - this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, &localRect, - nullptr, nullptr); + batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rectToDraw, + &localRect, nullptr)); } + if (batch) { + GrPipelineBuilder pipelineBuilder(paint, useHWAA); + this->drawBatch(pipelineBuilder, clip, batch); + } } void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, @@ -577,13 +569,13 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, view_matrix_ok_for_aa_fill_rect(viewMatrix)) { batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, localMatrix, rectToDraw)); - GrPipelineBuilder pipelineBuilder(paint, useHWAA); - this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } else { - this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, nullptr, - &localMatrix, nullptr); + batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rectToDraw, + nullptr, &localMatrix)); } + GrPipelineBuilder pipelineBuilder(paint, useHWAA); + this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } void GrDrawContext::drawVertices(const GrClip& clip, @@ -880,23 +872,6 @@ void GrDrawContext::drawImageNine(const GrClip& clip, } -void GrDrawContext::drawNonAAFilledRect(const GrClip& clip, - const GrPaint& paint, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix, - const GrUserStencilSettings* ss) { - SkAutoTUnref batch( - GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect, localRect, - localMatrix)); - GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); - if (ss) { - pipelineBuilder.setUserStencil(ss); - } - this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); -} - // Can 'path' be drawn as a pair of filled nested rectangles? static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path, SkRect rects[2]) { diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index bffe2f9740..8beaade32c 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -469,13 +469,15 @@ void GrDrawTarget::clear(const SkIRect* rect, drawContext->discard(); } - SkRect scalarRect = SkRect::Make(*rect); - - GrPaint paint; - paint.setColor4f(GrColor4f::FromGrColor(color)); - paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); + // TODO: flip this into real draw! + GrPipelineBuilder pipelineBuilder; + pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); - drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), scalarRect); + SkRect scalarRect = SkRect::Make(*rect); + SkAutoTUnref batch( + GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalarRect, + nullptr, nullptr)); + this->drawBatch(pipelineBuilder, drawContext, GrNoClip(), batch); } else { GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRenderTarget()); this->recordBatch(batch, batch->bounds()); diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp index 446483bcd0..335f3b60fa 100644 --- a/src/gpu/batches/GrDefaultPathRenderer.cpp +++ b/src/gpu/batches/GrDefaultPathRenderer.cpp @@ -554,7 +554,6 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext, GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr, &localMatrix)); - SkASSERT(GrPipelineBuilder::kBoth_DrawFace == drawFace[p]); GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); pipelineBuilder.setDrawFace(drawFace[p]); if (passes[p]) { diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp index d38d88600a..5b49e6b138 100644 --- a/src/gpu/batches/GrMSAAPathRenderer.cpp +++ b/src/gpu/batches/GrMSAAPathRenderer.cpp @@ -658,7 +658,6 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr, &localMatrix)); - SkASSERT(GrPipelineBuilder::kBoth_DrawFace == drawFace[p]); GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); pipelineBuilder.setDrawFace(drawFace[p]); if (passes[p]) { -- cgit v1.2.3