Fixes performance for texture domain uniform upload
Code review: http://codereview.appspot.com/4536073/
bug: http://code.google.com/p/skia/issues/detail?id=275
git-svn-id: http://skia.googlecode.com/svn/trunk@1406 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGpuGLShaders.cpp b/gpu/src/GrGpuGLShaders.cpp
index bf68def..6d4b4b1 100644
--- a/gpu/src/GrGpuGLShaders.cpp
+++ b/gpu/src/GrGpuGLShaders.cpp
@@ -345,28 +345,35 @@
const GrRect &texDom =
fCurrDrawState.fSamplerStates[s].getTextureDomain();
- float values[4] = {
- GrScalarToFloat(texDom.left()),
- GrScalarToFloat(texDom.top()),
- GrScalarToFloat(texDom.right()),
- GrScalarToFloat(texDom.bottom())
- };
+ if (((1 << s) & fDirtyFlags.fTextureChangedMask) ||
+ fProgramData->fTextureDomain[s] != texDom)
- GrGLTexture* texture = (GrGLTexture*) fCurrDrawState.fTextures[s];
- GrGLTexture::Orientation orientation = texture->orientation();
+ {
+ fProgramData->fTextureDomain[s] = texDom;
- // vertical flip if necessary
- if (GrGLTexture::kBottomUp_Orientation == orientation) {
- values[1] = 1.0f - values[1];
- values[3] = 1.0f - values[3];
+ float values[4] = {
+ GrScalarToFloat(texDom.left()),
+ GrScalarToFloat(texDom.top()),
+ GrScalarToFloat(texDom.right()),
+ GrScalarToFloat(texDom.bottom())
+ };
+
+ GrGLTexture* texture = (GrGLTexture*) fCurrDrawState.fTextures[s];
+ GrGLTexture::Orientation orientation = texture->orientation();
+
+ // vertical flip if necessary
+ if (GrGLTexture::kBottomUp_Orientation == orientation) {
+ values[1] = 1.0f - values[1];
+ values[3] = 1.0f - values[3];
+ }
+
+ values[0] *= SkScalarToFloat(texture->contentScaleX());
+ values[2] *= SkScalarToFloat(texture->contentScaleX());
+ values[1] *= SkScalarToFloat(texture->contentScaleY());
+ values[3] *= SkScalarToFloat(texture->contentScaleY());
+
+ GR_GL(Uniform4fv(uni, 1, values));
}
-
- values[0] *= SkScalarToFloat(texture->contentScaleX());
- values[2] *= SkScalarToFloat(texture->contentScaleX());
- values[1] *= SkScalarToFloat(texture->contentScaleY());
- values[3] *= SkScalarToFloat(texture->contentScaleY());
-
- GR_GL(Uniform4fv(uni, 1, values));
}
}