Index: content/common/gpu/client/gl_helper_scaling.cc |
diff --git a/content/common/gpu/client/gl_helper_scaling.cc b/content/common/gpu/client/gl_helper_scaling.cc |
index b248d9d92048e0ebbde1ef2490405963a0b9c18a..0216073b23d8888e2b3b0fa7b5ceaea6b73d7143 100644 |
--- a/content/common/gpu/client/gl_helper_scaling.cc |
+++ b/content/common/gpu/client/gl_helper_scaling.cc |
@@ -15,6 +15,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/time/time.h" |
#include "base/trace_event/trace_event.h" |
+#include "gpu/command_buffer/client/context_support.h" |
#include "gpu/command_buffer/client/gles2_interface.h" |
#include "third_party/skia/include/core/SkRegion.h" |
#include "ui/gfx/geometry/rect.h" |
@@ -24,8 +25,13 @@ using gpu::gles2::GLES2Interface; |
namespace content { |
-GLHelperScaling::GLHelperScaling(GLES2Interface* gl, GLHelper* helper) |
- : gl_(gl), helper_(helper), vertex_attributes_buffer_(gl_) { |
+GLHelperScaling::GLHelperScaling(GLES2Interface* gl, |
+ gpu::ContextSupport* context_support, |
+ GLHelper* helper) |
+ : gl_(gl), |
+ context_support_(context_support), |
+ helper_(helper), |
+ vertex_attributes_buffer_(gl_) { |
InitBuffer(); |
} |
@@ -50,7 +56,8 @@ class ShaderProgram : public base::RefCounted<ShaderProgram> { |
color_weights_location_(-1) {} |
// Compile shader program. |
- void Setup(const GLchar* vertex_shader_text, |
+ void Setup(gpu::ContextSupport* context_support, |
+ const GLchar* vertex_shader_text, |
const GLchar* fragment_shader_text); |
// UseProgram must be called with GL_TEXTURE_2D bound to the |
@@ -828,12 +835,14 @@ scoped_refptr<ShaderProgram> GLHelperScaling::GetShaderProgram(ShaderType type, |
shared_variables + "void main() {\n" + fragment_program + |
"}\n"; |
- cache_entry->Setup(vertex_program.c_str(), fragment_program.c_str()); |
+ cache_entry->Setup(context_support_, vertex_program.c_str(), |
+ fragment_program.c_str()); |
} |
return cache_entry; |
} |
-void ShaderProgram::Setup(const GLchar* vertex_shader_text, |
+void ShaderProgram::Setup(gpu::ContextSupport* context_support, |
+ const GLchar* vertex_shader_text, |
const GLchar* fragment_shader_text) { |
// Shaders to map the source texture to |dst_texture_|. |
GLuint vertex_shader = |
@@ -870,14 +879,7 @@ void ShaderProgram::Setup(const GLchar* vertex_shader_text, |
// The only reason fetching these attribute locations should fail is |
// if the context was spontaneously lost (i.e., because the GPU |
// process crashed, perhaps deliberately for testing). |
- // Unfortunately, the only way to reliably detect context loss from |
- // GLES2Interface would be to repeatedly call GetError(), and this |
- // seems fragile. Most of the APIs in GLHelper should be updated to |
- // be able to return an error. Fortunately, many users of this code |
- // check for context loss at a higher level. |
- if (!Initialized()) { |
- LOG(ERROR) << "ShaderProgram::Setup: initialization failed (context lost?)"; |
- } |
+ DCHECK_IMPLIES(!Initialized(), context_support->IsContextLost()); |
Ken Russell (switch to Gerrit)
2015/05/29 22:42:44
Nice.
|
return; |
} |