aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2016-06-10 12:32:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-10 12:32:58 -0700
commit656dbe4c712d2016dcf9af903f088f34ad2bf94d (patch)
tree7b8e32f033775a6d4287760c92f5aa079a77a813 /src/gpu
parent687d9d2eccec4fe86bc414015e6cbb4b4fb9be27 (diff)
Fix GrDrawContextPriv::stencilRect
Updates stencilRect to not call getFillRectBatch. This method can return a batch that uses coverage AA, which isn't appropriate for stencil draws. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2057613003 Review-Url: https://codereview.chromium.org/2057613003
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrClipMaskManager.cpp22
-rw-r--r--src/gpu/GrDrawContext.cpp12
-rw-r--r--src/gpu/GrDrawContextPriv.h2
3 files changed, 14 insertions, 22 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 9348181145..2047f6f6f4 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -51,15 +51,6 @@ static sk_sp<GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
kDevice_GrCoordSet));
}
-void GrClipMaskManager::DrawNonAARect(GrDrawContext* drawContext,
- const GrFixedClip& clip,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- bool doAA,
- const GrUserStencilSettings* stencilSettings) {
- drawContext->drawContextPriv().stencilRect(clip, stencilSettings, doAA, viewMatrix, rect);
-}
-
// Does the path in 'element' require SW rendering? If so, return true (and,
// optionally, set 'prOut' to NULL. If not, return false (and, optionally, set
// 'prOut' to the non-SW path renderer that will do the job).
@@ -600,6 +591,7 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
// with the existing clip.
for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) {
const Element* element = iter.get();
+ bool useHWAA = element->isAA() && drawContext->isStencilBufferMultisampled();
bool fillInverted = false;
// enabled at bottom of loop
@@ -662,8 +654,8 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
0xffff>()
);
if (Element::kRect_Type == element->getType()) {
- DrawNonAARect(drawContext, clip, viewMatrix,
- element->getRect(), element->isAA(), &kDrawToStencil);
+ drawContext->drawContextPriv().stencilRect(clip, &kDrawToStencil, useHWAA,
+ viewMatrix, element->getRect());
} else {
if (!clipPath.isEmpty()) {
if (canRenderDirectToStencil) {
@@ -705,8 +697,8 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
if (drawDirectToClip) {
if (Element::kRect_Type == element->getType()) {
- DrawNonAARect(drawContext, clip,
- viewMatrix, element->getRect(), element->isAA(), *pass);
+ drawContext->drawContextPriv().stencilRect(clip, *pass, useHWAA, viewMatrix,
+ element->getRect());
} else {
GrPaint paint;
paint.setXPFactory(GrDisableColorXPFactory::Make());
@@ -729,8 +721,8 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
} else {
// The view matrix is setup to do clip space -> stencil space translation, so
// draw rect in clip space.
- DrawNonAARect(drawContext, clip, viewMatrix,
- SkRect::Make(clipSpaceIBounds), false, *pass);
+ drawContext->drawContextPriv().stencilRect(clip, *pass, false, viewMatrix,
+ SkRect::Make(clipSpaceIBounds));
}
}
}
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 64ce0cec31..b5489f1123 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -408,7 +408,7 @@ void GrDrawContextPriv::stencilPath(const GrPipelineBuilder& pipelineBuilder,
void GrDrawContextPriv::stencilRect(const GrFixedClip& clip,
const GrUserStencilSettings* ss,
- bool doAA,
+ bool useHWAA,
const SkMatrix& viewMatrix,
const SkRect& rect) {
ASSERT_SINGLE_OWNER_PRIV
@@ -419,17 +419,17 @@ void GrDrawContextPriv::stencilRect(const GrFixedClip& clip,
AutoCheckFlush acf(fDrawContext->fDrawingManager);
GrPaint paint;
- paint.setAntiAlias(doAA);
+ paint.setAntiAlias(useHWAA);
paint.setXPFactory(GrDisableColorXPFactory::Make());
- bool useHWAA;
- SkAutoTUnref<GrDrawBatch> batch(
- fDrawContext->getFillRectBatch(paint, viewMatrix, rect, &useHWAA));
- SkASSERT(batch);
+ SkASSERT(!useHWAA || fDrawContext->isStencilBufferMultisampled());
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
pipelineBuilder.setUserStencil(ss);
+ SkAutoTUnref<GrDrawBatch> batch(
+ GrRectBatchFactory::CreateNonAAFill(SK_ColorWHITE, viewMatrix, rect, nullptr, nullptr));
+
fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch);
}
diff --git a/src/gpu/GrDrawContextPriv.h b/src/gpu/GrDrawContextPriv.h
index bdd3b4742d..0641e9f2b5 100644
--- a/src/gpu/GrDrawContextPriv.h
+++ b/src/gpu/GrDrawContextPriv.h
@@ -24,7 +24,7 @@ public:
void stencilRect(const GrFixedClip& clip,
const GrUserStencilSettings* ss,
- bool doAA,
+ bool useHWAA,
const SkMatrix& viewMatrix,
const SkRect& rect);