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

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

Issue 2045963004: [Remoting] OpenGL Rendering Layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Inlines Shaders & Fixes build files 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
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 "base/macros.h"
9 #include "base/threading/thread_checker.h"
10 #include "remoting/client/sys_opengl.h"
11
12 namespace remoting {
13 class GlCanvas;
14
15 // This class is for drawing a texture on the canvas. Must be deleted before the
16 // canvas is deleted.
17 class GlRenderLayer {
18 public:
19 // texture_id: An integer in range [0, GL_MAX_TEXTURE_IMAGE_UNITS], defining
20 // which slot to store the texture.
21 GlRenderLayer(int texture_id, GlCanvas* canvas);
22 ~GlRenderLayer();
23
24 // Sets the texture (BGRA 8888) to be drawn. Please use UpdateTexture() if the
25 // texture size isn't changed.
26 void SetTexture(const void* texture, int width, int height);
27
28 // Updates a subregion (BGRA 8888) of the texture.
29 // If |pixel_stride| is 0 or |pixel_stride| == |width|, |subtexture| will be
30 // treated as tightly packed.
31 void UpdateTexture(const void* subtexture,
32 int offset_x,
33 int offset_y,
34 int width,
35 int height,
36 int pixel_stride);
37
38 // Sets the positions of four vertices of the texture in normalized
39 // coordinates. The default values are (0, 0), (0, 1), (1, 0), (1, 1),
40 // i.e. stretching the texture to fit the whole canvas.
41 // positions: [ x_upperleft, y_upperleft, x_lowerleft, y_lowerleft,
42 // x_upperright, y_upperright, x_lowerright, y_lowerright ]
43 void SetVertexPositions(const float positions[8]);
44
45 // Sets the visible area of the texture. The default values are (0, 0),
46 // (0, 1), (1, 0), (1, 1), i.e. showing the whole texture.
47 // positions: [ x_upperleft, y_upperleft, x_lowerleft, y_lowerleft,
48 // x_upperright, y_upperright, x_lowerright, y_lowerright ]
49 void SetTextureVisibleArea(const float positions[8]);
50
51 // Draws the texture on the canvas. Texture must be set before calling Draw().
52 void Draw();
53
54 private:
55 static void PackDirtyRegion(void* dest,
56 const void* source,
57 int width,
58 int height,
59 int stride);
60 int texture_id_;
61 GlCanvas* canvas_;
62
63 GLuint texture_handle_;
64 GLuint buffer_handle_;
65
66 // true IFF the texture is already set by calling SetTexture().
67 bool texture_set_ = false;
68
69 // Used in OpenGL ES 2 context which doesn't support GL_UNPACK_ROW_LENGTH to
70 // tightly pack dirty regions before sending them to GPU.
71 std::unique_ptr<uint8_t[]> update_buffer_;
72 int update_buffer_size_ = 0;
73
74 base::ThreadChecker thread_checker_;
75 DISALLOW_COPY_AND_ASSIGN(GlRenderLayer);
76 };
77
78 } // namespace remoting
79 #endif // REMOTING_CLIENT_OPENGL_GL_RENDER_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698