Refactor position computation to enable device space "nudge"
To match raster's handling of BW geometry we want to be able to perform a device space "nudge" on all geometry. This CL sets us up to be able to do that in GrGLVertexBuilder::transformToNormalizedDeviceSpace. BUG=423834 TBR=bsalomon@google.com Review URL: https://codereview.chromium.org/854013002
This commit is contained in:
parent
75d98fd6f2
commit
46d36f0e7b
@ -79,5 +79,33 @@ dropshadowimagefilter
|
||||
# bsalomon slight change to image-surface GM on gpu
|
||||
image-surface
|
||||
|
||||
|
||||
|
||||
# robertphillips - https://codereview.chromium.org/854013002/
|
||||
# gpu-only and only a few low intensity pixel diffs
|
||||
conicpaths
|
||||
convexpaths
|
||||
dashcubics
|
||||
dcshader
|
||||
dftext
|
||||
fontmgr_bounds
|
||||
fontmgr_bounds_1_-0.25
|
||||
fontmgr_bounds_0.75_0
|
||||
getpostextpath
|
||||
glyph_pos_h_s
|
||||
gradients_view_perspective
|
||||
hairlines
|
||||
mixed_xfermodes
|
||||
patch_grid
|
||||
patch_primitive
|
||||
pathinterior
|
||||
path-reverse
|
||||
points
|
||||
poly2poly
|
||||
polygons
|
||||
roundrects
|
||||
rrect
|
||||
shadertext2
|
||||
shadertext3
|
||||
stringart
|
||||
strokerects
|
||||
strokes3
|
||||
stroketext
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(typeModifier)
|
||||
, fName(name)
|
||||
@ -85,46 +85,11 @@ public:
|
||||
kUnsizedArray = -1, // an unsized array (declared with [])
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets as a non-array.
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const SkString& name,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets as a non-array.
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const char* name,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all var options
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const SkString& name,
|
||||
int count,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision) {
|
||||
TypeModifier typeModifier = kNone_TypeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
int count = kNonArray) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
fType = type;
|
||||
@ -134,14 +99,11 @@ public:
|
||||
fPrecision = precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all var options
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const char* name,
|
||||
int count,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision) {
|
||||
TypeModifier typeModifier = kNone_TypeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
int count = kNonArray) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
fType = type;
|
||||
|
@ -535,7 +535,7 @@ public:
|
||||
const GrBatchTracker&)
|
||||
: fColor(GrColor_ILLEGAL) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE {
|
||||
const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
|
||||
@ -557,11 +557,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
qe.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, qe.inPosition()->fName,
|
||||
qe.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), qe.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()->fName,
|
||||
qe.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
@ -594,8 +594,10 @@ public:
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
b->add32((local.fInputColorType << 16) |
|
||||
(local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0x0));
|
||||
uint32_t key = local.fInputColorType << 16;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 1;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
|
@ -83,15 +83,15 @@ public:
|
||||
GLProcessor(const GrGeometryProcessor& gp, const GrBatchTracker&)
|
||||
: fColor(GrColor_ILLEGAL), fCoverage(0xff) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE {
|
||||
const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vs = pb->getVertexShaderBuilder();
|
||||
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
|
||||
GrGLGPFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
|
||||
// emit attributes
|
||||
vs->emitAttributes(gp);
|
||||
vsBuilder->emitAttributes(gp);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, gp.inColor(),
|
||||
@ -101,16 +101,16 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vs->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
gp.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, gp.inPosition()->fName,
|
||||
gp.viewMatrix(), this->uViewM());
|
||||
|
||||
if (gp.inLocalCoords()) {
|
||||
// emit transforms with explicit local coords
|
||||
this->emitTransforms(pb, this->position(), gp.inLocalCoords()->fName,
|
||||
this->emitTransforms(pb, gpArgs->fPositionVar, gp.inLocalCoords()->fName,
|
||||
gp.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
} else {
|
||||
// emit transforms with position
|
||||
this->emitTransforms(pb, this->position(), gp.inPosition()->fName,
|
||||
this->emitTransforms(pb, gpArgs->fPositionVar, gp.inPosition()->fName,
|
||||
gp.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
}
|
||||
|
||||
@ -142,6 +142,7 @@ public:
|
||||
uint32_t key = def.fFlags;
|
||||
key |= local.fInputColorType << 8 | local.fInputCoverageType << 16;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
|
@ -163,13 +163,13 @@ void GrGLPrimitiveProcessor::setUniformViewMatrix(const GrGLProgramDataManager&
|
||||
|
||||
void GrGLGeometryProcessor::emitCode(EmitArgs& args) {
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
vsBuilder->codeAppendf("vec3 %s;", this->position());
|
||||
this->onEmitCode(args);
|
||||
vsBuilder->transformToNormalizedDeviceSpace(this->position());
|
||||
GrGPArgs gpArgs;
|
||||
this->onEmitCode(args, &gpArgs);
|
||||
vsBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar);
|
||||
}
|
||||
|
||||
void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb,
|
||||
const char* position,
|
||||
const GrShaderVar& posVar,
|
||||
const char* localCoords,
|
||||
const SkMatrix& localMatrix,
|
||||
const TransformsIn& tin,
|
||||
@ -214,9 +214,19 @@ void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb,
|
||||
// varying = matrix * coords (logically)
|
||||
if (kDevice_GrCoordSet == coordType) {
|
||||
if (kVec2f_GrSLType == varyingType) {
|
||||
vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), uniName, position);
|
||||
if (kVec2f_GrSLType == posVar.getType()) {
|
||||
vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;",
|
||||
v.vsOut(), uniName, posVar.c_str());
|
||||
} else {
|
||||
vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), uniName, posVar.c_str());
|
||||
}
|
||||
} else {
|
||||
vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, position);
|
||||
if (kVec2f_GrSLType == posVar.getType()) {
|
||||
vb->codeAppendf("%s = %s * vec3(%s, 1);",
|
||||
v.vsOut(), uniName, posVar.c_str());
|
||||
} else {
|
||||
vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, posVar.c_str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (kVec2f_GrSLType == varyingType) {
|
||||
@ -247,6 +257,28 @@ GrGLGeometryProcessor::setTransformData(const GrPrimitiveProcessor* primProc,
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGeometryProcessor::SetupPosition(GrGLVertexBuilder* vsBuilder,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
const char* matName) {
|
||||
if (mat.isIdentity()) {
|
||||
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
|
||||
|
||||
vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
} else if (!mat.hasPerspective()) {
|
||||
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
|
||||
|
||||
vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));",
|
||||
gpArgs->fPositionVar.c_str(), matName, posName);
|
||||
} else {
|
||||
gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
|
||||
|
||||
vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
|
||||
gpArgs->fPositionVar.c_str(), matName, posName);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "gl/GrGLGpu.h"
|
||||
|
@ -220,7 +220,7 @@ protected:
|
||||
private:
|
||||
virtual bool hasExplicitLocalCoords() const = 0;
|
||||
|
||||
SkMatrix fViewMatrix;
|
||||
const SkMatrix fViewMatrix;
|
||||
SkMatrix fLocalMatrix;
|
||||
|
||||
typedef GrProcessor INHERITED;
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
const GrBatchTracker&)
|
||||
: fColor(GrColor_ILLEGAL) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{
|
||||
const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
@ -104,11 +104,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
ce.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, ce.inPosition()->fName,
|
||||
ce.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), ce.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, ce.inPosition()->fName,
|
||||
ce.localMatrix(), args.fTransformsIn, args.fTransformsOut);;
|
||||
|
||||
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
@ -123,14 +123,15 @@ public:
|
||||
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
|
||||
}
|
||||
|
||||
static void GenKey(const GrGeometryProcessor& processor,
|
||||
static void GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
const CircleEdgeEffect& circleEffect = processor.cast<CircleEdgeEffect>();
|
||||
const CircleEdgeEffect& circleEffect = gp.cast<CircleEdgeEffect>();
|
||||
uint16_t key = circleEffect.isStroked() ? 0x1 : 0x0;
|
||||
key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 2;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
}
|
||||
|
||||
@ -259,7 +260,7 @@ public:
|
||||
const GrBatchTracker&)
|
||||
: fColor(GrColor_ILLEGAL) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{
|
||||
const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
@ -286,11 +287,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
ee.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, ee.inPosition()->fName,
|
||||
ee.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), ee.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, ee.inPosition()->fName,
|
||||
ee.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
// for outer curve
|
||||
@ -320,14 +321,15 @@ public:
|
||||
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
|
||||
}
|
||||
|
||||
static void GenKey(const GrGeometryProcessor& processor,
|
||||
static void GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
const EllipseEdgeEffect& ellipseEffect = processor.cast<EllipseEdgeEffect>();
|
||||
const EllipseEdgeEffect& ellipseEffect = gp.cast<EllipseEdgeEffect>();
|
||||
uint16_t key = ellipseEffect.isStroked() ? 0x1 : 0x0;
|
||||
key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 2;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
}
|
||||
|
||||
@ -463,7 +465,7 @@ public:
|
||||
const GrBatchTracker&)
|
||||
: fColor(GrColor_ILLEGAL) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{
|
||||
const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
@ -490,11 +492,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
ee.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, ee.inPosition()->fName,
|
||||
ee.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), ee.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, ee.inPosition()->fName,
|
||||
ee.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
@ -538,15 +540,15 @@ public:
|
||||
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
|
||||
}
|
||||
|
||||
static void GenKey(const GrGeometryProcessor& processor,
|
||||
static void GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
const DIEllipseEdgeEffect& ellipseEffect = processor.cast<DIEllipseEdgeEffect>();
|
||||
const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffect>();
|
||||
uint16_t key = ellipseEffect.getMode();
|
||||
key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 8 :
|
||||
0x0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 8 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 9;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
GrGLConicEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
|
||||
void onEmitCode(EmitArgs&) SK_OVERRIDE;
|
||||
void onEmitCode(EmitArgs&, GrGPArgs*) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&,
|
||||
@ -66,7 +66,7 @@ GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor,
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
|
||||
void GrGLConicEffect::onEmitCode(EmitArgs& args) {
|
||||
void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
|
||||
@ -87,11 +87,10 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args) {
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
gp.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, gp.inPosition()->fName, gp.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(pb, this->position(), gp.inPosition()->fName, gp.localMatrix(),
|
||||
this->emitTransforms(pb, gpArgs->fPositionVar, gp.inPosition()->fName, gp.localMatrix(),
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
@ -164,16 +163,17 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args) {
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrConicEffect& ce = processor.cast<GrConicEffect>();
|
||||
const GrConicEffect& ce = gp.cast<GrConicEffect>();
|
||||
const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
|
||||
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;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 5;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ public:
|
||||
GrGLQuadEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
|
||||
void onEmitCode(EmitArgs&) SK_OVERRIDE;
|
||||
void onEmitCode(EmitArgs&, GrGPArgs*) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&,
|
||||
@ -304,7 +304,7 @@ GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor,
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
|
||||
void GrGLQuadEffect::onEmitCode(EmitArgs& args) {
|
||||
void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
|
||||
@ -325,11 +325,10 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args) {
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
gp.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, gp.inPosition()->fName, gp.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(pb, this->position(), gp.inPosition()->fName, gp.localMatrix(),
|
||||
this->emitTransforms(pb, gpArgs->fPositionVar, gp.inPosition()->fName, gp.localMatrix(),
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
@ -388,16 +387,17 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args) {
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
|
||||
const GrQuadEffect& ce = gp.cast<GrQuadEffect>();
|
||||
const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
|
||||
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;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 5;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
@ -486,7 +486,7 @@ public:
|
||||
GrGLCubicEffect(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&);
|
||||
|
||||
void onEmitCode(EmitArgs&) SK_OVERRIDE;
|
||||
void onEmitCode(EmitArgs&, GrGPArgs*) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&,
|
||||
@ -522,7 +522,7 @@ GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor,
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
|
||||
void GrGLCubicEffect::onEmitCode(EmitArgs& args) {
|
||||
void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
|
||||
const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>();
|
||||
@ -542,11 +542,10 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args) {
|
||||
this->addUniformViewMatrix(args.fPB);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
gp.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, gp.inPosition()->fName, gp.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(args.fPB, this->position(), gp.inPosition()->fName, gp.localMatrix(),
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, gp.inPosition()->fName, gp.localMatrix(),
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
@ -636,15 +635,16 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args) {
|
||||
fsBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
|
||||
}
|
||||
|
||||
void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
|
||||
const GrCubicEffect& ce = gp.cast<GrCubicEffect>();
|
||||
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;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 5;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&)
|
||||
: fColor(GrColor_ILLEGAL) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{
|
||||
const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
|
||||
const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTracker>();
|
||||
|
||||
@ -47,11 +47,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
cte.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, cte.inPosition()->fName,
|
||||
cte.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), cte.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->fName,
|
||||
cte.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
GrGLGPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
|
||||
@ -86,6 +86,7 @@ public:
|
||||
uint32_t key = 0;
|
||||
key |= SkToBool(gp.inColor()) ? 0x1 : 0x0;
|
||||
key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 2;
|
||||
b->add32(local.fInputColorType << 16 | key);
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,7 @@ class GLDashingCircleEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&);
|
||||
|
||||
void onEmitCode(EmitArgs&) SK_OVERRIDE;
|
||||
void onEmitCode(EmitArgs&, GrGPArgs*) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&,
|
||||
@ -560,7 +560,7 @@ GLDashingCircleEffect::GLDashingCircleEffect(const GrGeometryProcessor&,
|
||||
fPrevIntervalLength = SK_ScalarMax;
|
||||
}
|
||||
|
||||
void GLDashingCircleEffect::onEmitCode(EmitArgs& args) {
|
||||
void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const DashingCircleEffect& dce = args.fGP.cast<DashingCircleEffect>();
|
||||
const DashingCircleBatchTracker local = args.fBT.cast<DashingCircleBatchTracker>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
@ -587,11 +587,10 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args) {
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
dce.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, dce.inPosition()->fName, dce.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), dce.inPosition()->fName, dce.localMatrix(),
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, dce.inPosition()->fName, dce.localMatrix(),
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
// transforms all points so that we can compare them to our test circle
|
||||
@ -637,14 +636,17 @@ void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
}
|
||||
|
||||
void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
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);
|
||||
const DashingCircleEffect& dce = gp.cast<DashingCircleEffect>();
|
||||
uint32_t key = 0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 1;
|
||||
key |= dce.getEdgeType() << 8;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -822,7 +824,7 @@ class GLDashingLineEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&);
|
||||
|
||||
void onEmitCode(EmitArgs&) SK_OVERRIDE;
|
||||
void onEmitCode(EmitArgs&, GrGPArgs*) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor&,
|
||||
const GrBatchTracker&,
|
||||
@ -850,7 +852,7 @@ GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&,
|
||||
fPrevIntervalLength = SK_ScalarMax;
|
||||
}
|
||||
|
||||
void GLDashingLineEffect::onEmitCode(EmitArgs& args) {
|
||||
void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const DashingLineEffect& de = args.fGP.cast<DashingLineEffect>();
|
||||
const DashingLineBatchTracker& local = args.fBT.cast<DashingLineBatchTracker>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
@ -885,11 +887,10 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args) {
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
de.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, de.inPosition()->fName, de.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), de.inPosition()->fName, de.localMatrix(),
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, de.inPosition()->fName, de.localMatrix(),
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
// transforms all points so that we can compare them to our test rect
|
||||
@ -942,14 +943,17 @@ void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
}
|
||||
|
||||
void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor,
|
||||
void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
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 DashingLineEffect& de = gp.cast<DashingLineEffect>();
|
||||
uint32_t key = 0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 1;
|
||||
key |= de.getEdgeType() << 8;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
#endif
|
||||
{}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{
|
||||
const GrDistanceFieldTextureEffect& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldTextureEffect>();
|
||||
const DistanceFieldBatchTracker& local = args.fBT.cast<DistanceFieldBatchTracker>();
|
||||
@ -61,11 +61,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
dfTexEffect.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), dfTexEffect.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
const char* textureSizeUniName = NULL;
|
||||
@ -166,16 +166,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor& processor,
|
||||
static inline void GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrDistanceFieldTextureEffect& dfTexEffect =
|
||||
processor.cast<GrDistanceFieldTextureEffect>();
|
||||
const GrDistanceFieldTextureEffect& dfTexEffect = gp.cast<GrDistanceFieldTextureEffect>();
|
||||
const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTracker>();
|
||||
uint32_t key = dfTexEffect.getFlags();
|
||||
key |= local.fInputColorType << 16;
|
||||
key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ public:
|
||||
const GrBatchTracker&)
|
||||
: fColor(GrColor_ILLEGAL), fTextureSize(SkISize::Make(-1, -1)) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{
|
||||
const GrDistanceFieldNoGammaTextureEffect& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldNoGammaTextureEffect>();
|
||||
|
||||
@ -353,11 +353,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
dfTexEffect.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), dfTexEffect.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
const char* textureSizeUniName = NULL;
|
||||
@ -434,17 +434,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor& proc,
|
||||
static inline void GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrDistanceFieldNoGammaTextureEffect& dfTexEffect =
|
||||
proc.cast<GrDistanceFieldNoGammaTextureEffect>();
|
||||
gp.cast<GrDistanceFieldNoGammaTextureEffect>();
|
||||
|
||||
const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoGammaBatchTracker>();
|
||||
uint32_t key = dfTexEffect.getFlags();
|
||||
key |= local.fInputColorType << 16;
|
||||
key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
@ -568,7 +569,7 @@ public:
|
||||
, fTextureSize(SkISize::Make(-1,-1))
|
||||
, fTextColor(GrColor_ILLEGAL) {}
|
||||
|
||||
void onEmitCode(EmitArgs& args) SK_OVERRIDE {
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{
|
||||
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldLCDTextureEffect>();
|
||||
const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldLCDBatchTracker>();
|
||||
@ -591,11 +592,11 @@ public:
|
||||
this->addUniformViewMatrix(pb);
|
||||
|
||||
// Setup position
|
||||
vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
|
||||
dfTexEffect.inPosition()->fName);
|
||||
SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(), this->uViewM());
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, this->position(), dfTexEffect.inPosition()->fName,
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
const char* textureSizeUniName = NULL;
|
||||
@ -749,17 +750,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrGeometryProcessor& processor,
|
||||
static inline void GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
|
||||
processor.cast<GrDistanceFieldLCDTextureEffect>();
|
||||
gp.cast<GrDistanceFieldLCDTextureEffect>();
|
||||
|
||||
const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatchTracker>();
|
||||
uint32_t key = dfTexEffect.getFlags();
|
||||
key |= local.fInputColorType << 16;
|
||||
key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
|
||||
key |= ComputePosKey(gp.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,7 @@ private:
|
||||
};
|
||||
|
||||
class GrGLPathRendering;
|
||||
class GrGLVertexBuilder;
|
||||
/**
|
||||
* If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, then it must inherit
|
||||
* from this class. Since paths don't have vertices, this class is only meant to be used internally
|
||||
@ -143,26 +144,47 @@ public:
|
||||
const SkTArray<const GrCoordTransform*, true>& transforms);
|
||||
|
||||
protected:
|
||||
const char* position() const { return "pos3"; }
|
||||
|
||||
// Many GrGeometryProcessors do not need explicit local coords
|
||||
void emitTransforms(GrGLGPBuilder* gp,
|
||||
const char* position,
|
||||
const GrShaderVar& posVar,
|
||||
const SkMatrix& localMatrix,
|
||||
const TransformsIn& tin,
|
||||
TransformsOut* tout) {
|
||||
this->emitTransforms(gp, position, position, localMatrix, tin, tout);
|
||||
this->emitTransforms(gp, posVar, posVar.c_str(), localMatrix, tin, tout);
|
||||
}
|
||||
|
||||
void emitTransforms(GrGLGPBuilder*,
|
||||
const char* position,
|
||||
const GrShaderVar& posVar,
|
||||
const char* localCoords,
|
||||
const SkMatrix& localMatrix,
|
||||
const TransformsIn&,
|
||||
TransformsOut*);
|
||||
|
||||
struct GrGPArgs {
|
||||
// The variable used by a GP to store its position. It can be
|
||||
// either a vec2 or a vec3 depending on the presence of perspective.
|
||||
GrShaderVar fPositionVar;
|
||||
};
|
||||
|
||||
// Create the correct type of position variable given the CTM
|
||||
static void SetupPosition(GrGLVertexBuilder* vsBuilder,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
const char* matName);
|
||||
|
||||
static uint32_t ComputePosKey(const SkMatrix& mat) {
|
||||
if (mat.isIdentity()) {
|
||||
return 0x0;
|
||||
} else if (!mat.hasPerspective()) {
|
||||
return 0x01;
|
||||
} else {
|
||||
return 0x02;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void onEmitCode(EmitArgs&) = 0;
|
||||
virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
|
||||
|
||||
typedef GrGLPrimitiveProcessor INHERITED;
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
INHERITED::set(type, typeModifier, name, precision);
|
||||
INHERITED::set(type, name, typeModifier, precision);
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
@ -104,7 +104,7 @@ public:
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
INHERITED::set(type, typeModifier, name, precision);
|
||||
INHERITED::set(type, name, typeModifier, precision);
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
@ -121,7 +121,7 @@ public:
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
INHERITED::set(type, typeModifier, name, count, precision);
|
||||
INHERITED::set(type, name, typeModifier, precision, count);
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
@ -138,7 +138,7 @@ public:
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
INHERITED::set(type, typeModifier, name, count, precision);
|
||||
INHERITED::set(type, name, typeModifier, precision, count);
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void GrGLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) {
|
||||
return;
|
||||
}
|
||||
|
||||
void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const char* pos3) {
|
||||
void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posVar) {
|
||||
SkASSERT(!fRtAdjustName);
|
||||
|
||||
// setup RT Uniform
|
||||
@ -44,9 +44,19 @@ void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const char* pos3) {
|
||||
fProgramBuilder->rtAdjustment(),
|
||||
&fRtAdjustName);
|
||||
|
||||
// Transform from Skia's device coords to GL's normalized device coords.
|
||||
this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
|
||||
pos3, fRtAdjustName, pos3, fRtAdjustName, pos3);
|
||||
// Transform from Skia's device coords to GL's normalized device coords. Note that
|
||||
// because we want to "nudge" the device space positions we are converting to
|
||||
// non-homogeneous NDC.
|
||||
if (kVec3f_GrSLType == posVar.getType()) {
|
||||
this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy)/%s.z, dot(%s.yz, %s.zw)/%s.z, 0, 1);",
|
||||
posVar.c_str(), fRtAdjustName, posVar.c_str(),
|
||||
posVar.c_str(), fRtAdjustName, posVar.c_str());
|
||||
} else {
|
||||
SkASSERT(kVec2f_GrSLType == posVar.getType());
|
||||
this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
|
||||
posVar.c_str(), fRtAdjustName, fRtAdjustName,
|
||||
posVar.c_str(), fRtAdjustName, fRtAdjustName);
|
||||
}
|
||||
|
||||
// We could have the GrGeometryProcessor do this, but its just easier to have it performed here.
|
||||
// If we ever need to set variable pointsize, then we can reinvestigate
|
||||
|
@ -16,7 +16,7 @@ class GrGLVertexBuilder : public GrGLShaderBuilder {
|
||||
public:
|
||||
GrGLVertexBuilder(GrGLProgramBuilder* program);
|
||||
|
||||
void transformToNormalizedDeviceSpace(const char* pos3);
|
||||
void transformToNormalizedDeviceSpace(const GrShaderVar& posVar);
|
||||
void emitAttributes(const GrGeometryProcessor& gp);
|
||||
|
||||
void addAttribute(const GrGeometryProcessor::Attribute* attr) {
|
||||
|
Loading…
Reference in New Issue
Block a user