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

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

Issue 2045963004: [Remoting] OpenGL Rendering Layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 5 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
« no previous file with comments | « remoting/client/BUILD.gn ('k') | remoting/client/gl_canvas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 <array>
9
10 #include "base/macros.h"
11 #include "base/threading/thread_checker.h"
12 #include "remoting/client/sys_opengl.h"
13
14 namespace remoting {
15
16 // This class holds zoom and pan configurations of the canvas and is used to
17 // draw textures on the canvas.
18 // Must be constructed after the OpenGL surface is created and destroyed before
19 // the surface is destroyed.
20 //
21 // Coordinates to be used for GlCanvas should be normalized texture coordinates.
22 // In the view of a point on the canvas, the canvas has width 1 and height 1,
23 // with the origin at the upper-left corner of the canvas.
24 class GlCanvas {
25 public:
26 // gl_version: version number of the OpenGL ES context. Either 2 or 3.
27 GlCanvas(int gl_version);
28
29 ~GlCanvas();
30
31 // Sets the normalized transformation matrix. This matrix defines how the
32 // canvas should be shown on the view.
33 // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ].
34 // The matrix will be multiplied with the positions (with projective space,
35 // (x, y, 1)) to draw the textures with the right zoom and pan configuration.
36 //
37 // | m0, m1, m2, | | x |
38 // | m3, m4, m5, | * | y |
39 // | m6, m7, m8 | | 1 |
40 //
41 // For a typical transformation matrix such that m1=m3=m6=m7=0 and m8=1, m0
42 // and m4 defines the ratio of canvas width or height over view width or
43 // height. m2 and m5 defines the offset of the upper-left corner in percentage
44 // of the view's width or height. An identity matrix will stretch the canvas
45 // to fit the whole view.
46 void SetNormalizedTransformation(const std::array<float, 9>& matrix);
47
48 // Draws the texture on the canvas. Nothing will happen if
49 // SetNormalizedTransformation() has not been called.
50 // vertex_buffer: reference to the 2x4x2 float vertex buffer.
51 // [ four (x, y) normalized vertex positions on the canvas,
52 // four (x, y) vertex positions to define the visible area ]
53 void DrawTexture(int texture_id, GLuint texture_handle, GLuint vertex_buffer);
54
55 // Returns the version number of current OpenGL ES context. Either 2 or 3.
56 int GetGlVersion() const;
57
58 private:
59 int gl_version_;
60
61 // True IFF the transformation has been set.
62 bool transformation_set_ = false;
63
64 // Handles.
65 GLuint vertex_shader_;
66 GLuint fragment_shader_;
67 GLuint program_;
68
69 // Locations of the corresponding shader attributes.
70 GLuint transform_location_;
71 GLuint texture_location_;
72 GLuint position_location_;
73 GLuint tex_cord_location_;
74
75 base::ThreadChecker thread_checker_;
76
77 DISALLOW_COPY_AND_ASSIGN(GlCanvas);
78 };
79
80 } // namespace remoting
81
82 #endif // REMOTING_CLIENT_OPENGL_GL_CANVAS_H_
OLDNEW
« no previous file with comments | « remoting/client/BUILD.gn ('k') | remoting/client/gl_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698