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

Unified Diff: src/gpu/GrClipMaskManager.cpp

Issue 676983003: Clip mask manager sets stencil on draw type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrClipMaskManager.cpp
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 349d51e311586103bf14c9f67f08e33a4a1b7a36..aae78543158758d15860aca3a21d7864b4b93ddd 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -17,12 +17,12 @@
#include "GrRenderTarget.h"
#include "GrStencilBuffer.h"
#include "GrSWMaskHelper.h"
-#include "effects/GrTextureDomain.h"
-#include "effects/GrConvexPolyEffect.h"
-#include "effects/GrRRectEffect.h"
#include "SkRasterClip.h"
#include "SkStrokeRec.h"
#include "SkTLazy.h"
+#include "effects/GrTextureDomain.h"
+#include "effects/GrConvexPolyEffect.h"
+#include "effects/GrRRectEffect.h"
#define GR_AA_CLIP 1
@@ -212,6 +212,7 @@ bool GrClipMaskManager::installClipEffects(const GrReducedClip::ElementList& ele
// scissor, or entirely software
bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
GrDrawState::AutoRestoreEffects* are,
+ GrDrawState::AutoRestoreStencil* asr,
const SkRect* devBounds) {
fCurrClipMaskType = kNone_ClipMaskType;
@@ -228,32 +229,30 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
SkASSERT(rt);
bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWideOpen();
-
- if (!ignoreClip) {
- SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height());
- clipSpaceRTIBounds.offset(clipDataIn->fOrigin);
- GrReducedClip::ReduceClipStack(*clipDataIn->fClipStack,
- clipSpaceRTIBounds,
- &elements,
- &genID,
- &initialState,
- &clipSpaceIBounds,
- &requiresAA);
- if (elements.isEmpty()) {
- if (GrReducedClip::kAllIn_InitialState == initialState) {
- ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds;
- } else {
- return false;
- }
- }
- }
-
if (ignoreClip) {
fGpu->disableScissor();
- this->setGpuStencil();
+ this->setDrawStateStencil(asr);
return true;
}
+ // Setup clip
+ SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height());
+ clipSpaceRTIBounds.offset(clipDataIn->fOrigin);
+ GrReducedClip::ReduceClipStack(*clipDataIn->fClipStack,
+ clipSpaceRTIBounds,
+ &elements,
+ &genID,
+ &initialState,
+ &clipSpaceIBounds,
+ &requiresAA);
+ if (elements.isEmpty()) {
+ if (GrReducedClip::kAllIn_InitialState == initialState) {
+ ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds;
bsalomon 2014/10/24 21:04:38 Does this get respected anymore now that the if (i
+ } else {
+ return false;
+ }
+ }
+
// An element count of 4 was chosen because of the common pattern in Blink of:
// isect RR
// diff RR
@@ -275,7 +274,7 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
} else {
fGpu->disableScissor();
}
- this->setGpuStencil();
+ this->setDrawStateStencil(asr);
return true;
}
}
@@ -307,7 +306,7 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
are->set(fGpu->drawState());
setup_drawstate_aaclip(fGpu, result, rtSpaceMaskBounds);
fGpu->disableScissor();
- this->setGpuStencil();
+ this->setDrawStateStencil(asr);
return true;
}
// if alpha clip mask creation fails fall through to the non-AA code paths
@@ -335,7 +334,7 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
SkIRect scissorSpaceIBounds(clipSpaceIBounds);
scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset);
fGpu->enableScissor(scissorSpaceIBounds);
- this->setGpuStencil();
+ this->setDrawStateStencil(asr);
return true;
}
@@ -400,11 +399,11 @@ bool GrClipMaskManager::drawElement(GrTexture* target,
// TODO: Do rects directly to the accumulator using a aa-rect GrProcessor that covers
// the entire mask bounds and writes 0 outside the rect.
if (element->isAA()) {
- getContext()->getAARectRenderer()->fillAARect(fGpu,
- fGpu,
- element->getRect(),
- SkMatrix::I(),
- element->getRect());
+ this->getContext()->getAARectRenderer()->fillAARect(fGpu,
+ fGpu,
+ element->getRect(),
+ SkMatrix::I(),
+ element->getRect());
} else {
fGpu->drawSimpleRect(element->getRect());
}
@@ -707,7 +706,6 @@ bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID,
}
if (stencilBuffer->mustRenderClip(elementsGenID, clipSpaceIBounds, clipSpaceToStencilOffset)) {
-
stencilBuffer->setLastClip(elementsGenID, clipSpaceIBounds, clipSpaceToStencilOffset);
// Set the matrix so that rendered clip elements are transformed from clip to stencil space.
@@ -903,7 +901,7 @@ const GrStencilSettings& basic_apply_stencil_clip_settings() {
}
}
-void GrClipMaskManager::setGpuStencil() {
+void GrClipMaskManager::setDrawStateStencil(GrDrawState::AutoRestoreStencil* ars) {
// We make two copies of the StencilSettings here (except in the early
// exit scenario. One copy from draw state to the stack var. Then another
// from the stack var to the gpu. We could make this class hold a ptr to
@@ -933,7 +931,6 @@ void GrClipMaskManager::setGpuStencil() {
if (GrClipMaskManager::kRespectClip_StencilClipMode == clipMode) {
settings = basic_apply_stencil_clip_settings();
} else {
- fGpu->disableStencil();
return;
}
} else {
@@ -942,8 +939,7 @@ void GrClipMaskManager::setGpuStencil() {
// TODO: dynamically attach a stencil buffer
int stencilBits = 0;
- GrStencilBuffer* stencilBuffer =
- drawState.getRenderTarget()->getStencilBuffer();
+ GrStencilBuffer* stencilBuffer = drawState.getRenderTarget()->getStencilBuffer();
if (stencilBuffer) {
stencilBits = stencilBuffer->bits();
}
@@ -951,7 +947,8 @@ void GrClipMaskManager::setGpuStencil() {
SkASSERT(fGpu->caps()->stencilWrapOpsSupport() || !settings.usesWrapOp());
SkASSERT(fGpu->caps()->twoSidedStencilSupport() || !settings.isTwoSided());
this->adjustStencilParams(&settings, clipMode, stencilBits);
- fGpu->setStencilSettings(settings);
+ ars->set(fGpu->drawState());
+ fGpu->drawState()->setStencil(settings);
}
void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings,
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrDrawState.h » ('j') | src/gpu/GrDrawState.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698