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

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: rebase Created 6 years, 6 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 | « no previous file | content/common/gpu/media/rendering_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 12 matching lines...) Expand all
23 #if !defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY) 23 #if !defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY)
24 #define GL_VARIANT_GLX 1 24 #define GL_VARIANT_GLX 1
25 typedef GLXContext NativeContextType; 25 typedef GLXContext NativeContextType;
26 #else 26 #else
27 #define GL_VARIANT_EGL 1 27 #define GL_VARIANT_EGL 1
28 typedef EGLContext NativeContextType; 28 typedef EGLContext NativeContextType;
29 #endif 29 #endif
30 30
31 namespace content { 31 namespace content {
32 32
33 struct RenderingHelperParams { 33 struct RenderingHelperParams;
34 RenderingHelperParams();
35 ~RenderingHelperParams();
36
37 bool suppress_swap_to_display;
38 int num_windows;
39 // Dimensions of window(s) created for displaying frames. In the
40 // case of thumbnail rendering, these won't match the frame dimensions.
41 std::vector<gfx::Size> window_dimensions;
42 // Dimensions of video frame texture(s).
43 std::vector<gfx::Size> frame_dimensions;
44 // Whether the frames are rendered as scaled thumbnails within a
45 // larger FBO that is in turn rendered to the window.
46 bool render_as_thumbnails;
47 // The size of the FBO containing all visible thumbnails.
48 gfx::Size thumbnails_page_size;
49 // The size of each thumbnail within the FBO.
50 gfx::Size thumbnail_size;
51 };
52 34
53 // Creates and draws textures used by the video decoder. 35 // Creates and draws textures used by the video decoder.
54 // 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
55 // (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.
56 class RenderingHelper { 38 class RenderingHelper {
57 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
58 RenderingHelper(); 50 RenderingHelper();
59 ~RenderingHelper(); 51 ~RenderingHelper();
60 52
61 // Create the render context and windows by the specified dimensions. 53 // Create the render context and windows by the specified dimensions.
62 void Initialize(const RenderingHelperParams& params, 54 void Initialize(const RenderingHelperParams& params,
63 base::WaitableEvent* done); 55 base::WaitableEvent* done);
64 56
65 // Undo the effects of Initialize() and signal |*done|. 57 // Undo the effects of Initialize() and signal |*done|.
66 void UnInitialize(base::WaitableEvent* done); 58 void UnInitialize(base::WaitableEvent* done);
67 59
68 // 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
69 // signal |*done|. 61 // signal |*done|.
70 void CreateTexture(int window_id, 62 void CreateTexture(int window_id,
71 uint32 texture_target, 63 uint32 texture_target,
72 uint32* texture_id, 64 uint32* texture_id,
73 base::WaitableEvent* done); 65 base::WaitableEvent* done);
74 66
75 // 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|.
76 void RenderTexture(uint32 texture_target, uint32 texture_id); 73 void RenderTexture(uint32 texture_target, uint32 texture_id);
77 74
78 // Delete |texture_id|. 75 // Delete |texture_id|.
79 void DeleteTexture(uint32 texture_id); 76 void DeleteTexture(uint32 texture_id);
80 77
81 // Get the platform specific handle to the OpenGL display. 78 // Get the platform specific handle to the OpenGL display.
82 void* GetGLDisplay(); 79 void* GetGLDisplay();
83 80
84 // Get the platform specific handle to the OpenGL context. 81 // Get the platform specific handle to the OpenGL context.
85 NativeContextType GetGLContext(); 82 NativeContextType GetGLContext();
86 83
87 // Get rendered thumbnails as RGB. 84 // Get rendered thumbnails as RGB.
88 // 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.
89 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, 86 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb,
90 bool* alpha_solid, 87 bool* alpha_solid,
91 base::WaitableEvent* done); 88 base::WaitableEvent* done);
92 89
93 private: 90 private:
94 void Clear(); 91 void Clear();
95 92
96 void RenderContent(); 93 void RenderContent();
97 void DrawTexture(const gfx::Rect& area,
98 uint32 texture_target,
99 uint32 texture_id);
100 94
101 // Timer to trigger the RenderContent() repeatly. 95 // Timer to trigger the RenderContent() repeatly.
102 base::RepeatingTimer<RenderingHelper> render_timer_; 96 base::RepeatingTimer<RenderingHelper> render_timer_;
103 base::MessageLoop* message_loop_; 97 base::MessageLoop* message_loop_;
104 std::vector<gfx::Size> frame_dimensions_; 98 std::vector<gfx::Size> frame_dimensions_;
105 99
106 NativeContextType gl_context_; 100 NativeContextType gl_context_;
107 std::map<uint32, int> texture_id_to_surface_index_; 101 std::map<uint32, int> texture_id_to_surface_index_;
108 102
109 #if defined(GL_VARIANT_EGL) 103 #if defined(GL_VARIANT_EGL)
110 EGLDisplay gl_display_; 104 EGLDisplay gl_display_;
111 EGLSurface gl_surface_; 105 EGLSurface gl_surface_;
112 #else 106 #else
113 XVisualInfo* x_visual_; 107 XVisualInfo* x_visual_;
114 #endif 108 #endif
115 109
116 #if defined(OS_WIN) 110 #if defined(OS_WIN)
117 HWND window_; 111 HWND window_;
118 #else 112 #else
119 Display* x_display_; 113 Display* x_display_;
120 Window x_window_; 114 Window x_window_;
121 #endif 115 #endif
122 116
123 // The rendering area of each window on the screen. 117 // The rendering area of each window on the screen.
124 std::vector<gfx::Rect> render_areas_; 118 std::vector<gfx::Rect> render_areas_;
125 119
126 // The texture to be rendered on each window. 120 std::vector<base::WeakPtr<Client> > clients_;
127 std::vector<uint32> texture_ids_;
128 std::vector<uint32> texture_targets_;
129 121
130 bool render_as_thumbnails_; 122 bool render_as_thumbnails_;
131 int frame_count_; 123 int frame_count_;
132 GLuint thumbnails_fbo_id_; 124 GLuint thumbnails_fbo_id_;
133 GLuint thumbnails_texture_id_; 125 GLuint thumbnails_texture_id_;
134 gfx::Size thumbnails_fbo_size_; 126 gfx::Size thumbnails_fbo_size_;
135 gfx::Size thumbnail_size_; 127 gfx::Size thumbnail_size_;
136 GLuint program_; 128 GLuint program_;
137 base::TimeDelta frame_duration_; 129 base::TimeDelta frame_duration_;
138 130
139 DISALLOW_COPY_AND_ASSIGN(RenderingHelper); 131 DISALLOW_COPY_AND_ASSIGN(RenderingHelper);
140 }; 132 };
141 133
134 struct RenderingHelperParams {
135 RenderingHelperParams();
136 ~RenderingHelperParams();
137 int rendering_fps;
138
139 std::vector<base::WeakPtr<RenderingHelper::Client> > clients;
140 int num_windows;
141
142 // Dimensions of window(s) created for displaying frames. In the
143 // case of thumbnail rendering, these won't match the frame dimensions.
144 std::vector<gfx::Size> window_dimensions;
145 // Dimensions of video frame texture(s).
146 std::vector<gfx::Size> frame_dimensions;
147 // Whether the frames are rendered as scaled thumbnails within a
148 // larger FBO that is in turn rendered to the window.
149 bool render_as_thumbnails;
150 // The size of the FBO containing all visible thumbnails.
151 gfx::Size thumbnails_page_size;
152 // The size of each thumbnail within the FBO.
153 gfx::Size thumbnail_size;
154 };
142 } // namespace content 155 } // namespace content
143 156
144 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ 157 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698