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

Unified Diff: src/gpu/GrAADistanceFieldPathRenderer.cpp

Issue 815553003: Move ViewMatrix off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@remove-fragment-stage
Patch Set: more cleaning 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
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index 913cda40faf0dd8bc4ef70487f162e2fbe95dacd..99093faed780fc2b94b1c9e66b1790d69913f7cd 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -67,6 +67,7 @@ GrAADistanceFieldPathRenderer::~GrAADistanceFieldPathRenderer() {
////////////////////////////////////////////////////////////////////////////////
bool GrAADistanceFieldPathRenderer::canDrawPath(const GrDrawTarget* target,
const GrDrawState* drawState,
+ const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
bool antiAlias) const {
@@ -79,14 +80,13 @@ bool GrAADistanceFieldPathRenderer::canDrawPath(const GrDrawTarget* target,
}
// currently don't support perspective
- const SkMatrix& vm = drawState->getViewMatrix();
- if (vm.hasPerspective()) {
+ if (viewMatrix.hasPerspective()) {
return false;
}
// only support paths smaller than 64x64, scaled to less than 256x256
// the goal is to accelerate rendering of lots of small paths that may be scaling
- SkScalar maxScale = vm.getMaxScale();
+ SkScalar maxScale = viewMatrix.getMaxScale();
const SkRect& bounds = path.getBounds();
SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
return maxDim < 64.f && maxDim*maxScale < 256.f;
@@ -106,6 +106,7 @@ GrAADistanceFieldPathRenderer::onGetStencilSupport(const GrDrawTarget*,
bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
GrDrawState* drawState,
GrColor color,
+ const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
bool antiAlias) {
@@ -117,8 +118,7 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
SkASSERT(fContext);
// get mip level
- const SkMatrix& vm = drawState->getViewMatrix();
- SkScalar maxScale = vm.getMaxScale();
+ SkScalar maxScale = viewMatrix.getMaxScale();
const SkRect& bounds = path.getBounds();
SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
SkScalar size = maxScale*maxDim;
@@ -144,7 +144,7 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
}
// use signed distance field to render
- return this->internalDrawPath(target, drawState, color, path, pathData);
+ return this->internalDrawPath(target, drawState, color, viewMatrix, path, pathData);
}
// padding around path bounds to allow for antialiased pixels
@@ -308,6 +308,7 @@ bool GrAADistanceFieldPathRenderer::freeUnusedPlot() {
bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
GrDrawState* drawState,
GrColor color,
+ const SkMatrix& viewMatrix,
const SkPath& path,
const PathData* pathData) {
GrTexture* texture = fAtlas->getTexture();
@@ -319,12 +320,13 @@ bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
// set up any flags
uint32_t flags = 0;
- const SkMatrix& vm = drawState->getViewMatrix();
- flags |= vm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
+ flags |= viewMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode);
- if (flags != fEffectFlags || fCachedGeometryProcessor->color() != color) {
+ if (flags != fEffectFlags || fCachedGeometryProcessor->color() != color ||
+ !fCachedGeometryProcessor->viewMatrix().cheapEqualTo(viewMatrix)) {
fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Create(color,
+ viewMatrix,
texture,
params,
flags,
@@ -370,7 +372,7 @@ bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + th)),
vertSize);
- vm.mapRect(&r);
+ viewMatrix.mapRect(&r);
target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
target->drawIndexedInstances(drawState, fCachedGeometryProcessor.get(),
kTriangles_GrPrimitiveType, 1, 4, 6, &r);
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698