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

Unified Diff: src/gpu/gl/GrGLGeometryProcessor.h

Issue 1131513005: remove localmatrix from GrGeometryProcessor base class (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup4
Patch Set: tweaks Created 5 years, 7 months 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/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLGeometryProcessor.h
diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h
index 49ccb8b15cdbdd0df7a4e934778c147a85bd5fb0..dfb2b90ab8332b834f9ab9bbd26540811757ce36 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.h
+++ b/src/gpu/gl/GrGLGeometryProcessor.h
@@ -22,19 +22,32 @@ public:
/* Any general emit code goes in the base class emitCode. Subclasses override onEmitCode */
void emitCode(EmitArgs&) override;
- void setTransformData(const GrPrimitiveProcessor&,
- const GrGLProgramDataManager&,
- int index,
- const SkTArray<const GrCoordTransform*, true>& transforms);
+ // By default we use the identity matrix
+ virtual void setTransformData(const GrPrimitiveProcessor&,
+ const GrGLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) {
+ this->setTransformDataMatrix(SkMatrix::I(), pdman, index, transforms);
+ }
+
+ // A helper which subclasses can use if needed
+ template <class GeometryProcessor>
+ void setTransformDataHelper(const GrPrimitiveProcessor& primProc,
+ const GrGLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) {
+ const GeometryProcessor& gp = primProc.cast<GeometryProcessor>();
+ this->setTransformDataMatrix(gp.localMatrix(), pdman, index, transforms);
+ }
protected:
- // Many GrGeometryProcessors do not need explicit local coords
+ // A helper for subclasses which don't have an explicit local matrix
void emitTransforms(GrGLGPBuilder* gp,
const GrShaderVar& posVar,
- const SkMatrix& localMatrix,
+ const char* localCoords,
const TransformsIn& tin,
TransformsOut* tout) {
- this->emitTransforms(gp, posVar, posVar.c_str(), localMatrix, tin, tout);
+ this->emitTransforms(gp, posVar, localCoords, SkMatrix::I(), tin, tout);
}
void emitTransforms(GrGLGPBuilder*,
@@ -67,6 +80,22 @@ protected:
}
private:
+ void setTransformDataMatrix(const SkMatrix& localMatrix,
+ const GrGLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) {
+ SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index];
+ int numTransforms = transforms.count();
+ for (int t = 0; t < numTransforms; ++t) {
+ SkASSERT(procTransforms[t].fHandle.isValid());
+ const SkMatrix& transform = GetTransformMatrix(localMatrix, *transforms[t]);
+ if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) {
+ pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle(), transform);
+ procTransforms[t].fCurrentValue = transform;
+ }
+ }
+ }
+
virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
typedef GrGLPrimitiveProcessor INHERITED;
« no previous file with comments | « src/gpu/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698