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

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

Issue 25846002: Use vertexless shaders when NVpr is available (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix mac build Created 7 years, 2 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/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL.cpp
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index d1a716793f7e1bcde510f1898a5b724b4f10258c..576a134d0c05f8348302a2aa45d194dcecb55449 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -124,6 +124,7 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
fCaps.reset(SkRef(ctx.info().caps()));
fHWBoundTextures.reset(ctx.info().caps()->maxFragmentTextureUnits());
+ fHWTexGenSettings.reset(ctx.info().caps()->maxFixedFunctionTextureCoords());
fillInConfigRenderableTable();
@@ -377,7 +378,13 @@ void GrGpuGL::onResetContext(uint32_t resetBits) {
GL_CALL(Disable(GR_GL_TEXTURE_GEN_T));
GL_CALL(Disable(GR_GL_TEXTURE_GEN_Q));
GL_CALL(Disable(GR_GL_TEXTURE_GEN_R));
+ if (this->caps()->pathStencilingSupport()) {
+ GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL));
+ }
+ fHWTexGenSettings[i].fMode = GR_GL_NONE;
+ fHWTexGenSettings[i].fNumComponents = 0;
}
+ fHWActiveTexGenSets = 0;
}
// we assume these values
@@ -2112,6 +2119,124 @@ void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
texture->setCachedTexParams(newTexParams, this->getResetTimestamp());
}
+void GrGpuGL::setProjectionMatrix(const SkMatrix& matrix,
+ const SkISize& renderTargetSize,
+ GrSurfaceOrigin renderTargetOrigin) {
+
+ SkASSERT(this->glCaps().fixedFunctionSupport());
+
+ if (renderTargetOrigin == fHWProjectionMatrixState.fRenderTargetOrigin &&
+ renderTargetSize == fHWProjectionMatrixState.fRenderTargetSize &&
+ matrix.cheapEqualTo(fHWProjectionMatrixState.fViewMatrix)) {
+ return;
+ }
+
+ fHWProjectionMatrixState.fViewMatrix = matrix;
+ fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize;
+ fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin;
+
+ GrGLfloat glMatrix[4 * 4];
+ fHWProjectionMatrixState.getGLMatrix<4>(glMatrix);
+ GL_CALL(MatrixMode(GR_GL_PROJECTION));
+ GL_CALL(LoadMatrixf(glMatrix));
+}
+
+void GrGpuGL::enableTexGen(int unitIdx,
+ TexGenComponents components,
+ const GrGLfloat* coefficients) {
+
+ SkASSERT(this->glCaps().fixedFunctionSupport());
+ SkASSERT(this->caps()->pathStencilingSupport());
+ SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenComponents);
+
+ if (GR_GL_OBJECT_LINEAR == fHWTexGenSettings[unitIdx].fMode &&
+ components == fHWTexGenSettings[unitIdx].fNumComponents &&
+ !memcmp(coefficients, fHWTexGenSettings[unitIdx].fCoefficients,
+ 3 * components * sizeof(GrGLfloat))) {
+ return;
+ }
+
+ this->setTextureUnit(unitIdx);
+
+ if (GR_GL_OBJECT_LINEAR != fHWTexGenSettings[unitIdx].fMode) {
+ for (int i = 0; i < 4; i++) {
+ GL_CALL(TexGeni(GR_GL_S + i, GR_GL_TEXTURE_GEN_MODE, GR_GL_OBJECT_LINEAR));
+ }
+ fHWTexGenSettings[unitIdx].fMode = GR_GL_OBJECT_LINEAR;
+ }
+
+ for (int i = fHWTexGenSettings[unitIdx].fNumComponents; i < components; i++) {
+ GL_CALL(Enable(GR_GL_TEXTURE_GEN_S + i));
+ }
+ for (int i = components; i < fHWTexGenSettings[unitIdx].fNumComponents; i++) {
+ GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + i));
+ }
+ fHWTexGenSettings[unitIdx].fNumComponents = components;
+
+ for (int i = 0; i < components; i++) {
+ GrGLfloat plane[] = {coefficients[0 + 3 * i],
+ coefficients[1 + 3 * i],
+ 0,
+ coefficients[2 + 3 * i]};
+ GL_CALL(TexGenfv(GR_GL_S + i, GR_GL_OBJECT_PLANE, plane));
+ }
+
+ GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx,
+ GR_GL_OBJECT_LINEAR,
+ components,
+ coefficients));
+
+ memcpy(fHWTexGenSettings[unitIdx].fCoefficients, coefficients,
+ 3 * components * sizeof(GrGLfloat));
+
+ fHWActiveTexGenSets = SkTMax(fHWActiveTexGenSets, unitIdx);
+}
+
+void GrGpuGL::enableTexGen(int unitIdx, TexGenComponents components, const SkMatrix& matrix) {
+
+ GrGLfloat coefficients[3 * 3];
+ SkASSERT(this->glCaps().fixedFunctionSupport());
+ SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenComponents);
+
+ coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
+ coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]);
+ coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]);
+
+ if (components >= kST_TexGenComponents) {
+ coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]);
+ coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]);
+ coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]);
+ }
+
+ if (components >= kSTR_TexGenComponents) {
+ coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]);
+ coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]);
+ coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]);
+ }
+
+ enableTexGen(unitIdx, components, coefficients);
+}
+
+void GrGpuGL::disableUnusedTexGen(int numUsedTexCoordSets) {
+
+ SkASSERT(this->glCaps().fixedFunctionSupport());
+
+ for (int i = numUsedTexCoordSets; i < fHWActiveTexGenSets; i++) {
+ if (0 == fHWTexGenSettings[i].fNumComponents) {
+ continue;
+ }
+
+ this->setTextureUnit(i);
+ for (int j = 0; j < fHWTexGenSettings[i].fNumComponents; j++) {
+ GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + j));
+ }
+ GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL));
+ fHWTexGenSettings[i].fNumComponents = 0;
+ }
+
+ fHWActiveTexGenSets = SkTMin(fHWActiveTexGenSets, numUsedTexCoordSets);
+}
+
void GrGpuGL::flushMiscFixedFunctionState() {
const GrDrawState& drawState = this->getDrawState();
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698