## epoger will rebaseline by 25 Dec 2013
#gradtext
+#joshualitt
+gpusamplerstress
+
# robertphillips - skia:2995
blurrects
SkAutoTUnref<const GrGeometryProcessor> gp(
GrDefaultGeoProcFactory::Create(0xff000000));
ds.addCoverageProcessor(fp);
- ds.setIdentityViewMatrix();
ds.setRenderTarget(rt);
GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVertexStride(), 0);
SkAutoTUnref<const GrGeometryProcessor> gp(
GrDefaultGeoProcFactory::Create(0xff000000));
ds.addCoverageProcessor(fp);
- ds.setIdentityViewMatrix();
ds.setRenderTarget(rt);
GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVertexStride(), 0);
rrect));
if (fp) {
drawState.addCoverageProcessor(fp);
- drawState.setIdentityViewMatrix();
drawState.setRenderTarget(rt);
SkRect bounds = rrect.getBounds();
*/
bool isOpaqueAndConstantColor(GrColor* constantColor) const;
- /**
- * DO NOT USE THESE
- * TODO Remove remaining use cases and delete these
- */
- bool localCoordChangeInverse(const SkMatrix& newToOld) {
- SkMatrix oldToNew;
- bool computed = false;
- for (int i = 0; i < fColorStages.count(); ++i) {
- if (!computed && !newToOld.invert(&oldToNew)) {
- return false;
- } else {
- computed = true;
- }
- fColorStages[i].localCoordChange(oldToNew);
- }
- for (int i = 0; i < fCoverageStages.count(); ++i) {
- if (!computed && !newToOld.invert(&oldToNew)) {
- return false;
- } else {
- computed = true;
- }
- fCoverageStages[i].localCoordChange(oldToNew);
- }
- return true;
- }
-
private:
friend class GrContext; // To access above two functions
friend class GrStencilAndCoverTextContext; // To access above two functions
// 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:
"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");
}
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,
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");
}
// 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");
}
}
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode);
- // TODO cache these GPs
if (kARGB_GrMaskFormat == fCurrMaskFormat) {
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
if (textureUniqueID != fEffectTextureUniqueID ||
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;
}
}
SkAutoTUnref<const GrFragmentProcessor> fCachedTextureProcessor;
// Used to check whether fCachedEffect is still valid.
uint32_t fEffectTextureUniqueID;
+ SkMatrix fLocalMatrix;
GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
SkRegion::Op op,
const SkIRect& dstBound,
const SkIRect& srcBound) {
- SkAssertResult(drawState->setIdentityViewMatrix());
-
drawState->setRenderTarget(dstMask->asRenderTarget());
// We want to invert the coverage here
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,
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,
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
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"; }
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,
}
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)
}
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);
}
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); }
};
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());
return false;
}
- /**
- * Sets the view matrix to identity and updates any installed effects to compensate for the
- * coord system change.
- */
- bool setIdentityViewMatrix();
-
////////////////////////////////////////////////////////////////////////////
/**
* @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,
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) {
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) :
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,
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,
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,
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
}
- target->drawRect(drawState, color, bounds, NULL, NULL);
+ target->drawSimpleRect(drawState, color, bounds);
return true;
}
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);
}
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);
}
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);
}
// 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:
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) {
GrTextureParams::kNone_FilterMode);
return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
- random->nextBool(), random->nextBool());
+ random->nextBool(), random->nextBool(),
+ GrProcessorUnitTest::TestMatrix(random));
}
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() {}
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;
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);
}
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);
}
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:
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:
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:
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;
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));