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

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

Issue 294663006: vda_unittest - Move the fps control from ThrottleVDAClient to RenderingHelper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 7 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 <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "ui/gfx/size.h" 12 #include "base/time/time.h"
13 #include "base/timer/timer.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/size.h"
13 #include "ui/gl/gl_bindings.h" 16 #include "ui/gl/gl_bindings.h"
14 17
15 namespace base { 18 namespace base {
16 class MessageLoop; 19 class MessageLoop;
17 class WaitableEvent; 20 class WaitableEvent;
18 } 21 }
19 22
20 #if !defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY) 23 #if !defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY)
21 #define GL_VARIANT_GLX 1 24 #define GL_VARIANT_GLX 1
22 typedef GLXContext NativeContextType; 25 typedef GLXContext NativeContextType;
23 #else 26 #else
24 #define GL_VARIANT_EGL 1 27 #define GL_VARIANT_EGL 1
25 typedef EGLContext NativeContextType; 28 typedef EGLContext NativeContextType;
26 #endif 29 #endif
27 30
28 namespace content { 31 namespace content {
29 32
30 struct RenderingHelperParams { 33 struct RenderingHelperParams;
31 RenderingHelperParams();
32 ~RenderingHelperParams();
33
34 bool suppress_swap_to_display;
35 int num_windows;
36 // Dimensions of window(s) created for displaying frames. In the
37 // case of thumbnail rendering, these won't match the frame dimensions.
38 std::vector<gfx::Size> window_dimensions;
39 // Dimensions of video frame texture(s).
40 std::vector<gfx::Size> frame_dimensions;
41 // Whether the frames are rendered as scaled thumbnails within a
42 // larger FBO that is in turn rendered to the window.
43 bool render_as_thumbnails;
44 // The size of the FBO containing all visible thumbnails.
45 gfx::Size thumbnails_page_size;
46 // The size of each thumbnail within the FBO.
47 gfx::Size thumbnail_size;
48 };
49 34
50 // Creates and draws textures used by the video decoder. 35 // Creates and draws textures used by the video decoder.
51 // This class is not thread safe and thus all the methods of this class 36 // This class is not thread safe and thus all the methods of this class
52 // (except for ctor/dtor) ensure they're being run on a single thread. 37 // (except for ctor/dtor) ensure they're being run on a single thread.
53 class RenderingHelper { 38 class RenderingHelper {
54 public: 39 public:
40 // Interface for the content provider of the RenderingHelper.
41 class Client {
42 public:
43 // Callback to tell client to render the content.
44 virtual void RenderContent(RenderingHelper* helper) = 0;
45
46 protected:
47 virtual ~Client() {}
48 };
49
55 RenderingHelper(); 50 RenderingHelper();
56 ~RenderingHelper(); 51 ~RenderingHelper();
57 52
58 // Create the render context and windows by the specified dimensions. 53 // Create the render context and windows by the specified dimensions.
59 void Initialize(const RenderingHelperParams& params, 54 void Initialize(const RenderingHelperParams& params,
60 base::WaitableEvent* done); 55 base::WaitableEvent* done);
61 56
62 // Undo the effects of Initialize() and signal |*done|. 57 // Undo the effects of Initialize() and signal |*done|.
63 void UnInitialize(base::WaitableEvent* done); 58 void UnInitialize(base::WaitableEvent* done);
64 59
65 // Return a newly-created GLES2 texture id rendering to a specific window, and 60 // Return a newly-created GLES2 texture id rendering to a specific window, and
66 // signal |*done|. 61 // signal |*done|.
67 void CreateTexture(int window_id, 62 void CreateTexture(int window_id,
68 uint32 texture_target, 63 uint32 texture_target,
69 uint32* texture_id, 64 uint32* texture_id,
70 base::WaitableEvent* done); 65 base::WaitableEvent* done);
71 66
72 // Render |texture_id| to the screen using target |texture_target|. 67 // Render thumbnail in the |texture_id| to the FBO buffer using target
68 // |texture_target|.
69 void RenderThumbnail(uint32 texture_target, uint32 texture_id);
70
71 // Render |texture_id| to the current view port of the screen using target
72 // |texture_target|.
73 void RenderTexture(uint32 texture_target, uint32 texture_id); 73 void RenderTexture(uint32 texture_target, uint32 texture_id);
74 74
75 // Delete |texture_id|. 75 // Delete |texture_id|.
76 void DeleteTexture(uint32 texture_id); 76 void DeleteTexture(uint32 texture_id);
77 77
78 // Get the platform specific handle to the OpenGL display. 78 // Get the platform specific handle to the OpenGL display.
79 void* GetGLDisplay(); 79 void* GetGLDisplay();
80 80
81 // Get the platform specific handle to the OpenGL context. 81 // Get the platform specific handle to the OpenGL context.
82 NativeContextType GetGLContext(); 82 NativeContextType GetGLContext();
83 83
84 // Get rendered thumbnails as RGB. 84 // Get rendered thumbnails as RGB.
85 // Sets alpha_solid to true if the alpha channel is entirely 0xff. 85 // Sets alpha_solid to true if the alpha channel is entirely 0xff.
86 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, 86 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb,
87 bool* alpha_solid, 87 bool* alpha_solid,
88 base::WaitableEvent* done); 88 base::WaitableEvent* done);
89 89
90 private: 90 private:
91 void Clear(); 91 void Clear();
92 92
93 // Make window_id's surface current w/ the GL context, or release the context 93 void RenderContent();
94 // if |window_id < 0|. 94 base::RepeatingTimer<RenderingHelper> render_timer_;
95 void MakeCurrent(int window_id);
96
97 base::MessageLoop* message_loop_; 95 base::MessageLoop* message_loop_;
98 std::vector<gfx::Size> window_dimensions_;
99 std::vector<gfx::Size> frame_dimensions_; 96 std::vector<gfx::Size> frame_dimensions_;
100 97
101 NativeContextType gl_context_; 98 NativeContextType gl_context_;
102 std::map<uint32, int> texture_id_to_surface_index_; 99 std::map<uint32, int> texture_id_to_surface_index_;
103 100
104 #if defined(GL_VARIANT_EGL) 101 #if defined(GL_VARIANT_EGL)
105 EGLDisplay gl_display_; 102 EGLDisplay gl_display_;
106 std::vector<EGLSurface> gl_surfaces_; 103 EGLSurface gl_surface_;
107 #else 104 #else
108 XVisualInfo* x_visual_; 105 XVisualInfo* x_visual_;
109 #endif 106 #endif
110 107
111 #if defined(OS_WIN) 108 #if defined(OS_WIN)
112 std::vector<HWND> windows_; 109 HWND window_;
113 #else 110 #else
114 Display* x_display_; 111 Display* x_display_;
115 std::vector<Window> x_windows_; 112 Window x_window_;
116 #endif 113 #endif
117 114
115 // The rendering area of each window on the screen.
116 std::vector<gfx::Rect> render_areas_;
117
118 std::vector<base::WeakPtr<Client> > clients_;
119
118 bool render_as_thumbnails_; 120 bool render_as_thumbnails_;
119 int frame_count_; 121 int frame_count_;
120 GLuint thumbnails_fbo_id_; 122 GLuint thumbnails_fbo_id_;
121 GLuint thumbnails_texture_id_; 123 GLuint thumbnails_texture_id_;
122 gfx::Size thumbnails_fbo_size_; 124 gfx::Size thumbnails_fbo_size_;
123 gfx::Size thumbnail_size_; 125 gfx::Size thumbnail_size_;
124 GLuint program_; 126 GLuint program_;
127 base::TimeDelta frame_duration_;
125 128
126 DISALLOW_COPY_AND_ASSIGN(RenderingHelper); 129 DISALLOW_COPY_AND_ASSIGN(RenderingHelper);
127 }; 130 };
128 131
132 struct RenderingHelperParams {
133 RenderingHelperParams();
134 ~RenderingHelperParams();
135 int rendering_fps;
136
137 std::vector<base::WeakPtr<RenderingHelper::Client> > clients;
138 int num_windows;
139
140 // Dimensions of window(s) created for displaying frames. In the
141 // case of thumbnail rendering, these won't match the frame dimensions.
142 std::vector<gfx::Size> window_dimensions;
143 // Dimensions of video frame texture(s).
144 std::vector<gfx::Size> frame_dimensions;
145 // Whether the frames are rendered as scaled thumbnails within a
146 // larger FBO that is in turn rendered to the window.
147 bool render_as_thumbnails;
148 // The size of the FBO containing all visible thumbnails.
149 gfx::Size thumbnails_page_size;
150 // The size of each thumbnail within the FBO.
151 gfx::Size thumbnail_size;
152 };
129 } // namespace content 153 } // namespace content
130 154
131 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ 155 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698