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

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

Issue 2591363002: Adding drawable to CRD andorid and iOS gl rendering pipeline. (Closed)
Patch Set: Finished next round of feedback changes. Added more weakptrs for canvas passing. 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_RENDER_LAYER_H_ 5 #ifndef REMOTING_CLIENT_DISPLAY_GL_RENDER_LAYER_H_
6 #define REMOTING_CLIENT_DISPLAY_GL_RENDER_LAYER_H_ 6 #define REMOTING_CLIENT_DISPLAY_GL_RENDER_LAYER_H_
7 7
8 #include <array> 8 #include <array>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
13 #include "remoting/client/display/sys_opengl.h" 14 #include "remoting/client/display/sys_opengl.h"
14 15
15 namespace remoting { 16 namespace remoting {
16 class GlCanvas; 17 class Canvas;
17 18
18 // This class is for drawing a texture on the canvas. Must be deleted before the 19 // This class is for drawing a texture on the canvas. Must be deleted before the
19 // canvas is deleted. 20 // canvas is deleted.
20 class GlRenderLayer { 21 class GlRenderLayer {
21 public: 22 public:
22 static const int kBytesPerPixel = 4; 23 static const int kBytesPerPixel = 4;
23 24
24 // texture_id: An integer in range [0, GL_MAX_TEXTURE_IMAGE_UNITS], defining 25 // texture_id: An integer in range [0, GL_MAX_TEXTURE_IMAGE_UNITS], defining
25 // which slot to store the texture. 26 // which slot to store the texture.
26 GlRenderLayer(int texture_id, GlCanvas* canvas); 27 GlRenderLayer(int texture_id, base::WeakPtr<Canvas> canvas);
27 ~GlRenderLayer(); 28 ~GlRenderLayer();
28 29
29 // Sets the texture (RGBA 8888) to be drawn. Please use UpdateTexture() if the 30 // Sets the texture (RGBA 8888) to be drawn. Please use UpdateTexture() if the
30 // texture size isn't changed. 31 // texture size isn't changed.
31 // stride: byte distance between two rows in |subtexture|. 32 // stride: byte distance between two rows in |subtexture|.
32 // If |stride| is 0 or |stride| == |width|*kBytesPerPixel, |subtexture| will 33 // If |stride| is 0 or |stride| == |width|*kBytesPerPixel, |subtexture| will
33 // be treated as tightly packed. 34 // be treated as tightly packed.
34 void SetTexture(const uint8_t* texture, int width, int height, int stride); 35 void SetTexture(const uint8_t* texture, int width, int height, int stride);
35 36
36 // Updates a subregion (RGBA 8888) of the texture. Can only be called after 37 // Updates a subregion (RGBA 8888) of the texture. Can only be called after
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // function. If this is true, the user need to call 72 // function. If this is true, the user need to call
72 // glPixelStorei(GL_UNPACK_ROW_LENGTH, 0) after 73 // glPixelStorei(GL_UNPACK_ROW_LENGTH, 0) after
73 // updating the texture to reset the stride. 74 // updating the texture to reset the stride.
74 const uint8_t* PrepareTextureBuffer(const uint8_t* data, 75 const uint8_t* PrepareTextureBuffer(const uint8_t* data,
75 int width, 76 int width,
76 int height, 77 int height,
77 int stride, 78 int stride,
78 bool* should_reset_row_length); 79 bool* should_reset_row_length);
79 80
80 int texture_id_; 81 int texture_id_;
81 GlCanvas* canvas_; 82 base::WeakPtr<Canvas> canvas_;
82 83
83 GLuint texture_handle_; 84 GLuint texture_handle_;
84 GLuint buffer_handle_; 85 GLuint buffer_handle_;
85 86
86 bool texture_set_ = false; 87 bool texture_set_ = false;
87 88
88 bool vertex_position_set_ = false; 89 bool vertex_position_set_ = false;
89 90
90 // Used in OpenGL ES 2 context which doesn't support GL_UNPACK_ROW_LENGTH to 91 // 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 // tightly pack dirty regions before sending them to GPU.
92 std::unique_ptr<uint8_t[]> update_buffer_; 93 std::unique_ptr<uint8_t[]> update_buffer_;
93 int update_buffer_size_ = 0; 94 int update_buffer_size_ = 0;
94 95
95 base::ThreadChecker thread_checker_; 96 base::ThreadChecker thread_checker_;
96 DISALLOW_COPY_AND_ASSIGN(GlRenderLayer); 97 DISALLOW_COPY_AND_ASSIGN(GlRenderLayer);
97 }; 98 };
98 99
99 } // namespace remoting 100 } // namespace remoting
100 #endif // REMOTING_CLIENT_DISPLAY_GL_RENDER_LAYER_H_ 101 #endif // REMOTING_CLIENT_DISPLAY_GL_RENDER_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698