OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrGLProgram_DEFINED | 9 #ifndef GrGLProgram_DEFINED |
10 #define GrGLProgram_DEFINED | 10 #define GrGLProgram_DEFINED |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 * The base class always has a vertex shader, only the NVPR variants may omi t a vertex shader | 58 * The base class always has a vertex shader, only the NVPR variants may omi t a vertex shader |
59 */ | 59 */ |
60 virtual bool hasVertexShader() const { return true; } | 60 virtual bool hasVertexShader() const { return true; } |
61 | 61 |
62 /** | 62 /** |
63 * The GrDrawState's view matrix along with the aspects of the render target determine the | 63 * The GrDrawState's view matrix along with the aspects of the render target determine the |
64 * matrix sent to GL. The size of the render target affects the GL matrix be cause we must | 64 * matrix sent to GL. The size of the render target affects the GL matrix be cause we must |
65 * convert from Skia device coords to GL's normalized coords. Also the origi n of the render | 65 * convert from Skia device coords to GL's normalized coords. Also the origi n of the render |
66 * target may require us to perform a mirror-flip. | 66 * target may require us to perform a mirror-flip. |
67 */ | 67 */ |
68 struct MatrixState { | 68 struct MatrixState { |
bsalomon
2014/12/30 13:19:39
Change to RenderTargetState? Also, the above comme
| |
69 SkMatrix fViewMatrix; | |
70 SkISize fRenderTargetSize; | 69 SkISize fRenderTargetSize; |
71 GrSurfaceOrigin fRenderTargetOrigin; | 70 GrSurfaceOrigin fRenderTargetOrigin; |
72 | 71 |
73 MatrixState() { this->invalidate(); } | 72 MatrixState() { this->invalidate(); } |
74 void invalidate() { | 73 void invalidate() { |
75 fViewMatrix = SkMatrix::InvalidMatrix(); | |
76 fRenderTargetSize.fWidth = -1; | 74 fRenderTargetSize.fWidth = -1; |
77 fRenderTargetSize.fHeight = -1; | 75 fRenderTargetSize.fHeight = -1; |
78 fRenderTargetOrigin = (GrSurfaceOrigin) -1; | 76 fRenderTargetOrigin = (GrSurfaceOrigin) -1; |
79 } | 77 } |
80 | 78 |
81 /** | 79 /** |
82 * Gets a matrix that goes from local coords to Skia's device coordinate s. | |
83 */ | |
84 template<int Size> void getGLMatrix(GrGLfloat* destMatrix) { | |
85 GrGLGetMatrix<Size>(destMatrix, fViewMatrix); | |
86 } | |
87 | |
88 /** | |
89 * Gets a matrix that goes from local coordinates to GL normalized devic e coords. | |
90 */ | |
91 template<int Size> void getRTAdjustedGLMatrix(GrGLfloat* destMatrix) { | |
92 SkMatrix combined; | |
93 if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) { | |
94 combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1, | |
95 0, -SkIntToScalar(2) / fRenderTargetSize.fHeight , SK_Scalar1, | |
96 0, 0, 1); | |
97 } else { | |
98 combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1, | |
99 0, SkIntToScalar(2) / fRenderTargetSize.fHeight, -SK_Scalar1, | |
100 0, 0, 1); | |
101 } | |
102 combined.preConcat(fViewMatrix); | |
103 GrGLGetMatrix<Size>(destMatrix, combined); | |
104 } | |
105 | |
106 /** | |
107 * Gets a vec4 that adjusts the position from Skia device coords to GL's normalized device | 80 * Gets a vec4 that adjusts the position from Skia device coords to GL's normalized device |
108 * coords. Assuming the transformed position, pos, is a homogeneous vec3 , the vec, v, is | 81 * coords. Assuming the transformed position, pos, is a homogeneous vec3 , the vec, v, is |
109 * applied as such: | 82 * applied as such: |
110 * pos.x = dot(v.xy, pos.xz) | 83 * pos.x = dot(v.xy, pos.xz) |
111 * pos.y = dot(v.zq, pos.yz) | 84 * pos.y = dot(v.zq, pos.yz) |
112 */ | 85 */ |
113 void getRTAdjustmentVec(GrGLfloat* destVec) { | 86 void getRTAdjustmentVec(GrGLfloat* destVec) { |
114 destVec[0] = 2.f / fRenderTargetSize.fWidth; | 87 destVec[0] = 2.f / fRenderTargetSize.fWidth; |
115 destVec[1] = -1.f; | 88 destVec[1] = -1.f; |
116 if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) { | 89 if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 GrGLInstalledFragProc*) SK_OVERRIDE; | 236 GrGLInstalledFragProc*) SK_OVERRIDE; |
264 | 237 |
265 int fTexCoordSetCnt; | 238 int fTexCoordSetCnt; |
266 | 239 |
267 friend class GrGLLegacyNvprProgramBuilder; | 240 friend class GrGLLegacyNvprProgramBuilder; |
268 | 241 |
269 typedef GrGLNvprProgramBase INHERITED; | 242 typedef GrGLNvprProgramBase INHERITED; |
270 }; | 243 }; |
271 | 244 |
272 #endif | 245 #endif |
OLD | NEW |