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

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

Issue 299943002: separate view matrix from rt adjustment (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase on tot: Created 6 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 | « no previous file | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgram.h
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index 0a2a242fca3a88cf64572a96a8f42773a5f102e8..b6d9a8e0859f798450800c7105baed1a683cd757 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -103,20 +103,50 @@ public:
fRenderTargetSize.fHeight = -1;
fRenderTargetOrigin = (GrSurfaceOrigin) -1;
}
+
+ /**
+ * Gets a matrix that goes from local coords to Skia's device coordinates.
+ */
template<int Size> void getGLMatrix(GrGLfloat* destMatrix) {
+ GrGLGetMatrix<Size>(destMatrix, fViewMatrix);
+ }
+
+ /**
+ * Gets a matrix that goes from local coordinates to GL normalized device coords.
+ */
+ template<int Size> void getRTAdjustedGLMatrix(GrGLfloat* destMatrix) {
SkMatrix combined;
if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) {
combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1,
0, -SkIntToScalar(2) / fRenderTargetSize.fHeight, SK_Scalar1,
- 0, 0, SkMatrix::I()[8]);
+ 0, 0, 1);
} else {
combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1,
0, SkIntToScalar(2) / fRenderTargetSize.fHeight, -SK_Scalar1,
- 0, 0, SkMatrix::I()[8]);
+ 0, 0, 1);
}
combined.preConcat(fViewMatrix);
GrGLGetMatrix<Size>(destMatrix, combined);
}
+
+ /**
+ * Gets a vec4 that adjusts the position from Skia device coords to GL's normalized device
+ * coords. Assuming the transformed position, pos, is a homogeneous vec3, the vec, v, is
+ * applied as such:
+ * pos.x = dot(v.xy, pos.xz)
+ * pos.y = dot(v.zq, pos.yz)
+ */
+ void getRTAdjustmentVec(GrGLfloat* destVec) {
+ destVec[0] = 2.f / fRenderTargetSize.fWidth;
+ destVec[1] = -1.f;
+ if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) {
+ destVec[2] = -2.f / fRenderTargetSize.fHeight;
+ destVec[3] = 1.f;
+ } else {
+ destVec[2] = 2.f / fRenderTargetSize.fHeight;
+ destVec[3] = -1.f;
+ }
+ }
};
/**
@@ -137,6 +167,7 @@ private:
// handles for uniforms (aside from per-effect samplers)
struct UniformHandles {
UniformHandle fViewMatrixUni;
+ UniformHandle fRTAdjustmentUni;
UniformHandle fColorUni;
UniformHandle fCoverageUni;
« no previous file with comments | « no previous file | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698