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

Unified Diff: src/gpu/GrClipMaskManager.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 8 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
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrCommandBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrClipMaskManager.cpp
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 3e802d71356ec5e5957828159c9c0a0cdca198d1..f45533f9807f88318e5dd3392f94b11ce1b66b4c 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -30,7 +30,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 const GrFragmentProcessor* create_fp_for_mask(GrTexture* result, const SkIRect &devBound, GrRenderTarget* dst) {
+
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.
@@ -44,7 +45,7 @@ static const GrFragmentProcessor* create_fp_for_mask(GrTexture* result, const Sk
GrTextureDomain::MakeTexelDomain(result, domainTexels),
GrTextureDomain::kDecal_Mode,
GrTextureParams::kNone_FilterMode,
- kDevice_GrCoordSet);
+ kDevice_GrCoordSet, dst);
}
// Does the path in 'element' require SW rendering? If so, return true (and,
@@ -278,7 +279,8 @@ bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis
bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
GrPipelineBuilder::AutoRestoreStencil* ars,
const SkRect* devBounds,
- GrAppliedClip* out) {
+ GrAppliedClip* out,
+ GrRenderTarget* dst) {
if (kRespectClip_StencilClipMode == fClipMode) {
fClipMode = kIgnoreClip_StencilClipMode;
}
@@ -370,6 +372,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
// If MSAA is enabled we can do everything in the stencil buffer.
if (0 == rt->numStencilSamples() && requiresAA) {
+ SkAutoTUnref<GrDrawContext> dc;
SkAutoTUnref<GrTexture> result;
// The top-left of the mask corresponds to the top-left corner of the bounds.
@@ -391,7 +394,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
initialState,
elements,
clipToMaskOffset,
- clipSpaceIBounds));
+ clipSpaceIBounds, &dc));
// If createAlphaClipMask fails it means useSWOnlyPath has a bug
SkASSERT(result);
}
@@ -401,7 +404,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, rtSpaceMaskBounds));
+ out->fClipCoverageFP.reset(create_fp_for_mask(result, rtSpaceMaskBounds, dst));
this->setPipelineBuilderStencil(pipelineBuilder, ars);
return true;
}
@@ -451,12 +454,16 @@ bool GrClipMaskManager::drawElement(GrPipelineBuilder* pipelineBuilder,
// which ignores color.
GrColor color = GrColor_WHITE;
+ GrPaint paint;
+ paint.setAntiAlias(element->isAA());
+ GrClip clip;
+
// TODO: Draw rrects directly here.
switch (element->getType()) {
case Element::kEmpty_Type:
SkDEBUGFAIL("Should never get here with an empty element.");
break;
- case Element::kRect_Type:
+ case Element::kRect_Type: {
// 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()) {
@@ -470,6 +477,7 @@ bool GrClipMaskManager::drawElement(GrPipelineBuilder* pipelineBuilder,
element->getRect());
}
return true;
+ }
default: {
SkPath path;
element->asPath(&path);
@@ -477,6 +485,7 @@ bool GrClipMaskManager::drawElement(GrPipelineBuilder* pipelineBuilder,
path.toggleInverseFillType();
}
GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
+
if (nullptr == pr) {
GrPathRendererChain::DrawType type;
type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawType :
@@ -547,7 +556,8 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
GrReducedClip::InitialState initialState,
const GrReducedClip::ElementList& elements,
const SkVector& clipToMaskOffset,
- const SkIRect& clipSpaceIBounds) {
+ const SkIRect& clipSpaceIBounds,
+ SkAutoTUnref<GrDrawContext>* destDC) {
GrResourceProvider* resourceProvider = this->resourceProvider();
GrUniqueKey key;
GetClipMaskKey(elementsGenID, clipSpaceIBounds, &key);
@@ -562,6 +572,12 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
return nullptr;
}
+ destDC->reset(this->getContext()->drawContext(texture->asRenderTarget()));
+ if (!*destDC) {
+ texture->unref();
+ return NULL;
+ }
+
// Set the matrix so that rendered clip elements are transformed to mask space from clip
// space.
const SkMatrix translate = SkMatrix::MakeTrans(clipToMaskOffset.fX, clipToMaskOffset.fY);
@@ -572,10 +588,16 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
// The scratch texture that we are drawing into can be substantially larger than the mask. Only
// clear the part that we care about.
+#if 1
+ (*destDC)->clear(&maskSpaceIBounds,
+ GrReducedClip::kAllIn_InitialState == initialState ? 0xffffffff : 0x00000000,
+ true);
+#else
fDrawTarget->clear(&maskSpaceIBounds,
GrReducedClip::kAllIn_InitialState == initialState ? 0xffffffff : 0x00000000,
true,
texture->asRenderTarget());
+#endif
// When we use the stencil in the below loop it is important to have this clip installed.
// The second pass that zeros the stencil buffer renders the rect maskSpaceIBounds so the first
@@ -589,7 +611,6 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
SkRegion::Op op = element->getOp();
bool invert = element->isInverseFilled();
if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
-
GrPathRenderer* pr = GetPathRenderer(this->getContext(),
texture, translate, element);
if (Element::kRect_Type != element->getType() && !pr) {
@@ -640,9 +661,15 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
0xffff);
backgroundPipelineBuilder.setStencil(kDrawOutsideElement);
+#if 0
// The color passed in here does not matter since the coverageSetOpXP won't read it.
fDrawTarget->drawNonAARect(backgroundPipelineBuilder, GrColor_WHITE, translate,
clipSpaceIBounds);
+#else
+ GrClip clip;
+ GrPaint paint;
+ (*destDC)->drawRect(clip, paint, SkMatrix::I(), SkRect::Make(clipSpaceIBounds), NULL);
+#endif
}
} else {
GrPipelineBuilder pipelineBuilder;
@@ -654,6 +681,9 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
}
}
+ // This was written to but will have a unique key
+ texture->fException2 = true;
+
return texture.detach();
}
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrCommandBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698