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 |
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; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 86 |
84 // Get rendered thumbnails as RGB. | 87 // Get rendered thumbnails as RGB. |
85 // Sets alpha_solid to true if the alpha channel is entirely 0xff. | 88 // Sets alpha_solid to true if the alpha channel is entirely 0xff. |
86 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, | 89 void GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, |
87 bool* alpha_solid, | 90 bool* alpha_solid, |
88 base::WaitableEvent* done); | 91 base::WaitableEvent* done); |
89 | 92 |
90 private: | 93 private: |
91 void Clear(); | 94 void Clear(); |
92 | 95 |
93 // Make window_id's surface current w/ the GL context, or release the context | 96 void RenderContent(); |
94 // if |window_id < 0|. | 97 void DrawTexture(const gfx::Rect& area, |
95 void MakeCurrent(int window_id); | 98 uint32 texture_target, |
| 99 uint32 texture_id); |
96 | 100 |
| 101 // Timer to trigger the RenderContent() repeatly. |
| 102 base::RepeatingTimer<RenderingHelper> render_timer_; |
97 base::MessageLoop* message_loop_; | 103 base::MessageLoop* message_loop_; |
98 std::vector<gfx::Size> window_dimensions_; | |
99 std::vector<gfx::Size> frame_dimensions_; | 104 std::vector<gfx::Size> frame_dimensions_; |
100 | 105 |
101 NativeContextType gl_context_; | 106 NativeContextType gl_context_; |
102 std::map<uint32, int> texture_id_to_surface_index_; | 107 std::map<uint32, int> texture_id_to_surface_index_; |
103 | 108 |
104 #if defined(GL_VARIANT_EGL) | 109 #if defined(GL_VARIANT_EGL) |
105 EGLDisplay gl_display_; | 110 EGLDisplay gl_display_; |
106 std::vector<EGLSurface> gl_surfaces_; | 111 EGLSurface gl_surface_; |
107 #else | 112 #else |
108 XVisualInfo* x_visual_; | 113 XVisualInfo* x_visual_; |
109 #endif | 114 #endif |
110 | 115 |
111 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
112 std::vector<HWND> windows_; | 117 HWND window_; |
113 #else | 118 #else |
114 Display* x_display_; | 119 Display* x_display_; |
115 std::vector<Window> x_windows_; | 120 Window x_window_; |
116 #endif | 121 #endif |
117 | 122 |
| 123 // The rendering area of each window on the screen. |
| 124 std::vector<gfx::Rect> render_areas_; |
| 125 |
| 126 // The texture to be rendered on each window. |
| 127 std::vector<uint32> texture_ids_; |
| 128 std::vector<uint32> texture_targets_; |
| 129 |
118 bool render_as_thumbnails_; | 130 bool render_as_thumbnails_; |
119 int frame_count_; | 131 int frame_count_; |
120 GLuint thumbnails_fbo_id_; | 132 GLuint thumbnails_fbo_id_; |
121 GLuint thumbnails_texture_id_; | 133 GLuint thumbnails_texture_id_; |
122 gfx::Size thumbnails_fbo_size_; | 134 gfx::Size thumbnails_fbo_size_; |
123 gfx::Size thumbnail_size_; | 135 gfx::Size thumbnail_size_; |
124 GLuint program_; | 136 GLuint program_; |
| 137 base::TimeDelta frame_duration_; |
125 | 138 |
126 DISALLOW_COPY_AND_ASSIGN(RenderingHelper); | 139 DISALLOW_COPY_AND_ASSIGN(RenderingHelper); |
127 }; | 140 }; |
128 | 141 |
129 } // namespace content | 142 } // namespace content |
130 | 143 |
131 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ | 144 #endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ |
OLD | NEW |