OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/common/gpu/media/rendering_helper.h" | 5 #include "content/common/gpu/media/rendering_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <numeric> | 8 #include <numeric> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/mac/scoped_nsautorelease_pool.h" | 14 #include "base/mac/scoped_nsautorelease_pool.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/strings/stringize_macros.h" | 16 #include "base/strings/stringize_macros.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "ui/gl/gl_context.h" | 19 #include "ui/gl/gl_context.h" |
20 #include "ui/gl/gl_implementation.h" | 20 #include "ui/gl/gl_implementation.h" |
21 #include "ui/gl/gl_surface.h" | 21 #include "ui/gl/gl_surface.h" |
22 #include "ui/gl/gl_surface_egl.h" | |
23 #include "ui/gl/gl_surface_glx.h" | |
24 | 22 |
25 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
26 #include <windows.h> | 24 #include <windows.h> |
27 #endif | 25 #endif |
28 | 26 |
29 #if defined(USE_X11) | 27 #if defined(USE_X11) |
30 #include "ui/gfx/x/x11_types.h" | 28 #include "ui/gfx/x/x11_types.h" |
31 #endif | 29 #endif |
32 | 30 |
33 #if !defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY) | 31 #if defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
32 #include "ui/gl/gl_surface_glx.h" | |
34 #define GL_VARIANT_GLX 1 | 33 #define GL_VARIANT_GLX 1 |
35 #else | 34 #else |
35 #include "ui/gl/gl_surface_egl.h" | |
36 #define GL_VARIANT_EGL 1 | 36 #define GL_VARIANT_EGL 1 |
37 #endif | 37 #endif |
38 | 38 |
39 #if defined(USE_OZONE) | |
40 #if defined(OS_CHROMEOS) | |
41 #include "ui/display/chromeos/display_configurator.h" | |
42 #endif | |
43 #include "ui/ozone/public/ozone_platform.h" | |
44 #include "ui/ozone/public/ui_thread_gpu.h" | |
45 #include "ui/platform_window/platform_window.h" | |
46 #include "ui/platform_window/platform_window_delegate.h" | |
47 #endif | |
48 | |
39 // Helper for Shader creation. | 49 // Helper for Shader creation. |
40 static void CreateShader(GLuint program, | 50 static void CreateShader(GLuint program, |
41 GLenum type, | 51 GLenum type, |
42 const char* source, | 52 const char* source, |
43 int size) { | 53 int size) { |
44 GLuint shader = glCreateShader(type); | 54 GLuint shader = glCreateShader(type); |
45 glShaderSource(shader, 1, &source, &size); | 55 glShaderSource(shader, 1, &source, &size); |
46 glCompileShader(shader); | 56 glCompileShader(shader); |
47 int result = GL_FALSE; | 57 int result = GL_FALSE; |
48 glGetShaderiv(shader, GL_COMPILE_STATUS, &result); | 58 glGetShaderiv(shader, GL_COMPILE_STATUS, &result); |
49 if (!result) { | 59 if (!result) { |
50 char log[4096]; | 60 char log[4096]; |
51 glGetShaderInfoLog(shader, arraysize(log), NULL, log); | 61 glGetShaderInfoLog(shader, arraysize(log), NULL, log); |
52 LOG(FATAL) << log; | 62 LOG(FATAL) << log; |
53 } | 63 } |
54 glAttachShader(program, shader); | 64 glAttachShader(program, shader); |
55 glDeleteShader(shader); | 65 glDeleteShader(shader); |
56 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); | 66 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); |
57 } | 67 } |
58 | 68 |
59 namespace content { | 69 namespace content { |
60 | 70 |
71 #if defined(USE_OZONE) | |
72 | |
73 class RenderingHelper::StubOzoneDelegate : public ui::PlatformWindowDelegate { | |
74 public: | |
75 StubOzoneDelegate() : widget_(gfx::kNullAcceleratedWidget) { | |
76 ui_thread_gpu_.Initialize(); | |
77 platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow( | |
78 this, gfx::Rect()); | |
79 } | |
80 virtual ~StubOzoneDelegate() {} | |
scherkus (not reviewing)
2014/12/10 18:56:48
IIRC this should be override and we can drop virtu
llandwerlin-old
2014/12/13 15:23:53
Done.
| |
81 | |
82 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) override {} | |
83 | |
84 virtual void OnDamageRect(const gfx::Rect& damaged_region) override {} | |
85 | |
86 virtual void DispatchEvent(ui::Event* event) override {} | |
87 | |
88 virtual void OnCloseRequest() override {} | |
89 virtual void OnClosed() override {} | |
90 | |
91 virtual void OnWindowStateChanged( | |
92 ui::PlatformWindowState new_state) override {}; | |
93 | |
94 virtual void OnLostCapture() override {}; | |
95 | |
96 virtual void OnAcceleratedWidgetAvailable( | |
97 gfx::AcceleratedWidget widget) override { | |
98 widget_ = widget; | |
99 }; | |
100 | |
101 virtual void OnActivationChanged(bool active) override {}; | |
102 | |
103 gfx::AcceleratedWidget GetAcceleratedWidget() const { return widget_; } | |
scherkus (not reviewing)
2014/12/10 18:56:48
nit: for these types of accessors they should be u
llandwerlin-old
2014/12/13 15:23:53
Done.
| |
104 | |
105 gfx::Size GetSize() { return platform_window_->GetBounds().size(); } | |
106 | |
107 ui::PlatformWindow* platform_window() const { return platform_window_.get(); } | |
108 | |
109 private: | |
110 ui::UiThreadGpu ui_thread_gpu_; | |
111 scoped_ptr<ui::PlatformWindow> platform_window_; | |
112 gfx::AcceleratedWidget widget_; | |
113 }; | |
scherkus (not reviewing)
2014/12/10 18:56:48
DISALLOW etc...
llandwerlin-old
2014/12/13 15:23:53
Done.
| |
114 | |
115 #endif // defined(USE_OZONE) | |
116 | |
61 RenderingHelperParams::RenderingHelperParams() | 117 RenderingHelperParams::RenderingHelperParams() |
62 : rendering_fps(0), warm_up_iterations(0), render_as_thumbnails(false) { | 118 : rendering_fps(0), warm_up_iterations(0), render_as_thumbnails(false) { |
63 } | 119 } |
64 | 120 |
65 RenderingHelperParams::~RenderingHelperParams() {} | 121 RenderingHelperParams::~RenderingHelperParams() {} |
66 | 122 |
67 VideoFrameTexture::VideoFrameTexture(uint32 texture_target, | 123 VideoFrameTexture::VideoFrameTexture(uint32 texture_target, |
68 uint32 texture_id, | 124 uint32 texture_id, |
69 const base::Closure& no_longer_needed_cb) | 125 const base::Closure& no_longer_needed_cb) |
70 : texture_target_(texture_target), | 126 : texture_target_(texture_target), |
(...skipping 15 matching lines...) Expand all Loading... | |
86 | 142 |
87 // static | 143 // static |
88 bool RenderingHelper::InitializeOneOff() { | 144 bool RenderingHelper::InitializeOneOff() { |
89 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 145 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
90 #if GL_VARIANT_GLX | 146 #if GL_VARIANT_GLX |
91 cmd_line->AppendSwitchASCII(switches::kUseGL, | 147 cmd_line->AppendSwitchASCII(switches::kUseGL, |
92 gfx::kGLImplementationDesktopName); | 148 gfx::kGLImplementationDesktopName); |
93 #else | 149 #else |
94 cmd_line->AppendSwitchASCII(switches::kUseGL, gfx::kGLImplementationEGLName); | 150 cmd_line->AppendSwitchASCII(switches::kUseGL, gfx::kGLImplementationEGLName); |
95 #endif | 151 #endif |
152 | |
153 #if defined(USE_OZONE) | |
154 ui::OzonePlatform::InitializeForUI(); | |
155 #endif | |
96 return gfx::GLSurface::InitializeOneOff(); | 156 return gfx::GLSurface::InitializeOneOff(); |
97 } | 157 } |
98 | 158 |
99 RenderingHelper::RenderingHelper() { | 159 RenderingHelper::RenderingHelper() { |
100 window_ = gfx::kNullAcceleratedWidget; | 160 window_ = gfx::kNullAcceleratedWidget; |
101 Clear(); | 161 Clear(); |
102 } | 162 } |
103 | 163 |
104 RenderingHelper::~RenderingHelper() { | 164 RenderingHelper::~RenderingHelper() { |
105 CHECK_EQ(videos_.size(), 0U) << "Must call UnInitialize before dtor."; | 165 CHECK_EQ(videos_.size(), 0U) << "Must call UnInitialize before dtor."; |
(...skipping 14 matching lines...) Expand all Loading... | |
120 base::Bind(&RenderingHelper::RenderContent, base::Unretained(this))); | 180 base::Bind(&RenderingHelper::RenderContent, base::Unretained(this))); |
121 | 181 |
122 frame_duration_ = params.rendering_fps > 0 | 182 frame_duration_ = params.rendering_fps > 0 |
123 ? base::TimeDelta::FromSeconds(1) / params.rendering_fps | 183 ? base::TimeDelta::FromSeconds(1) / params.rendering_fps |
124 : base::TimeDelta(); | 184 : base::TimeDelta(); |
125 | 185 |
126 render_as_thumbnails_ = params.render_as_thumbnails; | 186 render_as_thumbnails_ = params.render_as_thumbnails; |
127 message_loop_ = base::MessageLoop::current(); | 187 message_loop_ = base::MessageLoop::current(); |
128 | 188 |
129 #if defined(OS_WIN) | 189 #if defined(OS_WIN) |
130 screen_size_ = | |
131 gfx::Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); | |
132 window_ = CreateWindowEx(0, | 190 window_ = CreateWindowEx(0, |
133 L"Static", | 191 L"Static", |
134 L"VideoDecodeAcceleratorTest", | 192 L"VideoDecodeAcceleratorTest", |
135 WS_OVERLAPPEDWINDOW | WS_VISIBLE, | 193 WS_OVERLAPPEDWINDOW | WS_VISIBLE, |
136 0, | 194 0, |
137 0, | 195 0, |
138 screen_size_.width(), | 196 GetSystemMetrics(SM_CXSCREEN), |
139 screen_size_.height(), | 197 GetSystemMetrics(SM_CYSCREEN), |
140 NULL, | 198 NULL, |
141 NULL, | 199 NULL, |
142 NULL, | 200 NULL, |
143 NULL); | 201 NULL); |
144 #elif defined(USE_X11) | 202 #elif defined(USE_X11) |
145 Display* display = gfx::GetXDisplay(); | 203 Display* display = gfx::GetXDisplay(); |
146 Screen* screen = DefaultScreenOfDisplay(display); | 204 Screen* screen = DefaultScreenOfDisplay(display); |
147 screen_size_ = gfx::Size(XWidthOfScreen(screen), XHeightOfScreen(screen)); | |
148 | 205 |
149 CHECK(display); | 206 CHECK(display); |
150 | 207 |
151 XSetWindowAttributes window_attributes; | 208 XSetWindowAttributes window_attributes; |
152 memset(&window_attributes, 0, sizeof(window_attributes)); | 209 memset(&window_attributes, 0, sizeof(window_attributes)); |
153 window_attributes.background_pixel = | 210 window_attributes.background_pixel = |
154 BlackPixel(display, DefaultScreen(display)); | 211 BlackPixel(display, DefaultScreen(display)); |
155 window_attributes.override_redirect = true; | 212 window_attributes.override_redirect = true; |
156 int depth = DefaultDepth(display, DefaultScreen(display)); | 213 int depth = DefaultDepth(display, DefaultScreen(display)); |
157 | 214 |
158 window_ = XCreateWindow(display, | 215 window_ = XCreateWindow(display, |
159 DefaultRootWindow(display), | 216 DefaultRootWindow(display), |
160 0, | 217 0, |
161 0, | 218 0, |
162 screen_size_.width(), | 219 XWidthOfScreen(screen), |
163 screen_size_.height(), | 220 XHeightOfScreen(screen), |
164 0 /* border width */, | 221 0 /* border width */, |
165 depth, | 222 depth, |
166 CopyFromParent /* class */, | 223 CopyFromParent /* class */, |
167 CopyFromParent /* visual */, | 224 CopyFromParent /* visual */, |
168 (CWBackPixel | CWOverrideRedirect), | 225 (CWBackPixel | CWOverrideRedirect), |
169 &window_attributes); | 226 &window_attributes); |
170 XStoreName(display, window_, "VideoDecodeAcceleratorTest"); | 227 XStoreName(display, window_, "VideoDecodeAcceleratorTest"); |
171 XSelectInput(display, window_, ExposureMask); | 228 XSelectInput(display, window_, ExposureMask); |
172 XMapWindow(display, window_); | 229 XMapWindow(display, window_); |
230 #elif defined(USE_OZONE) | |
231 platform_window_delegate_.reset(new RenderingHelper::StubOzoneDelegate()); | |
232 window_ = platform_window_delegate_->GetAcceleratedWidget(); | |
233 #if defined(OS_CHROMEOS) | |
234 display_configurator_.reset(new ui::DisplayConfigurator()); | |
235 display_configurator_->Init(true); | |
236 display_configurator_->ForceInitialConfigure(0); | |
237 platform_window_delegate_->platform_window()->SetBounds( | |
238 gfx::Rect(display_configurator_->framebuffer_size())); | |
239 #else | |
240 platform_window_delegate_->platform_window()->SetBounds(gfx::Rect(800, 600)); | |
241 #endif | |
173 #else | 242 #else |
174 #error unknown platform | 243 #error unknown platform |
175 #endif | 244 #endif |
176 CHECK(window_ != gfx::kNullAcceleratedWidget); | 245 CHECK(window_ != gfx::kNullAcceleratedWidget); |
177 | 246 |
178 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(window_); | 247 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(window_); |
248 screen_size_ = gl_surface_->GetSize(); | |
249 | |
179 gl_context_ = gfx::GLContext::CreateGLContext( | 250 gl_context_ = gfx::GLContext::CreateGLContext( |
180 NULL, gl_surface_.get(), gfx::PreferIntegratedGpu); | 251 NULL, gl_surface_.get(), gfx::PreferIntegratedGpu); |
181 gl_context_->MakeCurrent(gl_surface_.get()); | 252 CHECK(gl_context_->MakeCurrent(gl_surface_.get())); |
182 | 253 |
183 CHECK_GT(params.window_sizes.size(), 0U); | 254 CHECK_GT(params.window_sizes.size(), 0U); |
184 videos_.resize(params.window_sizes.size()); | 255 videos_.resize(params.window_sizes.size()); |
185 LayoutRenderingAreas(params.window_sizes); | 256 LayoutRenderingAreas(params.window_sizes); |
186 | 257 |
187 if (render_as_thumbnails_) { | 258 if (render_as_thumbnails_) { |
188 CHECK_EQ(videos_.size(), 1U); | 259 CHECK_EQ(videos_.size(), 1U); |
189 | 260 |
190 GLint max_texture_size; | 261 GLint max_texture_size; |
191 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); | 262 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 if (tex_external != -1) { | 368 if (tex_external != -1) { |
298 glUniform1i(tex_external, 1); | 369 glUniform1i(tex_external, 1); |
299 } | 370 } |
300 int pos_location = glGetAttribLocation(program_, "in_pos"); | 371 int pos_location = glGetAttribLocation(program_, "in_pos"); |
301 glEnableVertexAttribArray(pos_location); | 372 glEnableVertexAttribArray(pos_location); |
302 glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices); | 373 glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices); |
303 int tc_location = glGetAttribLocation(program_, "in_tc"); | 374 int tc_location = glGetAttribLocation(program_, "in_tc"); |
304 glEnableVertexAttribArray(tc_location); | 375 glEnableVertexAttribArray(tc_location); |
305 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords); | 376 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords); |
306 | 377 |
307 if (frame_duration_ != base::TimeDelta()) | 378 if (frame_duration_ != base::TimeDelta()) { |
308 WarmUpRendering(params.warm_up_iterations); | 379 int warm_up_iterations = params.warm_up_iterations; |
380 #if defined(USE_OZONE) | |
381 // On Ozone the VSyncProvider can't provide a vsync_internal until | |
382 // we render at least a frame, so we warm up with at least one | |
383 // frame. | |
384 // On top of this, we want to make sure all the buffers backing | |
385 // the GL surface are cleared, otherwise we can see the previous | |
386 // test's last frames, so we set warm up iterations to 2, to clear | |
387 // the front and back buffers. | |
388 warm_up_iterations = std::max(2, warm_up_iterations); | |
389 #endif | |
390 WarmUpRendering(warm_up_iterations); | |
391 } | |
309 | 392 |
310 // It's safe to use Unretained here since |rendering_thread_| will be stopped | 393 // It's safe to use Unretained here since |rendering_thread_| will be stopped |
311 // in VideoDecodeAcceleratorTest.TearDown(), while the |rendering_helper_| is | 394 // in VideoDecodeAcceleratorTest.TearDown(), while the |rendering_helper_| is |
312 // a member of that class. (See video_decode_accelerator_unittest.cc.) | 395 // a member of that class. (See video_decode_accelerator_unittest.cc.) |
313 gfx::VSyncProvider* vsync_provider = gl_surface_->GetVSyncProvider(); | 396 gfx::VSyncProvider* vsync_provider = gl_surface_->GetVSyncProvider(); |
314 if (vsync_provider) | 397 if (vsync_provider && frame_duration_ != base::TimeDelta()) |
315 vsync_provider->GetVSyncParameters(base::Bind( | 398 vsync_provider->GetVSyncParameters(base::Bind( |
316 &RenderingHelper::UpdateVSyncParameters, base::Unretained(this), done)); | 399 &RenderingHelper::UpdateVSyncParameters, base::Unretained(this), done)); |
317 else | 400 else |
318 done->Signal(); | 401 done->Signal(); |
319 } | 402 } |
320 | 403 |
321 // The rendering for the first few frames is slow (e.g., 100ms on Peach Pit). | 404 // The rendering for the first few frames is slow (e.g., 100ms on Peach Pit). |
322 // This affects the numbers measured in the performance test. We try to render | 405 // This affects the numbers measured in the performance test. We try to render |
323 // several frames here to warm up the rendering. | 406 // several frames here to warm up the rendering. |
324 void RenderingHelper::WarmUpRendering(int warm_up_iterations) { | 407 void RenderingHelper::WarmUpRendering(int warm_up_iterations) { |
325 unsigned int texture_id; | 408 unsigned int texture_id; |
326 scoped_ptr<GLubyte[]> emptyData(new GLubyte[screen_size_.GetArea() * 2]); | 409 scoped_ptr<GLubyte[]> emptyData(new GLubyte[screen_size_.GetArea() * 2]()); |
327 glGenTextures(1, &texture_id); | 410 glGenTextures(1, &texture_id); |
328 glBindTexture(GL_TEXTURE_2D, texture_id); | 411 glBindTexture(GL_TEXTURE_2D, texture_id); |
329 glTexImage2D(GL_TEXTURE_2D, | 412 glTexImage2D(GL_TEXTURE_2D, |
330 0, | 413 0, |
331 GL_RGB, | 414 GL_RGB, |
332 screen_size_.width(), | 415 screen_size_.width(), |
333 screen_size_.height(), | 416 screen_size_.height(), |
334 0, | 417 0, |
335 GL_RGB, | 418 GL_RGB, |
336 GL_UNSIGNED_SHORT_5_6_5, | 419 GL_UNSIGNED_SHORT_5_6_5, |
337 emptyData.get()); | 420 emptyData.get()); |
338 for (int i = 0; i < warm_up_iterations; ++i) { | 421 for (int i = 0; i < warm_up_iterations; ++i) { |
339 RenderTexture(GL_TEXTURE_2D, texture_id); | 422 RenderTexture(GL_TEXTURE_2D, texture_id); |
340 gl_surface_->SwapBuffers(); | 423 gl_surface_->SwapBuffers(); |
341 } | 424 } |
342 glDeleteTextures(1, &texture_id); | 425 glDeleteTextures(1, &texture_id); |
343 } | 426 } |
344 | 427 |
345 void RenderingHelper::UnInitialize(base::WaitableEvent* done) { | 428 void RenderingHelper::UnInitialize(base::WaitableEvent* done) { |
346 CHECK_EQ(base::MessageLoop::current(), message_loop_); | 429 CHECK_EQ(base::MessageLoop::current(), message_loop_); |
347 | 430 |
431 #if defined(USE_OZONE) && defined(OS_CHROMEOS) | |
432 display_configurator_->PrepareForExit(); | |
433 #endif | |
434 | |
348 render_task_.Cancel(); | 435 render_task_.Cancel(); |
349 | 436 |
350 if (render_as_thumbnails_) { | 437 if (render_as_thumbnails_) { |
351 glDeleteTextures(1, &thumbnails_texture_id_); | 438 glDeleteTextures(1, &thumbnails_texture_id_); |
352 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_); | 439 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_); |
353 } | 440 } |
354 | 441 |
355 gl_context_->ReleaseCurrent(gl_surface_.get()); | 442 gl_context_->ReleaseCurrent(gl_surface_.get()); |
356 gl_context_ = NULL; | 443 gl_context_ = NULL; |
357 gl_surface_ = NULL; | 444 gl_surface_ = NULL; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 glBindTexture(texture_target, 0); | 547 glBindTexture(texture_target, 0); |
461 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); | 548 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); |
462 } | 549 } |
463 | 550 |
464 void RenderingHelper::DeleteTexture(uint32 texture_id) { | 551 void RenderingHelper::DeleteTexture(uint32 texture_id) { |
465 CHECK_EQ(base::MessageLoop::current(), message_loop_); | 552 CHECK_EQ(base::MessageLoop::current(), message_loop_); |
466 glDeleteTextures(1, &texture_id); | 553 glDeleteTextures(1, &texture_id); |
467 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); | 554 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); |
468 } | 555 } |
469 | 556 |
470 void* RenderingHelper::GetGLContext() { | 557 scoped_refptr<gfx::GLContext> RenderingHelper::GetGLContext() { |
558 return gl_context_; | |
559 } | |
560 | |
561 void* RenderingHelper::GetGLContextHandle() { | |
471 return gl_context_->GetHandle(); | 562 return gl_context_->GetHandle(); |
472 } | 563 } |
473 | 564 |
474 void* RenderingHelper::GetGLDisplay() { | 565 void* RenderingHelper::GetGLDisplay() { |
475 return gl_surface_->GetDisplay(); | 566 return gl_surface_->GetDisplay(); |
476 } | 567 } |
477 | 568 |
478 void RenderingHelper::Clear() { | 569 void RenderingHelper::Clear() { |
479 videos_.clear(); | 570 videos_.clear(); |
480 message_loop_ = NULL; | 571 message_loop_ = NULL; |
481 gl_context_ = NULL; | 572 gl_context_ = NULL; |
482 gl_surface_ = NULL; | 573 gl_surface_ = NULL; |
483 | 574 |
484 render_as_thumbnails_ = false; | 575 render_as_thumbnails_ = false; |
485 frame_count_ = 0; | 576 frame_count_ = 0; |
486 thumbnails_fbo_id_ = 0; | 577 thumbnails_fbo_id_ = 0; |
487 thumbnails_texture_id_ = 0; | 578 thumbnails_texture_id_ = 0; |
488 | 579 |
489 #if defined(OS_WIN) | 580 #if defined(OS_WIN) |
490 if (window_) | 581 if (window_) |
491 DestroyWindow(window_); | 582 DestroyWindow(window_); |
492 #else | 583 #elif defined(USE_X11) |
493 // Destroy resources acquired in Initialize, in reverse-acquisition order. | 584 // Destroy resources acquired in Initialize, in reverse-acquisition order. |
494 if (window_) { | 585 if (window_) { |
495 CHECK(XUnmapWindow(gfx::GetXDisplay(), window_)); | 586 CHECK(XUnmapWindow(gfx::GetXDisplay(), window_)); |
496 CHECK(XDestroyWindow(gfx::GetXDisplay(), window_)); | 587 CHECK(XDestroyWindow(gfx::GetXDisplay(), window_)); |
497 } | 588 } |
589 #elif defined(USE_OZONE) | |
590 platform_window_delegate_.reset(); | |
498 #endif | 591 #endif |
499 window_ = gfx::kNullAcceleratedWidget; | 592 window_ = gfx::kNullAcceleratedWidget; |
500 } | 593 } |
501 | 594 |
502 void RenderingHelper::GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, | 595 void RenderingHelper::GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, |
503 bool* alpha_solid, | 596 bool* alpha_solid, |
504 base::WaitableEvent* done) { | 597 base::WaitableEvent* done) { |
505 CHECK(render_as_thumbnails_); | 598 CHECK(render_as_thumbnails_); |
506 | 599 |
507 const size_t num_pixels = thumbnails_fbo_size_.GetArea(); | 600 const size_t num_pixels = thumbnails_fbo_size_.GetArea(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
687 // When the rendering falls behind, drops frames. | 780 // When the rendering falls behind, drops frames. |
688 while (scheduled_render_time_ < target) { | 781 while (scheduled_render_time_ < target) { |
689 scheduled_render_time_ += frame_duration_; | 782 scheduled_render_time_ += frame_duration_; |
690 DropOneFrameForAllVideos(); | 783 DropOneFrameForAllVideos(); |
691 } | 784 } |
692 | 785 |
693 message_loop_->PostDelayedTask( | 786 message_loop_->PostDelayedTask( |
694 FROM_HERE, render_task_.callback(), target - now); | 787 FROM_HERE, render_task_.callback(), target - now); |
695 } | 788 } |
696 } // namespace content | 789 } // namespace content |
OLD | NEW |