Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: remoting/client/display/gl_canvas.h

Issue 2591363002: Adding drawable to CRD andorid and iOS gl rendering pipeline. (Closed)
Patch Set: Cleanup and adding interfaces based on review feedback.: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_CLIENT_DISPLAY_GL_CANVAS_H_ 5 #ifndef REMOTING_CLIENT_DISPLAY_GL_CANVAS_H_
6 #define REMOTING_CLIENT_DISPLAY_GL_CANVAS_H_ 6 #define REMOTING_CLIENT_DISPLAY_GL_CANVAS_H_
7 7
8 #include <array> 8 #include <array>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "remoting/client/display/canvas.h"
12 #include "remoting/client/display/sys_opengl.h" 13 #include "remoting/client/display/sys_opengl.h"
13 14
14 namespace remoting { 15 namespace remoting {
15 16
16 // This class holds zoom and pan configurations of the canvas and is used to 17 // This class holds zoom and pan configurations of the canvas and is used to
17 // draw textures on the canvas. 18 // draw textures on the canvas.
18 // Must be constructed after the OpenGL surface is created and destroyed before 19 // Must be constructed after the OpenGL surface is created and destroyed before
19 // the surface is destroyed. 20 // the surface is destroyed.
20 class GlCanvas { 21 class GlCanvas : public Canvas {
21 public: 22 public:
22 // gl_version: version number of the OpenGL ES context. Either 2 or 3. 23 // gl_version: version number of the OpenGL ES context. Either 2 or 3.
23 GlCanvas(int gl_version); 24 GlCanvas(int gl_version);
24 25
25 ~GlCanvas(); 26 ~GlCanvas() override;
27
28 void Clear() override;
26 29
27 // Sets the transformation matrix. This matrix defines how the canvas should 30 // Sets the transformation matrix. This matrix defines how the canvas should
28 // be shown on the view. 31 // be shown on the view.
29 // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ]. 32 // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ].
30 // The matrix will be multiplied with the positions (with projective space, 33 // The matrix will be multiplied with the positions (with projective space,
31 // (x, y, 1)) to draw the textures with the right zoom and pan configuration. 34 // (x, y, 1)) to draw the textures with the right zoom and pan configuration.
32 // 35 //
33 // | m0, m1, m2, | | x | 36 // | m0, m1, m2, | | x |
34 // | m3, m4, m5, | * | y | 37 // | m3, m4, m5, | * | y |
35 // | m6, m7, m8 | | 1 | 38 // | m6, m7, m8 | | 1 |
36 // 39 //
37 // For a typical transformation matrix such that m1=m3=m6=m7=0 and m8=1, m0 40 // For a typical transformation matrix such that m1=m3=m6=m7=0 and m8=1, m0
38 // and m4 defines the scaling factor of the canvas and m2 and m5 defines the 41 // and m4 defines the scaling factor of the canvas and m2 and m5 defines the
39 // offset of the upper-left corner in pixel. 42 // offset of the upper-left corner in pixel.
40 void SetTransformationMatrix(const std::array<float, 9>& matrix); 43 void SetTransformationMatrix(const std::array<float, 9>& matrix) override;
41 44
42 // Sets the size of the view in pixels. 45 // Sets the size of the view in pixels.
43 void SetViewSize(int width, int height); 46 void SetViewSize(int width, int height) override;
44 47
45 // Draws the texture on the canvas. Nothing will happen if 48 // Draws the texture on the canvas. Nothing will happen if
46 // SetNormalizedTransformation() has not been called. 49 // SetNormalizedTransformation() has not been called.
47 // vertex_buffer: reference to the 2x4x2 float vertex buffer. 50 // vertex_buffer: reference to the 2x4x2 float vertex buffer.
48 // [ four (x, y) position of the texture vertices in pixel 51 // [ four (x, y) position of the texture vertices in pixel
49 // with respect to the canvas, 52 // with respect to the canvas,
50 // four (x, y) position of the vertices in percentage 53 // four (x, y) position of the vertices in percentage
51 // defining the visible area of the texture ] 54 // defining the visible area of the texture ]
52 // alpha_multiplier: Will be multiplied with the alpha channel of the texture. 55 // alpha_multiplier: Will be multiplied with the alpha channel of the texture.
53 // Passing 1 means no change of the transparency of the 56 // Passing 1 means no change of the transparency of the
54 // texture. 57 // texture.
55 void DrawTexture(int texture_id, 58 void DrawTexture(int texture_id,
56 GLuint texture_handle, 59 GLuint texture_handle,
57 GLuint vertex_buffer, 60 GLuint vertex_buffer,
58 float alpha_multiplier); 61 float alpha_multiplier) override;
59 62
60 // Returns the version number of current OpenGL ES context. Either 2 or 3. 63 // Returns the version number of current OpenGL ES context. Either 2 or 3.
61 int GetGlVersion() const; 64 int GetVersion() const override;
62 65
63 // Returns the maximum texture resolution limitation. Neither the width nor 66 // Returns the maximum texture resolution limitation. Neither the width nor
64 // the height of the texture can exceed this limitation. 67 // the height of the texture can exceed this limitation.
65 int GetMaxTextureSize() const; 68 int GetMaxTextureSize() const override;
66 69
67 private: 70 private:
71 GlCanvas();
Yuwei 2017/01/09 20:28:52 Where is this constructor used?
nicholss 2017/01/09 20:39:24 it is not, removed.
68 int gl_version_; 72 int gl_version_;
69 73
70 int max_texture_size_ = 0; 74 int max_texture_size_ = 0;
71 bool transformation_set_ = false; 75 bool transformation_set_ = false;
72 bool view_size_set_ = false; 76 bool view_size_set_ = false;
73 77
74 // Handles. 78 // Handles.
75 GLuint vertex_shader_; 79 GLuint vertex_shader_;
76 GLuint fragment_shader_; 80 GLuint fragment_shader_;
77 GLuint program_; 81 GLuint program_;
78 82
79 // Locations of the corresponding shader attributes. 83 // Locations of the corresponding shader attributes.
80 GLuint transform_location_; 84 GLuint transform_location_;
81 GLuint view_size_location_; 85 GLuint view_size_location_;
82 GLuint texture_location_; 86 GLuint texture_location_;
83 GLuint alpha_multiplier_location_; 87 GLuint alpha_multiplier_location_;
84 GLuint position_location_; 88 GLuint position_location_;
85 GLuint tex_cord_location_; 89 GLuint tex_cord_location_;
86 90
87 base::ThreadChecker thread_checker_; 91 base::ThreadChecker thread_checker_;
88 92
89 DISALLOW_COPY_AND_ASSIGN(GlCanvas); 93 DISALLOW_COPY_AND_ASSIGN(GlCanvas);
90 }; 94 };
91 95
92 } // namespace remoting 96 } // namespace remoting
93 97
94 #endif // REMOTING_CLIENT_DISPLAY_GL_CANVAS_H_ 98 #endif // REMOTING_CLIENT_DISPLAY_GL_CANVAS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698