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 #include "content/common/gpu/media/rendering_helper.h" | 5 #include "content/common/gpu/media/rendering_helper.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 virtual ~RenderingHelperEGL(); | 50 virtual ~RenderingHelperEGL(); |
51 | 51 |
52 // Implement RenderingHelper. | 52 // Implement RenderingHelper. |
53 virtual void Initialize(bool suppress_swap_to_display, | 53 virtual void Initialize(bool suppress_swap_to_display, |
54 int num_windows, | 54 int num_windows, |
55 int width, | 55 int width, |
56 int height, | 56 int height, |
57 base::WaitableEvent* done) OVERRIDE; | 57 base::WaitableEvent* done) OVERRIDE; |
58 virtual void UnInitialize(base::WaitableEvent* done) OVERRIDE; | 58 virtual void UnInitialize(base::WaitableEvent* done) OVERRIDE; |
59 virtual void CreateTexture(int window_id, | 59 virtual void CreateTexture(int window_id, |
| 60 int texture_target, |
60 uint32* texture_id, | 61 uint32* texture_id, |
61 base::WaitableEvent* done) OVERRIDE; | 62 base::WaitableEvent* done) OVERRIDE; |
62 virtual void RenderTexture(uint32 texture_id) OVERRIDE; | 63 virtual void RenderTexture(uint32 texture_id) OVERRIDE; |
63 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; | 64 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; |
64 virtual void* GetGLContext() OVERRIDE; | 65 virtual void* GetGLContext() OVERRIDE; |
65 virtual void* GetGLDisplay() OVERRIDE; | 66 virtual void* GetGLDisplay() OVERRIDE; |
66 | 67 |
67 private: | 68 private: |
68 void Clear(); | 69 void Clear(); |
69 | 70 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 EGL_NO_CONTEXT)) << eglGetError(); | 241 EGL_NO_CONTEXT)) << eglGetError(); |
241 CHECK(eglDestroyContext(egl_display_, egl_context_)); | 242 CHECK(eglDestroyContext(egl_display_, egl_context_)); |
242 for (size_t i = 0; i < egl_surfaces_.size(); ++i) | 243 for (size_t i = 0; i < egl_surfaces_.size(); ++i) |
243 CHECK(eglDestroySurface(egl_display_, egl_surfaces_[i])); | 244 CHECK(eglDestroySurface(egl_display_, egl_surfaces_[i])); |
244 CHECK(eglTerminate(egl_display_)); | 245 CHECK(eglTerminate(egl_display_)); |
245 Clear(); | 246 Clear(); |
246 done->Signal(); | 247 done->Signal(); |
247 } | 248 } |
248 | 249 |
249 void RenderingHelperEGL::CreateTexture(int window_id, | 250 void RenderingHelperEGL::CreateTexture(int window_id, |
| 251 int texture_target, |
250 uint32* texture_id, | 252 uint32* texture_id, |
251 base::WaitableEvent* done) { | 253 base::WaitableEvent* done) { |
252 if (MessageLoop::current() != message_loop_) { | 254 if (MessageLoop::current() != message_loop_) { |
253 message_loop_->PostTask( | 255 message_loop_->PostTask( |
254 FROM_HERE, | 256 FROM_HERE, |
255 base::Bind(&RenderingHelper::CreateTexture, base::Unretained(this), | 257 base::Bind(&RenderingHelper::CreateTexture, base::Unretained(this), |
256 window_id, texture_id, done)); | 258 window_id, texture_id, done)); |
257 return; | 259 return; |
258 } | 260 } |
| 261 CHECK_EQ(GL_TEXTURE_2D, texture_target); |
259 CHECK(eglMakeCurrent(egl_display_, egl_surfaces_[window_id], | 262 CHECK(eglMakeCurrent(egl_display_, egl_surfaces_[window_id], |
260 egl_surfaces_[window_id], egl_context_)) | 263 egl_surfaces_[window_id], egl_context_)) |
261 << eglGetError(); | 264 << eglGetError(); |
262 glGenTextures(1, texture_id); | 265 glGenTextures(1, texture_id); |
263 glBindTexture(GL_TEXTURE_2D, *texture_id); | 266 glBindTexture(GL_TEXTURE_2D, *texture_id); |
264 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width_, height_, 0, GL_RGBA, | 267 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width_, height_, 0, GL_RGBA, |
265 GL_UNSIGNED_BYTE, NULL); | 268 GL_UNSIGNED_BYTE, NULL); |
266 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 269 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
267 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 270 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
268 // OpenGLES2.0.25 section 3.8.2 requires CLAMP_TO_EDGE for NPOT textures. | 271 // OpenGLES2.0.25 section 3.8.2 requires CLAMP_TO_EDGE for NPOT textures. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 x_windows_.push_back(x_window); | 384 x_windows_.push_back(x_window); |
382 XStoreName(x_display_, x_window, "VideoDecodeAcceleratorTest"); | 385 XStoreName(x_display_, x_window, "VideoDecodeAcceleratorTest"); |
383 XSelectInput(x_display_, x_window, ExposureMask); | 386 XSelectInput(x_display_, x_window, ExposureMask); |
384 XMapWindow(x_display_, x_window); | 387 XMapWindow(x_display_, x_window); |
385 return x_window; | 388 return x_window; |
386 } | 389 } |
387 | 390 |
388 #endif // OS_WIN | 391 #endif // OS_WIN |
389 | 392 |
390 } // namespace video_test_util | 393 } // namespace video_test_util |
OLD | NEW |