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

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

Issue 2614443003: Moving the GL implementation details into a sub folder for client display. (Closed)
Patch Set: Adding deps restriction on r/c/display; Moving sys_opengl.h 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
« no previous file with comments | « remoting/client/gl_math.cc ('k') | remoting/client/gl_render_layer.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_RENDER_LAYER_H_
6 #define REMOTING_CLIENT_OPENGL_GL_RENDER_LAYER_H_
7
8 #include <array>
9 #include <memory>
10
11 #include "base/macros.h"
12 #include "base/threading/thread_checker.h"
13 #include "remoting/client/sys_opengl.h"
14
15 namespace remoting {
16 class GlCanvas;
17
18 // This class is for drawing a texture on the canvas. Must be deleted before the
19 // canvas is deleted.
20 class GlRenderLayer {
21 public:
22 static const int kBytesPerPixel = 4;
23
24 // texture_id: An integer in range [0, GL_MAX_TEXTURE_IMAGE_UNITS], defining
25 // which slot to store the texture.
26 GlRenderLayer(int texture_id, GlCanvas* canvas);
27 ~GlRenderLayer();
28
29 // Sets the texture (RGBA 8888) to be drawn. Please use UpdateTexture() if the
30 // texture size isn't changed.
31 // stride: byte distance between two rows in |subtexture|.
32 // If |stride| is 0 or |stride| == |width|*kBytesPerPixel, |subtexture| will
33 // be treated as tightly packed.
34 void SetTexture(const uint8_t* texture, int width, int height, int stride);
35
36 // Updates a subregion (RGBA 8888) of the texture. Can only be called after
37 // SetTexture() has been called.
38 // stride: See SetTexture().
39 void UpdateTexture(const uint8_t* subtexture,
40 int offset_x,
41 int offset_y,
42 int width,
43 int height,
44 int stride);
45
46 // Sets the positions of four vertices of the texture in pixel with respect to
47 // the canvas.
48 // positions: [ x_upperleft, y_upperleft, x_lowerleft, y_lowerleft,
49 // x_upperright, y_upperright, x_lowerright, y_lowerright ]
50 void SetVertexPositions(const std::array<float, 8>& positions);
51
52 // Sets the visible area of the texture in percentage of the width and height
53 // of the texture. The default values are (0, 0), (0, 1), (1, 0), (1, 1),
54 // i.e. showing the whole texture.
55 // positions: [ x_upperleft, y_upperleft, x_lowerleft, y_lowerleft,
56 // x_upperright, y_upperright, x_lowerright, y_lowerright ]
57 void SetTextureVisibleArea(const std::array<float, 8>& positions);
58
59 // Draws the texture on the canvas. Texture must be set before calling Draw().
60 void Draw(float alpha_multiplier);
61
62 // true if the texture is already set by calling SetTexture().
63 bool is_texture_set() { return texture_set_; }
64
65 private:
66 // Returns pointer to the texture buffer that can be used by glTexImage2d or
67 // glTexSubImage2d. The returned value will be |data| if the texture can be
68 // used without manual packing, otherwise the data will be manually packed and
69 // the pointer to |update_buffer_| will be returned.
70 // should_reset_row_length: Pointer to a bool that will be set by the
71 // function. If this is true, the user need to call
72 // glPixelStorei(GL_UNPACK_ROW_LENGTH, 0) after
73 // updating the texture to reset the stride.
74 const uint8_t* PrepareTextureBuffer(const uint8_t* data,
75 int width,
76 int height,
77 int stride,
78 bool* should_reset_row_length);
79
80 int texture_id_;
81 GlCanvas* canvas_;
82
83 GLuint texture_handle_;
84 GLuint buffer_handle_;
85
86 bool texture_set_ = false;
87
88 bool vertex_position_set_ = false;
89
90 // Used in OpenGL ES 2 context which doesn't support GL_UNPACK_ROW_LENGTH to
91 // tightly pack dirty regions before sending them to GPU.
92 std::unique_ptr<uint8_t[]> update_buffer_;
93 int update_buffer_size_ = 0;
94
95 base::ThreadChecker thread_checker_;
96 DISALLOW_COPY_AND_ASSIGN(GlRenderLayer);
97 };
98
99 } // namespace remoting
100 #endif // REMOTING_CLIENT_OPENGL_GL_RENDER_LAYER_H_
OLDNEW
« no previous file with comments | « remoting/client/gl_math.cc ('k') | remoting/client/gl_render_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698