Index: cc/output/shader.cc |
diff --git a/cc/output/shader.cc b/cc/output/shader.cc |
index 2226192d9af9a6840e64be959452c9df71154193..be0c3c02a20eb42ab24de70f11da8abce6f8dd6b 100644 |
--- a/cc/output/shader.cc |
+++ b/cc/output/shader.cc |
@@ -81,17 +81,27 @@ static std::string SetVertexTexCoordPrecision(const char* shader_string) { |
TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context, |
int highp_threshold_min, |
int x, int y) { |
- // Initialize range and precision with minimum spec values for when |
- // GetShaderPrecisionFormat is a test stub. |
- // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat |
- // everywhere. |
- GLint range[2] = { 14, 14 }; |
- GLint precision = 10; |
- GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER, |
- GL_MEDIUM_FLOAT, |
- range, &precision)); |
- int highp_threshold = std::max(1 << precision, highp_threshold_min); |
- if (x > highp_threshold || y > highp_threshold) |
+ static int s_highp_threshold = 0; |
+ static WebGraphicsContext3D* s_cached_context = NULL; |
+ |
+ if (!s_cached_context) { |
+ // Initialize range and precision with minimum spec values for when |
+ // GetShaderPrecisionFormat is a test stub. |
+ // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat |
+ // everywhere. |
+ static GLint range[2] = { 14, 14 }; |
+ static GLint precision = 10; |
+ GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER, |
+ GL_MEDIUM_FLOAT, |
+ range, &precision)); |
+ s_highp_threshold = std::max(1 << precision, highp_threshold_min); |
+ s_cached_context = context; |
+ } |
+ |
+ // If we are using multiple contexts, we need smarter caching logic. |
+ DCHECK_EQ(s_cached_context, context); |
vangelis
2013/05/03 19:13:27
It's not uncommon for one renderer to have multipl
|
+ |
+ if (x > s_highp_threshold || y > s_highp_threshold) |
return TexCoordPrecisionHigh; |
return TexCoordPrecisionMedium; |
} |