aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-05-19 11:36:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-19 11:36:25 -0700
commit5f2fa47a6ea50653fa1584d6baeabce50698881c (patch)
tree1ab1b8ac77f9e89b6dc45be3b111b1b03bc72e0d /src
parentc989e1851ee6b1be2b5b56129efcd14cfafb31d8 (diff)
Make GrAppliedClip friendless
GrAppliedClip is a pretty amiable class but not so good about setting boundaries. It is probably for the best that it breaks things off with GrClipMaskManager before the drama of https://codereview.chromium.org/1988923002/ (Declassify GrClipMaskManager and Remove GrRenderTarget and GrDrawTarget from GrPipelineBuilder) begins. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1993263002 Review-Url: https://codereview.chromium.org/1993263002
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrClip.cpp6
-rw-r--r--src/gpu/GrClipMaskManager.cpp24
-rw-r--r--src/gpu/GrClipMaskManager.h2
3 files changed, 18 insertions, 14 deletions
diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp
index 15065aa484..eeb105e2cb 100644
--- a/src/gpu/GrClip.cpp
+++ b/src/gpu/GrClip.cpp
@@ -52,9 +52,11 @@ bool GrFixedClip::apply(GrClipMaskManager*, const GrPipelineBuilder& pipelineBui
if (devBounds && !devBounds->intersects(SkRect::Make(tightScissor))) {
return false;
}
- out->fScissorState.set(tightScissor);
+ out->makeScissoredStencil(fHasStencilClip, tightScissor);
+ return true;
}
- out->fHasStencilClip = fHasStencilClip;
+
+ out->makeStencil(fHasStencilClip);
return true;
}
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 4aaf57add6..81b6fe8614 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -31,7 +31,8 @@ typedef SkClipStack::Element Element;
////////////////////////////////////////////////////////////////////////////////
// set up the draw state to enable the aa clipping mask. Besides setting up the
// stage matrix this also alters the vertex layout
-static const GrFragmentProcessor* create_fp_for_mask(GrTexture* result, const SkIRect &devBound) {
+static sk_sp<const GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
+ const SkIRect &devBound) {
SkMatrix mat;
// We use device coords to compute the texture coordinates. We set our matrix to be a
// translation to the devBound, and then a scaling matrix to normalized coords.
@@ -40,12 +41,13 @@ static const GrFragmentProcessor* create_fp_for_mask(GrTexture* result, const Sk
SkIntToScalar(-devBound.fTop));
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
- return GrTextureDomainEffect::Create(result,
+ return sk_sp<const GrFragmentProcessor>(GrTextureDomainEffect::Create(
+ result,
mat,
GrTextureDomain::MakeTexelDomain(result, domainTexels),
GrTextureDomain::kDecal_Mode,
GrTextureParams::kNone_FilterMode,
- kDevice_GrCoordSet);
+ kDevice_GrCoordSet));
}
static void draw_non_aa_rect(GrDrawTarget* drawTarget,
@@ -186,7 +188,7 @@ bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis
bool abortIfAA,
SkVector& clipToRTOffset,
const SkRect* drawBounds,
- const GrFragmentProcessor** resultFP) {
+ sk_sp<const GrFragmentProcessor>* resultFP) {
SkRect boundsInClipSpace;
if (drawBounds) {
boundsInClipSpace = *drawBounds;
@@ -271,7 +273,7 @@ bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis
*resultFP = nullptr;
if (!failed && fpCnt) {
- *resultFP = GrFragmentProcessor::RunInSeries(fps, fpCnt);
+ resultFP->reset(GrFragmentProcessor::RunInSeries(fps, fpCnt));
}
for (int i = 0; i < fpCnt; ++i) {
fps[i]->unref();
@@ -352,7 +354,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
disallowAnalyticAA = pipelineBuilder.isHWAntialias() ||
pipelineBuilder.hasUserStencilSettings();
}
- const GrFragmentProcessor* clipFP = nullptr;
+ sk_sp<const GrFragmentProcessor> clipFP;
if (elements.isEmpty() ||
(requiresAA &&
this->getAnalyticClipProcessor(elements, disallowAnalyticAA, clipToRTOffset, devBounds,
@@ -361,9 +363,10 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
scissorSpaceIBounds.offset(-clip.origin());
if (nullptr == devBounds ||
!SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
- out->fScissorState.set(scissorSpaceIBounds);
+ out->makeScissoredFPBased(clipFP, scissorSpaceIBounds);
+ return true;
}
- out->fClipCoverageFP.reset(clipFP);
+ out->makeFPBased(clipFP);
return true;
}
}
@@ -403,7 +406,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
// clipSpace bounds. We determine the mask's position WRT to the render target here.
SkIRect rtSpaceMaskBounds = clipSpaceIBounds;
rtSpaceMaskBounds.offset(-clip.origin());
- out->fClipCoverageFP.reset(create_fp_for_mask(result.get(), rtSpaceMaskBounds));
+ out->makeFPBased(create_fp_for_mask(result.get(), rtSpaceMaskBounds));
return true;
}
// if alpha clip mask creation fails fall through to the non-AA code paths
@@ -423,8 +426,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
// use both stencil and scissor test to the bounds for the final draw.
SkIRect scissorSpaceIBounds(clipSpaceIBounds);
scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset);
- out->fScissorState.set(scissorSpaceIBounds);
- out->fHasStencilClip = true;
+ out->makeScissoredStencil(true, scissorSpaceIBounds);
return true;
}
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index 8ecba09fba..d546a76136 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -73,7 +73,7 @@ private:
bool abortIfAA,
SkVector& clipOffset,
const SkRect* devBounds,
- const GrFragmentProcessor** fp);
+ sk_sp<const GrFragmentProcessor>* fp);
// Draws the clip into the stencil buffer
bool createStencilClipMask(GrRenderTarget*,