Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_CLIENT_OPENGL_GL_CANVAS_H_ | |
| 6 #define REMOTING_CLIENT_OPENGL_GL_CANVAS_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/threading/thread_checker.h" | |
| 10 #include "remoting/client/opengl_wrapper.h" | |
| 11 | |
| 12 namespace remoting { | |
| 13 | |
| 14 // This class holds zoom and pan configurations of the canvas and is used to | |
| 15 // draw textures on the canvas. | |
| 16 // Must be constructed after the OpenGL surface is created and destructed before | |
| 17 // the surface is destroyed. | |
| 18 // 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.
| |
| 19 class GlCanvas { | |
| 20 public: | |
| 21 GlCanvas(); | |
| 22 ~GlCanvas(); | |
| 23 | |
| 24 // Sets the normalized transformation matrix. | |
| 25 // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ]. | |
| 26 // The matrix will be multiplied with the positions (with projective space, | |
| 27 // (x, y, 1)) to draw the textures with the right zoom and pan configuration. | |
| 28 // | |
| 29 // | m0, m1, m2, | | x | | |
| 30 // | m3, m4, m5, | * | y | | |
| 31 // | m6, m7, m8 | | 1 | | |
| 32 // | |
| 33 // 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
| |
| 34 void SetNormalizedTransformation(const float* matrix); | |
| 35 | |
| 36 // Draws the texture on the canvas. | |
| 37 // vertex_buffer: reference to the 2x4x2 float vertex buffer. | |
| 38 // [ four (x, y) normalized vertex positions on the canvas, | |
| 39 // four (x, y) vertex positions to define the visible area ] | |
| 40 void DrawTexture(int texture_id, GLuint texture_handle, GLuint vertex_buffer); | |
| 41 | |
| 42 private: | |
| 43 // Handles. | |
| 44 GLuint vertex_shader_; | |
| 45 GLuint fragment_shader_; | |
| 46 GLuint program_; | |
| 47 | |
| 48 // Indices. | |
| 49 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.
| |
| 50 GLuint texture_loc_; | |
| 51 GLuint position_loc_; | |
| 52 GLuint tex_cord_loc_; | |
| 53 | |
| 54 base::ThreadChecker thread_checker_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(GlCanvas); | |
| 57 }; | |
| 58 | |
| 59 } // namespace remoting | |
| 60 | |
| 61 #endif // REMOTING_CLIENT_OPENGL_GL_CANVAS_H_ | |
| OLD | NEW |