aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-12-22 15:27:05 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-22 15:27:05 -0800
commit8fc6c2d82c1f30ff82274334c01f0799def6a609 (patch)
tree6499d32fd02b524167a690704d855e804f66c8a3 /src
parent16c8f14cd481b78673a33450a1395958e3e10e62 (diff)
This CL cleans up the last remaining users of localCoordChange on paint
NOTREECHECKS=True BUG=skia: Review URL: https://codereview.chromium.org/817853002
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp8
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp3
-rwxr-xr-xsrc/gpu/GrBitmapTextContext.cpp15
-rw-r--r--src/gpu/GrBitmapTextContext.h1
-rw-r--r--src/gpu/GrClipMaskManager.cpp14
-rwxr-xr-xsrc/gpu/GrContext.cpp29
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp25
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.h10
-rw-r--r--src/gpu/GrDrawState.cpp18
-rw-r--r--src/gpu/GrDrawState.h6
-rw-r--r--src/gpu/GrDrawTarget.h8
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp21
-rw-r--r--src/gpu/GrOvalRenderer.cpp15
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp3
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp15
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.h8
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp2
-rwxr-xr-xsrc/gpu/effects/GrDistanceFieldTextureEffect.cpp18
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp19
19 files changed, 149 insertions, 89 deletions
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 2c7f5ee8ce..d18d3c3b6a 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -564,9 +564,9 @@ void GrGLDisplacementMapEffect::emitCode(GrGLFPBuilder* builder,
// Unpremultiply the displacement
fsBuilder->codeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
dColor, dColor, nearZero, dColor, dColor);
-
+ SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 1);
fsBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.",
- cCoords, coords[1].c_str(), scaleUni, dColor);
+ cCoords, coords2D.c_str(), scaleUni, dColor);
switch (fXChannelSelector) {
case SkDisplacementMapEffect::kR_ChannelSelectorType:
@@ -611,7 +611,9 @@ void GrGLDisplacementMapEffect::emitCode(GrGLFPBuilder* builder,
"bool %s = (%s.x < 0.0) || (%s.y < 0.0) || (%s.x > 1.0) || (%s.y > 1.0);\t\t",
outOfBounds, cCoords, cCoords, cCoords, cCoords);
fsBuilder->codeAppendf("%s = %s ? vec4(0.0) : ", outputColor, outOfBounds);
- fsBuilder->appendTextureLookup(samplers[1], cCoords, coords[1].getType());
+
+ // cCoords is always a vec2f
+ fsBuilder->appendTextureLookup(samplers[1], cCoords, kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
}
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 311010fcd9..6d69823caf 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -575,7 +575,8 @@ public:
const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const BatchTracker& local = bt.cast<BatchTracker>();
- b->add32(local.fInputColorType);
+ b->add32((local.fInputColorType << 16) |
+ (local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0x0));
}
virtual void setData(const GrGLProgramDataManager& pdman,
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 732a514c4f..790590dbcc 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -154,7 +154,8 @@ void GrBitmapTextContext::onDrawText(const GrPaint& paint, const SkPaint& skPain
SkFixed fx = SkScalarToFixed(x) + halfSampleX;
SkFixed fy = SkScalarToFixed(y) + halfSampleY;
- if (!fPaint.localCoordChangeInverse(viewMatrix)) {
+ // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix
+ if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatrix)) {
SkDebugf("Cannot invert viewmatrix\n");
}
@@ -202,7 +203,9 @@ void GrBitmapTextContext::onDrawPosText(const GrPaint& paint, const SkPaint& skP
// store original matrix before we reset, so we can use it to transform positions
SkMatrix ctm = viewMatrix;
- if (!fPaint.localCoordChangeInverse(viewMatrix)) {
+
+ // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix
+ if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatrix)) {
SkDebugf("Cannot invert viewmatrix\n");
}
@@ -559,7 +562,6 @@ void GrBitmapTextContext::flush() {
}
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode);
- // TODO cache these GPs
if (kARGB_GrMaskFormat == fCurrMaskFormat) {
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
if (textureUniqueID != fEffectTextureUniqueID ||
@@ -569,19 +571,22 @@ void GrBitmapTextContext::flush() {
fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCurrTexture,
SkMatrix::I(),
params));
+ fEffectTextureUniqueID = textureUniqueID;
}
drawState.addColorProcessor(fCachedTextureProcessor.get());
} else {
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
if (textureUniqueID != fEffectTextureUniqueID ||
- fCachedGeometryProcessor->color() != color) {
+ fCachedGeometryProcessor->color() != color ||
+ !fCachedGeometryProcessor->localMatrix().cheapEqualTo(fLocalMatrix)) {
bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor());
fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color,
fCurrTexture,
params,
hasColor,
- opaqueVertexColors));
+ opaqueVertexColors,
+ fLocalMatrix));
fEffectTextureUniqueID = textureUniqueID;
}
}
diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h
index ad21a2ffda..f1e6b03212 100644
--- a/src/gpu/GrBitmapTextContext.h
+++ b/src/gpu/GrBitmapTextContext.h
@@ -35,6 +35,7 @@ private:
SkAutoTUnref<const GrFragmentProcessor> fCachedTextureProcessor;
// Used to check whether fCachedEffect is still valid.
uint32_t fEffectTextureUniqueID;
+ SkMatrix fLocalMatrix;
GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 5e2c0aa795..e56f4dd77d 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -425,8 +425,6 @@ void GrClipMaskManager::mergeMask(GrDrawState* drawState,
SkRegion::Op op,
const SkIRect& dstBound,
const SkIRect& srcBound) {
- SkAssertResult(drawState->setIdentityViewMatrix());
-
drawState->setRenderTarget(dstMask->asRenderTarget());
// We want to invert the coverage here
@@ -606,11 +604,11 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
return NULL;
}
- GrDrawState backgroundDrawState(translate);
- backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
- backgroundDrawState.setRenderTarget(result->asRenderTarget());
-
if (useTemp) {
+ GrDrawState backgroundDrawState;
+ backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
+ backgroundDrawState.setRenderTarget(result->asRenderTarget());
+
// Now draw into the accumulator using the real operation and the temp buffer as a
// texture
this->mergeMask(&backgroundDrawState,
@@ -620,6 +618,10 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
maskSpaceIBounds,
maskSpaceElementIBounds);
} else {
+ GrDrawState backgroundDrawState(translate);
+ backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
+ backgroundDrawState.setRenderTarget(result->asRenderTarget());
+
set_coverage_drawing_xpf(op, !invert, &backgroundDrawState);
// Draw to the exterior pixels (those with a zero stencil value).
GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement,
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index c637101d07..2818aa92dd 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -555,29 +555,42 @@ void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix)
SkIntToScalar(getRenderTarget()->width()),
SkIntToScalar(getRenderTarget()->height()));
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
- GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::drawPaint", this);
+
+ // by definition this fills the entire clip, no need for AA
+ if (paint->isAntiAlias()) {
+ paint.writable()->setAntiAlias(false);
+ }
+
+ bool isPerspective = viewMatrix.hasPerspective();
// We attempt to map r by the inverse matrix and draw that. mapRect will
// map the four corners and bound them with a new rect. This will not
// produce a correct result for some perspective matrices.
- if (!viewMatrix.hasPerspective()) {
+ if (!isPerspective) {
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
SkDebugf("Could not invert matrix\n");
return;
}
inverse.mapRect(&r);
+ this->drawRect(*paint, viewMatrix, r);
} else {
- if (!paint.writable()->localCoordChangeInverse(viewMatrix)) {
+ SkMatrix localMatrix;
+ if (!viewMatrix.invert(&localMatrix)) {
SkDebugf("Could not invert matrix\n");
return;
}
+
+ AutoCheckFlush acf(this);
+ GrDrawState drawState;
+ GrDrawTarget* target = this->prepareToDraw(&drawState, paint, &SkMatrix::I(), &acf);
+ if (NULL == target) {
+ return;
+ }
+
+ GR_CREATE_TRACE_MARKER("GrContext::drawPaintWithPerspective", target);
+ target->drawRect(&drawState, paint->getColor(), r, NULL, &localMatrix);
}
- // by definition this fills the entire clip, no need for AA
- if (paint->isAntiAlias()) {
- paint.writable()->setAntiAlias(false);
- }
- this->drawRect(*paint, viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix, r);
}
#ifdef SK_DEVELOPER
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index a74565c5d7..7f557b52b5 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -22,8 +22,9 @@ typedef GrDefaultGeoProcFactory Flag;
class DefaultGeoProc : public GrGeometryProcessor {
public:
static GrGeometryProcessor* Create(GrColor color, uint8_t coverage, uint32_t gpTypeFlags,
- bool opaqueVertexColors) {
- return SkNEW_ARGS(DefaultGeoProc, (color, coverage, gpTypeFlags, opaqueVertexColors));
+ bool opaqueVertexColors, const SkMatrix& localMatrix) {
+ return SkNEW_ARGS(DefaultGeoProc, (color, coverage, gpTypeFlags, opaqueVertexColors,
+ localMatrix));
}
virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; }
@@ -122,10 +123,11 @@ public:
const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
- b->add32(def.fFlags);
-
const BatchTracker& local = bt.cast<BatchTracker>();
- b->add32(local.fInputColorType | local.fInputCoverageType << 16);
+ uint32_t key = def.fFlags;
+ key |= local.fInputColorType << 8 | local.fInputCoverageType << 16;
+ key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
+ b->add32(key);
}
virtual void setData(const GrGLProgramDataManager& pdman,
@@ -164,8 +166,9 @@ public:
}
private:
- DefaultGeoProc(GrColor color, uint8_t coverage, uint32_t gpTypeFlags, bool opaqueVertexColors)
- : INHERITED(color, opaqueVertexColors)
+ DefaultGeoProc(GrColor color, uint8_t coverage, uint32_t gpTypeFlags, bool opaqueVertexColors,
+ const SkMatrix& localMatrix)
+ : INHERITED(color, opaqueVertexColors, localMatrix)
, fInPosition(NULL)
, fInColor(NULL)
, fInLocalCoords(NULL)
@@ -244,12 +247,14 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(SkRandom* random,
}
return DefaultGeoProc::Create(GrRandomColor(random), GrRandomCoverage(random),
- flags, random->nextBool());
+ flags, random->nextBool(),
+ GrProcessorUnitTest::TestMatrix(random));
}
const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(GrColor color,
uint32_t gpTypeFlags,
bool opaqueVertexColors,
- uint8_t coverage) {
- return DefaultGeoProc::Create(color, coverage, gpTypeFlags, opaqueVertexColors);
+ uint8_t coverage,
+ const SkMatrix& localMatrix) {
+ return DefaultGeoProc::Create(color, coverage, gpTypeFlags, opaqueVertexColors, localMatrix);
}
diff --git a/src/gpu/GrDefaultGeoProcFactory.h b/src/gpu/GrDefaultGeoProcFactory.h
index f13ff85904..b7db74d845 100644
--- a/src/gpu/GrDefaultGeoProcFactory.h
+++ b/src/gpu/GrDefaultGeoProcFactory.h
@@ -83,7 +83,15 @@ public:
static const GrGeometryProcessor* Create(GrColor,
uint32_t gpTypeFlags = 0,
bool opaqueVertexColors = false,
- uint8_t coverage = 0xff);
+ uint8_t coverage = 0xff,
+ const SkMatrix& localMatrix = SkMatrix::I());
+
+ static const GrGeometryProcessor* Create(GrColor color,
+ uint32_t gpTypeFlags,
+ const SkMatrix& localMatrix) {
+ return Create(color, gpTypeFlags, false, 0xff, localMatrix);
+ }
+
static size_t DefaultVertexStride() { return sizeof(PositionAttr); }
};
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 68cd01c3d5..643253efc0 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -112,24 +112,6 @@ void GrDrawState::onReset(const SkMatrix* initialViewMatrix) {
fCoveragePrimProc = NULL;
}
-bool GrDrawState::setIdentityViewMatrix() {
- if (this->numFragmentStages()) {
- SkMatrix invVM;
- if (!fViewMatrix.invert(&invVM)) {
- // sad trombone sound
- return false;
- }
- for (int s = 0; s < this->numColorStages(); ++s) {
- fColorStages[s].localCoordChange(invVM);
- }
- for (int s = 0; s < this->numCoverageStages(); ++s) {
- fCoverageStages[s].localCoordChange(invVM);
- }
- }
- fViewMatrix.reset();
- return true;
-}
-
void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRenderTarget* rt) {
SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 24f987d0ce..36e2b3a2fb 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -303,12 +303,6 @@ public:
return false;
}
- /**
- * Sets the view matrix to identity and updates any installed effects to compensate for the
- * coord system change.
- */
- bool setIdentityViewMatrix();
-
////////////////////////////////////////////////////////////////////////////
/**
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 64cbc8781e..d2c20a1eed 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -303,10 +303,10 @@ public:
* @param rect the rect to draw
* @param localRect optional rect that specifies local coords to map onto
* rect. If NULL then rect serves as the local coords.
- * @param localMatrix optional matrix applied to localRect. If
- * srcRect is non-NULL and srcMatrix is non-NULL
- * then srcRect will be transformed by srcMatrix.
- * srcMatrix can be NULL when no srcMatrix is desired.
+ * @param localMatrix Optional local matrix. The local coordinates are specified by localRect,
+ * or if it is NULL by rect. This matrix applies to the coordinate implied by
+ * that rectangle before it is input to GrCoordTransforms that read local
+ * coordinates
*/
void drawRect(GrDrawState* ds,
GrColor color,
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index dc074b7b51..6e5c1fe778 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -62,13 +62,18 @@ void get_vertex_bounds(const void* vertices,
The vertex attrib order is always pos, color, [local coords].
*/
-static const GrGeometryProcessor* create_rect_gp(GrDrawState* drawState,
- bool hasLocalCoords,
- GrColor color) {
+static const GrGeometryProcessor* create_rect_gp(bool hasExplicitLocalCoords,
+ GrColor color,
+ const SkMatrix* localMatrix) {
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kColor_GPType;
- flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
- return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(color));
+ flags |= hasExplicitLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
+ if (localMatrix) {
+ return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(color), 0xff,
+ *localMatrix);
+ } else {
+ return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(color));
+ }
}
static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettings) {
@@ -115,7 +120,11 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
const SkMatrix* localMatrix) {
GrDrawState::AutoRestoreEffects are(ds);
- SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(ds, SkToBool(localRect), color));
+ bool hasExplicitLocalCoords = SkToBool(localRect);
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ create_rect_gp(hasExplicitLocalCoords,
+ color,
+ hasExplicitLocalCoords ? NULL : localMatrix));
size_t vstride = gp->getVertexStride();
SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) :
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 304d6d69ad..05838cf6e5 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -123,7 +123,9 @@ public:
GrProcessorKeyBuilder* b) {
const BatchTracker& local = bt.cast<BatchTracker>();
const CircleEdgeEffect& circleEffect = processor.cast<CircleEdgeEffect>();
- b->add32(circleEffect.isStroked() << 16 | local.fInputColorType);
+ uint16_t key = circleEffect.isStroked() ? 0x1 : 0x0;
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x2 : 0x0;
+ b->add32(key << 16 | local.fInputColorType);
}
virtual void setData(const GrGLProgramDataManager& pdman,
@@ -306,7 +308,9 @@ public:
GrProcessorKeyBuilder* b) {
const BatchTracker& local = bt.cast<BatchTracker>();
const EllipseEdgeEffect& ellipseEffect = processor.cast<EllipseEdgeEffect>();
- b->add32(ellipseEffect.isStroked() << 16 | local.fInputColorType);
+ uint16_t key = ellipseEffect.isStroked() ? 0x1 : 0x0;
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x2 : 0x0;
+ b->add32(key << 16 | local.fInputColorType);
}
virtual void setData(const GrGLProgramDataManager& pdman,
@@ -510,7 +514,10 @@ public:
GrProcessorKeyBuilder* b) {
const BatchTracker& local = bt.cast<BatchTracker>();
const DIEllipseEdgeEffect& ellipseEffect = processor.cast<DIEllipseEdgeEffect>();
- b->add32(ellipseEffect.getMode() << 16 | local.fInputColorType);
+ uint16_t key = ellipseEffect.getMode();
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 8 :
+ 0x0;
+ b->add32(key << 16 | local.fInputColorType);
}
virtual void setData(const GrGLProgramDataManager& pdman,
@@ -1086,7 +1093,7 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target,
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
}
- target->drawRect(drawState, color, bounds, NULL, NULL);
+ target->drawSimpleRect(drawState, color, bounds);
return true;
}
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 2a4ef3692f..0ba7beeb88 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -165,6 +165,7 @@ void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor,
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x10 : 0x0;
b->add32(key);
}
@@ -374,6 +375,7 @@ void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor,
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x10 : 0x0;
b->add32(key);
}
@@ -605,6 +607,7 @@ void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor,
const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8;
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x10 : 0x0;
b->add32(key);
}
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 09eee1c70d..44de98a348 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -75,8 +75,10 @@ public:
// on addVertexAttrib.
// TODO When we have deferred geometry we can fix this
const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
- b->add32(SkToBool(gp.inColor()));
- b->add32(local.fInputColorType);
+ uint32_t key = 0;
+ key |= SkToBool(gp.inColor()) ? 0x1 : 0x0;
+ key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x2 : 0x0;
+ b->add32(local.fInputColorType << 16 | key);
}
private:
@@ -90,8 +92,10 @@ private:
GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture,
const GrTextureParams& params, bool useColorAttrib,
- bool opaqueVertexColors)
- : INHERITED(color, opaqueVertexColors), fTextureAccess(texture, params), fInColor(NULL) {
+ bool opaqueVertexColors, const SkMatrix& localMatrix)
+ : INHERITED(color, opaqueVertexColors, localMatrix)
+ , fTextureAccess(texture, params)
+ , fInColor(NULL) {
this->initClassID<GrBitmapTextGeoProc>();
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
if (useColorAttrib) {
@@ -172,5 +176,6 @@ GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
GrTextureParams::kNone_FilterMode);
return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
- random->nextBool(), random->nextBool());
+ random->nextBool(), random->nextBool(),
+ GrProcessorUnitTest::TestMatrix(random));
}
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h
index 507515bedb..c69ffd7a1b 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -22,8 +22,10 @@ class GrInvariantOutput;
class GrBitmapTextGeoProc : public GrGeometryProcessor {
public:
static GrGeometryProcessor* Create(GrColor color, GrTexture* tex, const GrTextureParams& p,
- bool useColorAttrib, bool opaqueVertexColors) {
- return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, useColorAttrib, opaqueVertexColors));
+ bool useColorAttrib, bool opaqueVertexColors,
+ const SkMatrix& localMatrix) {
+ return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, useColorAttrib, opaqueVertexColors,
+ localMatrix));
}
virtual ~GrBitmapTextGeoProc() {}
@@ -47,7 +49,7 @@ public:
private:
GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
- bool useColorAttrib, bool opaqueVertexColors);
+ bool useColorAttrib, bool opaqueVertexColors, const SkMatrix& localMatrix);
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 35b763788a..d5b0b48e9b 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -624,6 +624,7 @@ void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor,
GrProcessorKeyBuilder* b) {
const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>();
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
+ b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective());
b->add32(dce.getEdgeType() << 16 | local.fInputColorType);
}
@@ -913,6 +914,7 @@ void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor,
GrProcessorKeyBuilder* b) {
const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>();
const DashingLineEffect& de = processor.cast<DashingLineEffect>();
+ b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective());
b->add32(de.getEdgeType() << 16 | local.fInputColorType);
}
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index 0f930af371..f5510d478b 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -166,8 +166,10 @@ public:
const GrDistanceFieldTextureEffect& dfTexEffect =
processor.cast<GrDistanceFieldTextureEffect>();
const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTracker>();
- b->add32(dfTexEffect.getFlags());
- b->add32(local.fInputColorType);
+ uint32_t key = dfTexEffect.getFlags();
+ key |= local.fInputColorType << 16;
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
+ b->add32(key);
}
private:
@@ -422,8 +424,10 @@ public:
proc.cast<GrDistanceFieldNoGammaTextureEffect>();
const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoGammaBatchTracker>();
- b->add32(dfTexEffect.getFlags());
- b->add32(local.fInputColorType);
+ uint32_t key = dfTexEffect.getFlags();
+ key |= local.fInputColorType << 16;
+ key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
+ b->add32(key);
}
private:
@@ -724,8 +728,10 @@ public:
processor.cast<GrDistanceFieldLCDTextureEffect>();
const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatchTracker>();
- b->add32(dfTexEffect.getFlags());
- b->add32(local.fInputColorType);
+ uint32_t key = dfTexEffect.getFlags();
+ key |= local.fInputColorType << 16;
+ key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
+ b->add32(key);
}
private:
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index cfb1d38b61..13a14534cf 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -378,8 +378,22 @@ void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage,
for (int t = 0; t < numTransforms; t++) {
const char* uniName = "StageMatrix";
- GrSLType varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrSLType :
- kVec2f_GrSLType;
+ GrSLType varyingType;
+
+ // TODO when we have deleted the coord change matrices we can get rid of the below check
+ GrCoordSet coordType = processor->coordTransform(t).sourceCoords();
+ const SkMatrix& localMatrix = fOptState.getPrimitiveProcessor()->localMatrix();
+ if (localMatrix.isIdentity()) {
+ varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrSLType :
+ kVec2f_GrSLType;
+ } else {
+ uint32_t type = processor->coordTransform(t).getMatrix().getType();
+ if (kLocal_GrCoordSet == coordType) {
+ type |= localMatrix.getType();
+ }
+ varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSLType :
+ kVec2f_GrSLType;
+ }
GrSLPrecision precision = processor->coordTransform(t).precision();
SkString suffixedUniName;
@@ -401,7 +415,6 @@ void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage,
varyingName = suffixedVaryingName.c_str();
}
- GrCoordSet coordType = processor->coordTransform(t).sourceCoords();
GrGLVertToFrag v(varyingType);
this->addVarying(varyingName, &v, precision);
fCoordVaryings.push_back(TransformVarying(v, uniName, coordType));