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

Side by Side Diff: content/common/gpu/media/rendering_helper.h

Issue 462413004: rendering_helper - Refactoring - remove the Client interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_
6 #define CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_
7 7
8 #include <deque>
8 #include <map> 9 #include <map>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
16 #include "ui/gl/gl_bindings.h" 17 #include "ui/gl/gl_bindings.h"
17 #include "ui/gl/gl_context.h" 18 #include "ui/gl/gl_context.h"
18 #include "ui/gl/gl_surface.h" 19 #include "ui/gl/gl_surface.h"
19 20
20 namespace base { 21 namespace base {
21 class MessageLoop; 22 class MessageLoop;
22 class WaitableEvent; 23 class WaitableEvent;
23 } 24 }
24 25
25 namespace content { 26 namespace content {
26 27
27 struct RenderingHelperParams; 28 class VideoFrame : public base::RefCounted<VideoFrame> {
29 public:
30 uint32 texture_id() const { return texture_id_; }
31 uint32 texture_target() const { return texture_target_; }
32
33 VideoFrame(uint32 texture_target,
34 uint32 texture_id,
35 const base::Closure& no_longer_needed_cb);
36 ~VideoFrame();
37
38 private:
39 uint32 texture_target_;
40 uint32 texture_id_;
41 base::Closure no_longer_needed_cb_;
42 };
43
44 struct RenderingHelperParams {
45 RenderingHelperParams();
46 ~RenderingHelperParams();
47
48 // The rendering FPS.
49 int rendering_fps;
50
51 // The desired size of each window. We play each stream in its own window
52 // on the screen.
53 std::vector<gfx::Size> window_sizes;
54
55 // The members below are only used for the thumbnail mode where all frames
56 // are rendered in sequence onto one FBO for comparison/verification purposes.
57
58 // Whether the frames are rendered as scaled thumbnails within a
59 // larger FBO that is in turn rendered to the window.
60 bool render_as_thumbnails;
61 // The size of the FBO containing all visible thumbnails.
62 gfx::Size thumbnails_page_size;
63 // The size of each thumbnail within the FBO.
64 gfx::Size thumbnail_size;
65 };
28 66
29 // Creates and draws textures used by the video decoder. 67 // Creates and draws textures used by the video decoder.
30 // This class is not thread safe and thus all the methods of this class 68 // This class is not thread safe and thus all the methods of this class
31 // (except for ctor/dtor) ensure they're being run on a single thread. 69 // (except for ctor/dtor) ensure they're being run on a single thread.
32 class RenderingHelper { 70 class RenderingHelper {
33 public: 71 public:
34 // Interface for the content provider of the RenderingHelper.
35 class Client {
36 public:
37 // Callback to tell client to render the content.
38 virtual void RenderContent(RenderingHelper* helper) = 0;
39
40 // Callback to get the desired window size of the client.
41 virtual const gfx::Size& GetWindowSize() = 0;
42
43 protected:
44 virtual ~Client() {}
45 };
46 72
47 RenderingHelper(); 73 RenderingHelper();
48 ~RenderingHelper(); 74 ~RenderingHelper();
49 75
50 static bool InitializeOneOff(); 76 static bool InitializeOneOff();
51 77
52 // Create the render context and windows by the specified dimensions. 78 // Create the render context and windows by the specified dimensions.
53 void Initialize(const RenderingHelperParams& params, 79 void Initialize(const RenderingHelperParams& params,
54 base::WaitableEvent* done); 80 base::WaitableEvent* done);
55 81
56 // Undo the effects of Initialize() and signal |*done|. 82 // Undo the effects of Initialize() and signal |*done|.
57 void UnInitialize(base::WaitableEvent* done); 83 void UnInitialize(base::WaitableEvent* done);
58 84
59 // Return a newly-created GLES2 texture id of the specified size, and 85 // Return a newly-created GLES2 texture id of the specified size, and
60 // signal |*done|. 86 // signal |*done|.
61 void CreateTexture(uint32 texture_target, 87 void CreateTexture(uint32 texture_target,
62 uint32* texture_id, 88 uint32* texture_id,
63 const gfx::Size& size, 89 const gfx::Size& size,
64 base::WaitableEvent* done); 90 base::WaitableEvent* done);
65 91
66 // Render thumbnail in the |texture_id| to the FBO buffer using target 92 // Render thumbnail in the |texture_id| to the FBO buffer using target
67 // |texture_target|. 93 // |texture_target|.
68 void RenderThumbnail(uint32 texture_target, uint32 texture_id); 94 void RenderThumbnail(uint32 texture_target, uint32 texture_id);
69 95
70 // Render |texture_id| to the current view port of the screen using target 96 // Queues the VideoFrame for rendering.
71 // |texture_target|. 97 void QueueVideoFrame(size_t window_id, scoped_refptr<VideoFrame> video_frame);
72 void RenderTexture(uint32 texture_target, uint32 texture_id); 98
99 // Drops all the pending video frames of the specified window.
100 void DropPendingFrames(size_t window_id);
73 101
74 // Delete |texture_id|. 102 // Delete |texture_id|.
75 void DeleteTexture(uint32 texture_id); 103 void DeleteTexture(uint32 texture_id);
76 104
77 // Get the platform specific handle to the OpenGL display. 105 // Get the platform specific handle to the OpenGL display.
78 void* GetGLDisplay(); 106 void* GetGLDisplay();
79 107
80 // Get the platform specific handle to the OpenGL context. 108 // Get the platform specific handle to the OpenGL context.
81 void* GetGLContext(); 109 void* GetGLContext();
82 110
83 // Get rendered thumbnails as RGB. 111 // Get rendered thumbnails as RGB.
84 // Sets alpha_solid to true if the alpha channel is entirely 0xff. 112 // Sets alpha_solid to true if the alpha channel is entirely 0xff.
85 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, 113 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb,
86 bool* alpha_solid, 114 bool* alpha_solid,
87 base::WaitableEvent* done); 115 base::WaitableEvent* done);
88 116
89 private: 117 private:
118 struct RenderedVideo {
119 // The rect on the screen where the video will be rendered.
120 gfx::Rect render_area;
121
122 // Ture if the last (and the only one) frame in pending_frames has
Pawel Osciak 2014/08/15 05:45:16 s/Ture/True/ Also, I think you want to say not th
Owen Lin 2014/08/18 09:03:08 I have changed the documentation. But I am confuse
Pawel Osciak 2014/08/20 10:26:26 Right, it was actually me who was confused. Please
123 // been rendered.
124 bool last_frame_rendered;
125
126 // The video frames pending for rendering.
127 std::deque<scoped_refptr<VideoFrame> > pending_frames;
Pawel Osciak 2014/08/15 05:45:16 Oh I forgot to comment on this last time, you don'
Owen Lin 2014/08/18 09:03:08 Done. Thanks. I got a feeling that deque is more e
128
129 RenderedVideo() : last_frame_rendered(false) {}
130 };
131
90 void Clear(); 132 void Clear();
91 133
92 void RenderContent(); 134 void RenderContent();
93 135
94 void LayoutRenderingAreas(); 136 void LayoutRenderingAreas(const std::vector<gfx::Size>& window_sizes);
137
138 // Render |texture_id| to the current view port of the screen using target
139 // |texture_target|.
140 void RenderTexture(uint32 texture_target, uint32 texture_id);
95 141
96 // Timer to trigger the RenderContent() repeatly. 142 // Timer to trigger the RenderContent() repeatly.
97 scoped_ptr<base::RepeatingTimer<RenderingHelper> > render_timer_; 143 scoped_ptr<base::RepeatingTimer<RenderingHelper> > render_timer_;
98 base::MessageLoop* message_loop_; 144 base::MessageLoop* message_loop_;
99 145
100 scoped_refptr<gfx::GLContext> gl_context_; 146 scoped_refptr<gfx::GLContext> gl_context_;
101 scoped_refptr<gfx::GLSurface> gl_surface_; 147 scoped_refptr<gfx::GLSurface> gl_surface_;
102 148
103 gfx::AcceleratedWidget window_; 149 gfx::AcceleratedWidget window_;
104 150
105 gfx::Size screen_size_; 151 gfx::Size screen_size_;
106 152
107 // The rendering area of each window on the screen. 153 std::vector<RenderedVideo> videos_;
108 std::vector<gfx::Rect> render_areas_;
109
110 std::vector<base::WeakPtr<Client> > clients_;
111 154
112 bool render_as_thumbnails_; 155 bool render_as_thumbnails_;
113 int frame_count_; 156 int frame_count_;
114 GLuint thumbnails_fbo_id_; 157 GLuint thumbnails_fbo_id_;
115 GLuint thumbnails_texture_id_; 158 GLuint thumbnails_texture_id_;
116 gfx::Size thumbnails_fbo_size_; 159 gfx::Size thumbnails_fbo_size_;
117 gfx::Size thumbnail_size_; 160 gfx::Size thumbnail_size_;
118 GLuint program_; 161 GLuint program_;
119 base::TimeDelta frame_duration_; 162 base::TimeDelta frame_duration_;
120 163
121 DISALLOW_COPY_AND_ASSIGN(RenderingHelper); 164 DISALLOW_COPY_AND_ASSIGN(RenderingHelper);
122 }; 165 };
123 166
124 struct RenderingHelperParams {
125 RenderingHelperParams();
126 ~RenderingHelperParams();
127
128 // The rendering FPS.
129 int rendering_fps;
130
131 // The clients who provide the content for rendering.
132 std::vector<base::WeakPtr<RenderingHelper::Client> > clients;
133
134 // Whether the frames are rendered as scaled thumbnails within a
135 // larger FBO that is in turn rendered to the window.
136 bool render_as_thumbnails;
137 // The size of the FBO containing all visible thumbnails.
138 gfx::Size thumbnails_page_size;
139 // The size of each thumbnail within the FBO.
140 gfx::Size thumbnail_size;
141 };
142 } // namespace content 167 } // namespace content
143 168
144 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ 169 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/media/rendering_helper.cc » ('j') | content/common/gpu/media/rendering_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698