Chromium Code Reviews| Index: remoting/client/gl_canvas.cc |
| diff --git a/remoting/client/gl_canvas.cc b/remoting/client/gl_canvas.cc |
| index 0a49f13ec26b8f404700d8aa31a9cbf5605f2fed..65e263e1789df7f54b217ac4a411b81f88505f33 100644 |
| --- a/remoting/client/gl_canvas.cc |
| +++ b/remoting/client/gl_canvas.cc |
| @@ -65,7 +65,17 @@ const char kDrawTexFrag[] = |
| namespace remoting { |
| +GlCanvas::GlCanvas() {} |
| + |
| GlCanvas::GlCanvas(int gl_version) : gl_version_(gl_version) { |
| +#ifndef NDEBUG |
| + // Set the background clear color to bright green for debugging purposes. |
| + glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| +#else |
| + // Set the background clear color to black. |
| + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
| +#endif |
|
joedow
2016/12/22 00:29:02
Can you reuse the Clear() method after everything
nicholss
2017/01/09 18:50:23
removing the clear function
|
| + |
| glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
| vertex_shader_ = CompileShader(GL_VERTEX_SHADER, kTexCoordToViewVert); |
| @@ -84,16 +94,19 @@ GlCanvas::GlCanvas(int gl_version) : gl_version_(gl_version) { |
| glEnableVertexAttribArray(tex_cord_location_); |
| glEnable(GL_BLEND); |
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| + gl_constructed_ = true; |
| } |
| GlCanvas::~GlCanvas() { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| - glDisable(GL_BLEND); |
| - glDisableVertexAttribArray(tex_cord_location_); |
| - glDisableVertexAttribArray(position_location_); |
| - glDeleteProgram(program_); |
| - glDeleteShader(vertex_shader_); |
| - glDeleteShader(fragment_shader_); |
| + if (gl_constructed_) { |
|
Yuwei
2016/12/21 23:41:58
If you have a separate GlCanvas interface then I d
joedow
2016/12/22 00:29:02
This feels a bit odd. Is there a way to guarantee
nicholss
2016/12/22 16:21:41
It is odd because this is not dependency injection
joedow
2016/12/22 19:18:09
I don't think DI is required to prevent having tes
Sergey Ulanov
2016/12/22 22:38:45
In this case I don't think we need any of it. It s
nicholss
2017/01/09 18:50:23
I would prefer to not test OpenGL and the renderer
nicholss
2017/01/09 18:50:24
I added an interface and moved to a more dependenc
Yuwei
2017/01/09 20:28:51
The previous tests work based on these preconditio
|
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + glDisable(GL_BLEND); |
| + glDisableVertexAttribArray(tex_cord_location_); |
| + glDisableVertexAttribArray(position_location_); |
| + glDeleteProgram(program_); |
| + glDeleteShader(vertex_shader_); |
| + glDeleteShader(fragment_shader_); |
| + } |
| } |
| void GlCanvas::SetTransformationMatrix(const std::array<float, 9>& matrix) { |
| @@ -113,6 +126,15 @@ void GlCanvas::SetViewSize(int width, int height) { |
| view_size_set_ = true; |
| } |
| +void GlCanvas::Clear() { |
| + glClear(GL_COLOR_BUFFER_BIT); |
|
Yuwei
2016/12/21 23:41:58
glClearColor only specifies the color and glClear
nicholss
2017/01/09 18:50:24
Fixed.
|
| + |
| +#ifndef NDEBUG |
| + // Set the background clear color to bright green for debugging purposes. |
| + glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| +#endif |
|
Yuwei
2016/12/21 23:41:58
Why is the NDEBUG case not here?
|
| +} |
| + |
| void GlCanvas::DrawTexture(int texture_id, |
| GLuint texture_handle, |
| GLuint vertex_buffer, |
| @@ -145,4 +167,12 @@ int GlCanvas::GetMaxTextureSize() const { |
| return max_texture_size_; |
| } |
| +GlCanvas* GlCanvas::CreateGlCanvas(int gl_version) { |
| + if (gl_version > 0) { |
| + return new GlCanvas(gl_version); |
| + } else { |
| + return new FakeGlCanvas(); |
|
joedow
2016/12/22 00:29:01
I don't think this logic should be included in pro
nicholss
2017/01/09 18:50:23
Removing.
|
| + } |
| +} |
| + |
| } // namespace remoting |