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

Unified Diff: src/gpu/GrClipMaskManager.cpp

Issue 815553003: Move ViewMatrix off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@remove-fragment-stage
Patch Set: more claenup Created 6 years 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 4b57868520d479f9cfb726cbcef98070f6dcdfbb..85f56a3bd64e2ca045ef48373543faf0eaa7282e 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -56,6 +56,7 @@ void setup_drawstate_aaclip(const SkIRect &devBound,
bool path_needs_SW_renderer(GrContext* context,
const GrDrawTarget* gpu,
const GrDrawState* drawState,
+ const SkMatrix& viewMatrix,
const SkPath& origPath,
const SkStrokeRec& stroke,
bool doAA) {
@@ -69,7 +70,7 @@ bool path_needs_SW_renderer(GrContext* context,
GrPathRendererChain::kColorAntiAlias_DrawType :
GrPathRendererChain::kColor_DrawType;
- return NULL == context->getPathRenderer(gpu, drawState, *path, stroke, false, type);
+ return NULL == context->getPathRenderer(gpu, drawState, viewMatrix, *path, stroke, false, type);
}
}
@@ -79,6 +80,7 @@ bool path_needs_SW_renderer(GrContext* context,
* entire clip should be rendered in SW and then uploaded en masse to the gpu.
*/
bool GrClipMaskManager::useSWOnlyPath(const GrDrawState* drawState,
+ const SkMatrix& viewMatrix,
const GrReducedClip::ElementList& elements) {
// TODO: generalize this function so that when
// a clip gets complex enough it can just be done in SW regardless
@@ -92,8 +94,8 @@ bool GrClipMaskManager::useSWOnlyPath(const GrDrawState* drawState,
if (Element::kRect_Type != element->getType()) {
SkPath path;
element->asPath(&path);
- if (path_needs_SW_renderer(this->getContext(), fClipTarget, drawState, path, stroke,
- element->isAA())) {
+ if (path_needs_SW_renderer(this->getContext(), fClipTarget, drawState, viewMatrix,
bsalomon 2014/12/29 18:35:46 So AFAICT you tunneled the original draw's matrix
joshualitt 2014/12/29 19:23:38 Brian, are you sure about this? I could be wrong
bsalomon 2014/12/29 19:29:01 Hmm... that seems incorrect. If we were using the
+ path, stroke, element->isAA())) {
return true;
}
}
@@ -202,6 +204,7 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
GrDrawState::AutoRestoreStencil* ars,
GrScissorState* scissorState,
const GrClipData* clipDataIn,
+ const SkMatrix& viewMatrix,
const SkRect* devBounds) {
fCurrClipMaskType = kNone_ClipMaskType;
if (kRespectClip_StencilClipMode == fClipMode) {
@@ -273,7 +276,7 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
if (0 == rt->numSamples() && requiresAA) {
GrTexture* result = NULL;
- if (this->useSWOnlyPath(drawState, elements)) {
+ if (this->useSWOnlyPath(drawState, viewMatrix, elements)) {
// The clip geometry is complex enough that it will be more efficient to create it
// entirely in software
result = this->createSoftwareClipMask(genID,
@@ -337,6 +340,7 @@ void set_coverage_drawing_xpf(SkRegion::Op op, bool invertCoverage, GrDrawState*
////////////////////////////////////////////////////////////////////////////////
bool GrClipMaskManager::drawElement(GrDrawState* drawState,
+ const SkMatrix& viewMatrix,
GrTexture* target,
const SkClipStack::Element* element,
GrPathRenderer* pr) {
@@ -357,15 +361,22 @@ bool GrClipMaskManager::drawElement(GrDrawState* drawState,
// 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()) {
+ SkMatrix invert;
+ if (!viewMatrix.invert(&invert)) {
+ SkDebugf("Could not invert\n");
+ return false;
+ }
+ SkRect devRect = element->getRect();
+ viewMatrix.mapRect(&devRect);
this->getContext()->getAARectRenderer()->fillAARect(fClipTarget,
drawState,
color,
- SkMatrix::I(),
+ viewMatrix,
+ invert,
element->getRect(),
- SkMatrix::I(),
- element->getRect());
+ devRect);
} else {
- fClipTarget->drawSimpleRect(drawState, color, element->getRect());
+ fClipTarget->drawSimpleRect(drawState, color, viewMatrix, element->getRect());
}
return true;
default: {
@@ -380,14 +391,14 @@ bool GrClipMaskManager::drawElement(GrDrawState* drawState,
GrPathRendererChain::DrawType type;
type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawType :
GrPathRendererChain::kColor_DrawType;
- pr = this->getContext()->getPathRenderer(fClipTarget, drawState, path, stroke,
- false, type);
+ pr = this->getContext()->getPathRenderer(fClipTarget, drawState, viewMatrix, path,
+ stroke, false, type);
}
if (NULL == pr) {
return false;
}
- pr->drawPath(fClipTarget, drawState, color, path, stroke, element->isAA());
+ pr->drawPath(fClipTarget, drawState, color, viewMatrix, path, stroke, element->isAA());
break;
}
}
@@ -414,8 +425,8 @@ bool GrClipMaskManager::canStencilAndDrawElement(GrDrawState* drawState,
GrPathRendererChain::DrawType type = element->isAA() ?
GrPathRendererChain::kStencilAndColorAntiAlias_DrawType :
GrPathRendererChain::kStencilAndColor_DrawType;
- *pr = this->getContext()->getPathRenderer(fClipTarget, drawState, path, stroke, false,
- type);
+ *pr = this->getContext()->getPathRenderer(fClipTarget, drawState, SkMatrix::I(), path,
+ stroke, false, type);
return SkToBool(*pr);
}
}
@@ -441,7 +452,7 @@ void GrClipMaskManager::mergeMask(GrDrawState* drawState,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kNone_FilterMode))->unref();
// The color passed in here does not matter since the coverageSetOpXP won't read it.
- fClipTarget->drawSimpleRect(drawState, GrColor_WHITE, SkRect::Make(dstBound));
+ fClipTarget->drawSimpleRect(drawState, GrColor_WHITE, SkMatrix::I(), SkRect::Make(dstBound));
}
GrTexture* GrClipMaskManager::createTempMask(int width, int height) {
@@ -549,7 +560,7 @@ 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) {
- GrDrawState drawState(translate);
+ GrDrawState drawState;
drawState.enableState(GrDrawState::kClip_StateBit);
GrPathRenderer* pr = NULL;
@@ -600,7 +611,7 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
set_coverage_drawing_xpf(op, invert, &drawState);
}
- if (!this->drawElement(&drawState, dst, element, pr)) {
+ if (!this->drawElement(&drawState, translate, dst, element, pr)) {
fAACache.reset();
return NULL;
}
@@ -619,7 +630,7 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
maskSpaceIBounds,
maskSpaceElementIBounds);
} else {
- GrDrawState backgroundDrawState(translate);
+ GrDrawState backgroundDrawState;
backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
backgroundDrawState.setRenderTarget(result->asRenderTarget());
@@ -634,16 +645,17 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
0xffff);
backgroundDrawState.setStencil(kDrawOutsideElement);
// The color passed in here does not matter since the coverageSetOpXP won't read it.
- fClipTarget->drawSimpleRect(&backgroundDrawState, GrColor_WHITE, clipSpaceIBounds);
+ fClipTarget->drawSimpleRect(&backgroundDrawState, GrColor_WHITE, translate,
+ clipSpaceIBounds);
}
} else {
- GrDrawState drawState(translate);
+ GrDrawState drawState;
drawState.enableState(GrDrawState::kClip_StateBit);
// all the remaining ops can just be directly draw into the accumulation buffer
set_coverage_drawing_xpf(op, false, &drawState);
// The color passed in here does not matter since the coverageSetOpXP won't read it.
- this->drawElement(&drawState, result, element);
+ this->drawElement(&drawState, translate, result, element);
}
}
@@ -676,8 +688,8 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
SkIntToScalar(clipSpaceToStencilOffset.fX),
SkIntToScalar(clipSpaceToStencilOffset.fY)
};
- SkMatrix matrix;
- matrix.setTranslate(translate);
+ SkMatrix viewMatrix;
+ viewMatrix.setTranslate(translate);
// We set the current clip to the bounds so that our recursive draws are scissored to them.
SkIRect stencilSpaceIBounds(clipSpaceIBounds);
@@ -697,7 +709,7 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) {
const Element* element = iter.get();
- GrDrawState drawState(matrix);
+ GrDrawState drawState;
drawState.setRenderTarget(rt);
drawState.enableState(GrDrawState::kClip_StateBit);
@@ -732,6 +744,7 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
}
pr = this->getContext()->getPathRenderer(fClipTarget,
&drawState,
+ viewMatrix,
clipPath,
stroke,
false,
@@ -769,16 +782,17 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
0xffff);
if (Element::kRect_Type == element->getType()) {
*drawState.stencil() = gDrawToStencil;
- fClipTarget->drawSimpleRect(&drawState, GrColor_WHITE, element->getRect());
+ fClipTarget->drawSimpleRect(&drawState, GrColor_WHITE, viewMatrix,
+ element->getRect());
} else {
if (!clipPath.isEmpty()) {
GrDrawTarget::AutoGeometryPush agp(fClipTarget);
if (canRenderDirectToStencil) {
*drawState.stencil() = gDrawToStencil;
- pr->drawPath(fClipTarget, &drawState, GrColor_WHITE, clipPath, stroke,
- false);
+ pr->drawPath(fClipTarget, &drawState, GrColor_WHITE, viewMatrix,
+ clipPath, stroke, false);
} else {
- pr->stencilPath(fClipTarget, &drawState, clipPath, stroke);
+ pr->stencilPath(fClipTarget, &drawState, viewMatrix, clipPath, stroke);
}
}
}
@@ -793,16 +807,17 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
if (canDrawDirectToClip) {
if (Element::kRect_Type == element->getType()) {
- fClipTarget->drawSimpleRect(&drawStateCopy, GrColor_WHITE,
+ fClipTarget->drawSimpleRect(&drawStateCopy, GrColor_WHITE, viewMatrix,
element->getRect());
} else {
GrDrawTarget::AutoGeometryPush agp(fClipTarget);
- pr->drawPath(fClipTarget, &drawStateCopy, GrColor_WHITE, clipPath, stroke, false);
+ pr->drawPath(fClipTarget, &drawStateCopy, GrColor_WHITE, viewMatrix,
+ clipPath, stroke, false);
}
} else {
// The view matrix is setup to do clip space -> stencil space translation, so
// draw rect in clip space.
- fClipTarget->drawSimpleRect(&drawStateCopy, GrColor_WHITE,
+ fClipTarget->drawSimpleRect(&drawStateCopy, GrColor_WHITE, viewMatrix,
SkRect::Make(clipSpaceIBounds));
}
}

Powered by Google App Engine
This is Rietveld 408576698