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

Unified Diff: src/gpu/gl/GrGLProgram.cpp

Issue 820523002: initial changes to add local matrix to primitive processor (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup-ccm-above-context
Patch Set: cleanup 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/gl/GrGLProgram.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgram.cpp
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index f8770b3664827623473a37fb0c3a02128c29bfc2..9bf91fc59527b377625f9894c579813fb64ccfa7 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -27,15 +27,27 @@
/**
* Retrieves the final matrix that a transform needs to apply to its source coords.
*/
-static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage, int transformIdx) {
+static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage,
+ int transformIdx,
+ const SkMatrix& localMatrix) {
const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransform(transformIdx);
SkMatrix combined;
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
// If we have explicit local coords or are in device coords then we shouldn't need a coord
// change.
- const SkMatrix& ccm = stage.getCoordChangeMatrix();
- combined.setConcat(coordTransform.getMatrix(), ccm);
+ // TODO shortly we will get rid of coord change matrices entirely, and the PrimProc will
+ // always have a local matrix, often Identity, which can be used to transform coord
+ // transforms. Until we actually do this, we need some way for a PrimProc to say 'use my
+ // matrix' instead of the coord change mechanism. Temporarily, we have overloaded
+ // The identity matrix to be this value, ie if a primproc has an identity matrix for a
+ // local matrix then use the coord change matrix, otherwise use the matrix on the primproc
+ if (localMatrix.isIdentity()) {
+ const SkMatrix& ccm = stage.getCoordChangeMatrix();
+ combined.setConcat(coordTransform.getMatrix(), ccm);
+ } else {
+ combined.setConcat(coordTransform.getMatrix(), localMatrix);
+ }
} else {
combined = coordTransform.getMatrix();
}
@@ -180,18 +192,20 @@ void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
const GrPendingFragmentStage& stage = optState.getFragmentStage(e);
const GrProcessor& processor = *stage.getProcessor();
fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, processor);
- this->setTransformData(stage, fFragmentProcessors->fProcs[e]);
+ const SkMatrix& localMatrix = optState.getPrimitiveProcessor()->localMatrix();
+ this->setTransformData(stage, localMatrix, fFragmentProcessors->fProcs[e]);
this->bindTextures(fFragmentProcessors->fProcs[e], processor);
}
}
void GrGLProgram::setTransformData(const GrPendingFragmentStage& processor,
+ const SkMatrix& localMatrix,
GrGLInstalledFragProc* ip) {
SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransforms;
int numTransforms = transforms.count();
SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
- const SkMatrix& matrix = get_transform_matrix(processor, t);
+ const SkMatrix& matrix = get_transform_matrix(processor, t, localMatrix);
if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUniformHandle(), matrix);
transforms[t].fCurrentValue = matrix;
@@ -291,13 +305,14 @@ void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) {
}
void GrGLNvprProgram::setTransformData(const GrPendingFragmentStage& proc,
+ const SkMatrix& localMatrix,
GrGLInstalledFragProc* ip) {
SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransforms;
int numTransforms = transforms.count();
SkASSERT(numTransforms == proc.getProcessor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
- const SkMatrix& transform = get_transform_matrix(proc, t);
+ const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix);
if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
continue;
}
@@ -335,12 +350,13 @@ void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) {
void
GrGLLegacyNvprProgram::setTransformData(const GrPendingFragmentStage& proc,
+ const SkMatrix& localMatrix,
GrGLInstalledFragProc* ip) {
// We've hidden the texcoord index in the first entry of the transforms array for each effect
int texCoordIndex = ip->fTransforms[0].fHandle.handle();
int numTransforms = proc.getProcessor()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
- const SkMatrix& transform = get_transform_matrix(proc, t);
+ const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix);
GrGLPathRendering::PathTexGenComponents components =
GrGLPathRendering::kST_PathTexGenComponents;
if (proc.isPerspectiveCoordTransform(t)) {
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698