Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 15 matching lines...) Expand all Loading... | |
| 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(); | 34 RenderingHelperParams(); |
| 35 ~RenderingHelperParams(); | 35 ~RenderingHelperParams(); |
| 36 | 36 int rendering_fps; |
| 37 bool suppress_swap_to_display; | |
| 38 int num_windows; | 37 int num_windows; |
| 39 // Dimensions of window(s) created for displaying frames. In the | 38 // Dimensions of window(s) created for displaying frames. In the |
| 40 // case of thumbnail rendering, these won't match the frame dimensions. | 39 // case of thumbnail rendering, these won't match the frame dimensions. |
| 41 std::vector<gfx::Size> window_dimensions; | 40 std::vector<gfx::Size> window_dimensions; |
| 42 // Dimensions of video frame texture(s). | 41 // Dimensions of video frame texture(s). |
| 43 std::vector<gfx::Size> frame_dimensions; | 42 std::vector<gfx::Size> frame_dimensions; |
| 44 // Whether the frames are rendered as scaled thumbnails within a | 43 // Whether the frames are rendered as scaled thumbnails within a |
| 45 // larger FBO that is in turn rendered to the window. | 44 // larger FBO that is in turn rendered to the window. |
| 46 bool render_as_thumbnails; | 45 bool render_as_thumbnails; |
| 47 // The size of the FBO containing all visible thumbnails. | 46 // The size of the FBO containing all visible thumbnails. |
| 48 gfx::Size thumbnails_page_size; | 47 gfx::Size thumbnails_page_size; |
| 49 // The size of each thumbnail within the FBO. | 48 // The size of each thumbnail within the FBO. |
| 50 gfx::Size thumbnail_size; | 49 gfx::Size thumbnail_size; |
| 51 }; | 50 }; |
| 52 | 51 |
| 52 class RenderingHelper; | |
| 53 | |
| 54 class RenderingClient { | |
|
Ami GONE FROM CHROMIUM
2014/05/21 18:25:54
what is this?
(please document all classes, _espec
Owen Lin
2014/05/26 06:21:07
Done.
| |
| 55 public: | |
| 56 virtual void RenderContent(RenderingHelper* helper) = 0; | |
|
Ami GONE FROM CHROMIUM
2014/05/21 18:25:54
Prefer callbacks to interface types like this. E.
Owen Lin
2014/05/26 06:21:07
Moved into RenderingHelper.
I am going to add some
| |
| 57 protected: | |
| 58 virtual ~RenderingClient() {} | |
| 59 }; | |
| 53 | 60 |
| 54 // Creates and draws textures used by the video decoder. | 61 // Creates and draws textures used by the video decoder. |
|
Ami GONE FROM CHROMIUM
2014/05/21 18:25:54
"draws" is now a lie?
Comment needs updating.
Owen Lin
2014/05/26 06:21:07
This class is the one who really draws textures.
| |
| 55 // This class is not thread safe and thus all the methods of this class | 62 // This class is not thread safe and thus all the methods of this class |
| 56 // (except for ctor/dtor) ensure they're being run on a single thread. | 63 // (except for ctor/dtor) ensure they're being run on a single thread. |
| 57 class RenderingHelper { | 64 class RenderingHelper { |
| 58 public: | 65 public: |
| 59 RenderingHelper(); | 66 RenderingHelper(); |
| 60 ~RenderingHelper(); | 67 ~RenderingHelper(); |
| 61 | 68 |
| 62 // Create the render context and windows by the specified dimensions. | 69 // Create the render context and windows by the specified dimensions. |
| 63 void Initialize(const RenderingHelperParams& params, | 70 void Initialize(const RenderingHelperParams& params, |
| 64 base::WaitableEvent* done); | 71 base::WaitableEvent* done); |
| 65 | 72 |
| 66 // Undo the effects of Initialize() and signal |*done|. | 73 // Undo the effects of Initialize() and signal |*done|. |
| 67 void UnInitialize(base::WaitableEvent* done); | 74 void UnInitialize(base::WaitableEvent* done); |
| 68 | 75 |
| 76 void SetClient(int window_id, RenderingClient* client); | |
|
Ami GONE FROM CHROMIUM
2014/05/21 18:25:54
Would be easier to grok as a param to a once-only
Owen Lin
2014/05/26 06:21:07
Passed as the parameter of Initialize().
| |
| 77 | |
| 69 // Return a newly-created GLES2 texture id rendering to a specific window, and | 78 // Return a newly-created GLES2 texture id rendering to a specific window, and |
| 70 // signal |*done|. | 79 // signal |*done|. |
| 71 void CreateTexture(int window_id, | 80 void CreateTexture(int window_id, |
| 72 uint32 texture_target, | 81 uint32 texture_target, |
| 73 uint32* texture_id, | 82 uint32* texture_id, |
| 74 base::WaitableEvent* done); | 83 base::WaitableEvent* done); |
| 75 | 84 |
| 76 // Render |texture_id| to the screen using target |texture_target|. | 85 // Render thumbnail in the |texture_id| to the FBO buffer using target |
| 86 // |texture_target|. | |
| 87 void RenderThumbnail(uint32 texture_target, uint32 texture_id); | |
| 88 | |
| 89 // Render |texture_id| to the current view port of the screen using target | |
| 90 // |texture_target|. | |
| 77 void RenderTexture(uint32 texture_target, uint32 texture_id); | 91 void RenderTexture(uint32 texture_target, uint32 texture_id); |
| 78 | 92 |
| 79 // Delete |texture_id|. | 93 // Delete |texture_id|. |
| 80 void DeleteTexture(uint32 texture_id); | 94 void DeleteTexture(uint32 texture_id); |
| 81 | 95 |
| 82 // Get the platform specific handle to the OpenGL display. | 96 // Get the platform specific handle to the OpenGL display. |
| 83 void* GetGLDisplay(); | 97 void* GetGLDisplay(); |
| 84 | 98 |
| 85 // Get the platform specific handle to the OpenGL context. | 99 // Get the platform specific handle to the OpenGL context. |
| 86 NativeContextType GetGLContext(); | 100 NativeContextType GetGLContext(); |
| 87 | 101 |
| 88 // Get rendered thumbnails as RGB. | 102 // Get rendered thumbnails as RGB. |
| 89 // Sets alpha_solid to true if the alpha channel is entirely 0xff. | 103 // Sets alpha_solid to true if the alpha channel is entirely 0xff. |
| 90 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, | 104 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, |
| 91 bool* alpha_solid, | 105 bool* alpha_solid, |
| 92 base::WaitableEvent* done); | 106 base::WaitableEvent* done); |
| 93 | 107 |
| 94 private: | 108 private: |
| 95 void Clear(); | 109 void Clear(); |
| 96 | 110 |
| 97 void RenderContent(); | 111 void RenderContent(); |
| 98 void DrawTexture(const gfx::Rect &area, | |
| 99 uint32 texture_target, | |
| 100 uint32 texture_id); | |
| 101 | |
| 102 base::RepeatingTimer<RenderingHelper> render_timer_; | 112 base::RepeatingTimer<RenderingHelper> render_timer_; |
| 103 base::MessageLoop* message_loop_; | 113 base::MessageLoop* message_loop_; |
| 104 std::vector<gfx::Size> frame_dimensions_; | 114 std::vector<gfx::Size> frame_dimensions_; |
| 105 | 115 |
| 106 NativeContextType gl_context_; | 116 NativeContextType gl_context_; |
| 107 std::map<uint32, int> texture_id_to_surface_index_; | 117 std::map<uint32, int> texture_id_to_surface_index_; |
| 108 | 118 |
| 109 #if defined(GL_VARIANT_EGL) | 119 #if defined(GL_VARIANT_EGL) |
| 110 EGLDisplay gl_display_; | 120 EGLDisplay gl_display_; |
| 111 EGLSurface gl_surface_; | 121 EGLSurface gl_surface_; |
| 112 #else | 122 #else |
| 113 XVisualInfo* x_visual_; | 123 XVisualInfo* x_visual_; |
| 114 #endif | 124 #endif |
| 115 | 125 |
| 116 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
| 117 HWND window_; | 127 HWND window_; |
| 118 #else | 128 #else |
| 119 Display* x_display_; | 129 Display* x_display_; |
| 120 Window x_window_; | 130 Window x_window_; |
| 121 #endif | 131 #endif |
| 122 | 132 |
| 123 // The rendering area of each window on the screen. | 133 // The rendering area of each window on the screen. |
| 124 std::vector<gfx::Rect> render_areas_; | 134 std::vector<gfx::Rect> render_areas_; |
| 125 | 135 |
| 126 // The texture to be rendered on each window. | 136 std::vector<RenderingClient*> clients_; |
| 127 std::vector<uint32> texture_ids_; | |
| 128 std::vector<uint32> texture_targets_; | |
| 129 | 137 |
| 130 bool render_as_thumbnails_; | 138 bool render_as_thumbnails_; |
| 131 int frame_count_; | 139 int frame_count_; |
| 132 GLuint thumbnails_fbo_id_; | 140 GLuint thumbnails_fbo_id_; |
| 133 GLuint thumbnails_texture_id_; | 141 GLuint thumbnails_texture_id_; |
| 134 gfx::Size thumbnails_fbo_size_; | 142 gfx::Size thumbnails_fbo_size_; |
| 135 gfx::Size thumbnail_size_; | 143 gfx::Size thumbnail_size_; |
| 136 GLuint program_; | 144 GLuint program_; |
| 137 base::TimeDelta frame_duration_; | 145 base::TimeDelta frame_duration_; |
| 138 | 146 |
| 139 DISALLOW_COPY_AND_ASSIGN(RenderingHelper); | 147 DISALLOW_COPY_AND_ASSIGN(RenderingHelper); |
| 140 }; | 148 }; |
| 141 | 149 |
| 142 } // namespace content | 150 } // namespace content |
| 143 | 151 |
| 144 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ | 152 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ |
| OLD | NEW |