Chromium Code Reviews| Index: remoting/client/opengl/gl_canvas.h |
| diff --git a/remoting/client/opengl/gl_canvas.h b/remoting/client/opengl/gl_canvas.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0dbb98a79de4a2542c566fa9f3c90b555f53c47a |
| --- /dev/null |
| +++ b/remoting/client/opengl/gl_canvas.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_CLIENT_OPENGL_GL_CANVAS_H_ |
| +#define REMOTING_CLIENT_OPENGL_GL_CANVAS_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "remoting/client/opengl_wrapper.h" |
| + |
| +namespace remoting { |
| + |
| +// This class holds zoom and pan configurations of the canvas and is used to |
| +// draw textures on the canvas. |
| +// Must be constructed after the OpenGL surface is created and destructed before |
| +// the surface is destroyed. |
| +// For more details, see the design doc: https://goo.gl/v549OW |
|
Sergey Ulanov
2016/06/27 23:15:29
Please don't refer to design docs from the code. D
Yuwei
2016/06/28 22:51:11
Done. Removed.
|
| +class GlCanvas { |
| + public: |
| + GlCanvas(); |
| + ~GlCanvas(); |
| + |
| + // Sets the normalized transformation matrix. |
| + // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ]. |
| + // The matrix will be multiplied with the positions (with projective space, |
| + // (x, y, 1)) to draw the textures with the right zoom and pan configuration. |
| + // |
| + // | m0, m1, m2, | | x | |
| + // | m3, m4, m5, | * | y | |
| + // | m6, m7, m8 | | 1 | |
| + // |
| + // By default the transformation is a zero matrix. |
|
Sergey Ulanov
2016/06/27 23:15:29
Why is it 0-matrix? wouldn't it make more sense to
Yuwei
2016/06/28 01:31:20
I don't have strong opinion... I made it 0-matrix
Sergey Ulanov
2016/06/30 00:34:52
I guess even if it's 0-matrix it doesn't mean noth
Yuwei
2016/07/07 22:07:45
Just made it draw nothing if the transformation ma
|
| + void SetNormalizedTransformation(const float* matrix); |
| + |
| + // Draws the texture on the canvas. |
| + // vertex_buffer: reference to the 2x4x2 float vertex buffer. |
| + // [ four (x, y) normalized vertex positions on the canvas, |
| + // four (x, y) vertex positions to define the visible area ] |
| + void DrawTexture(int texture_id, GLuint texture_handle, GLuint vertex_buffer); |
| + |
| + private: |
| + // Handles. |
| + GLuint vertex_shader_; |
| + GLuint fragment_shader_; |
| + GLuint program_; |
| + |
| + // Indices. |
| + GLuint transform_loc_; |
|
Sergey Ulanov
2016/06/27 23:15:29
it's not clear from the comment or name what this
Yuwei
2016/06/28 22:51:11
Done.
|
| + GLuint texture_loc_; |
| + GLuint position_loc_; |
| + GLuint tex_cord_loc_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GlCanvas); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_CLIENT_OPENGL_GL_CANVAS_H_ |