| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/stringize_macros.h" | 10 #include "base/strings/stringize_macros.h" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
| 13 #include "ui/gl/gl_context_stub_with_extensions.h" | 13 #include "ui/gl/gl_context_stub_with_extensions.h" |
| 14 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
| 15 #include "ui/gl/gl_surface.h" | 15 #include "ui/gl/gl_surface.h" |
| 16 | 16 |
| 17 #if defined(USE_X11) |
| 18 #include "ui/gfx/x/x11_types.h" |
| 19 #endif |
| 20 |
| 17 #ifdef GL_VARIANT_GLX | 21 #ifdef GL_VARIANT_GLX |
| 18 typedef GLXWindow NativeWindowType; | 22 typedef GLXWindow NativeWindowType; |
| 19 struct XFreeDeleter { | 23 struct XFreeDeleter { |
| 20 void operator()(void* x) const { ::XFree(x); } | 24 void operator()(void* x) const { ::XFree(x); } |
| 21 }; | 25 }; |
| 22 #else // EGL | 26 #else // EGL |
| 23 typedef EGLNativeWindowType NativeWindowType; | 27 typedef EGLNativeWindowType NativeWindowType; |
| 24 #endif | 28 #endif |
| 25 | 29 |
| 26 // Helper for Shader creation. | 30 // Helper for Shader creation. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 109 |
| 106 CHECK_GT(params.window_dimensions.size(), 0U); | 110 CHECK_GT(params.window_dimensions.size(), 0U); |
| 107 CHECK_EQ(params.frame_dimensions.size(), params.window_dimensions.size()); | 111 CHECK_EQ(params.frame_dimensions.size(), params.window_dimensions.size()); |
| 108 window_dimensions_ = params.window_dimensions; | 112 window_dimensions_ = params.window_dimensions; |
| 109 frame_dimensions_ = params.frame_dimensions; | 113 frame_dimensions_ = params.frame_dimensions; |
| 110 render_as_thumbnails_ = params.render_as_thumbnails; | 114 render_as_thumbnails_ = params.render_as_thumbnails; |
| 111 message_loop_ = base::MessageLoop::current(); | 115 message_loop_ = base::MessageLoop::current(); |
| 112 CHECK_GT(params.num_windows, 0); | 116 CHECK_GT(params.num_windows, 0); |
| 113 | 117 |
| 114 #if GL_VARIANT_GLX | 118 #if GL_VARIANT_GLX |
| 115 x_display_ = base::MessagePumpForUI::GetDefaultXDisplay(); | 119 x_display_ = gfx::GetXDisplay(); |
| 116 CHECK(x_display_); | 120 CHECK(x_display_); |
| 117 CHECK(glXQueryVersion(x_display_, NULL, NULL)); | 121 CHECK(glXQueryVersion(x_display_, NULL, NULL)); |
| 118 const int fbconfig_attr[] = { | 122 const int fbconfig_attr[] = { |
| 119 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, | 123 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, |
| 120 GLX_RENDER_TYPE, GLX_RGBA_BIT, | 124 GLX_RENDER_TYPE, GLX_RGBA_BIT, |
| 121 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, | 125 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, |
| 122 GLX_BIND_TO_TEXTURE_RGB_EXT, GL_TRUE, | 126 GLX_BIND_TO_TEXTURE_RGB_EXT, GL_TRUE, |
| 123 GLX_DOUBLEBUFFER, True, | 127 GLX_DOUBLEBUFFER, True, |
| 124 GL_NONE, | 128 GL_NONE, |
| 125 }; | 129 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 137 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); | 141 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); |
| 138 stub_context->SetGLVersionString( | 142 stub_context->SetGLVersionString( |
| 139 reinterpret_cast<const char*>(glGetString(GL_VERSION))); | 143 reinterpret_cast<const char*>(glGetString(GL_VERSION))); |
| 140 | 144 |
| 141 #else // EGL | 145 #else // EGL |
| 142 EGLNativeDisplayType native_display; | 146 EGLNativeDisplayType native_display; |
| 143 | 147 |
| 144 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
| 145 native_display = EGL_DEFAULT_DISPLAY; | 149 native_display = EGL_DEFAULT_DISPLAY; |
| 146 #else | 150 #else |
| 147 x_display_ = base::MessagePumpForUI::GetDefaultXDisplay(); | 151 x_display_ = gfx::GetXDisplay(); |
| 148 CHECK(x_display_); | 152 CHECK(x_display_); |
| 149 native_display = x_display_; | 153 native_display = x_display_; |
| 150 #endif | 154 #endif |
| 151 | 155 |
| 152 gl_display_ = eglGetDisplay(native_display); | 156 gl_display_ = eglGetDisplay(native_display); |
| 153 CHECK(gl_display_); | 157 CHECK(gl_display_); |
| 154 CHECK(eglInitialize(gl_display_, NULL, NULL)) << glGetError(); | 158 CHECK(eglInitialize(gl_display_, NULL, NULL)) << glGetError(); |
| 155 | 159 |
| 156 static EGLint rgba8888[] = { | 160 static EGLint rgba8888[] = { |
| 157 EGL_RED_SIZE, 8, | 161 EGL_RED_SIZE, 8, |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 *rgb_ptr++ = *rgba_ptr++; | 561 *rgb_ptr++ = *rgba_ptr++; |
| 558 solid = solid && (*rgba_ptr == 0xff); | 562 solid = solid && (*rgba_ptr == 0xff); |
| 559 rgba_ptr++; | 563 rgba_ptr++; |
| 560 } | 564 } |
| 561 *alpha_solid = solid; | 565 *alpha_solid = solid; |
| 562 | 566 |
| 563 done->Signal(); | 567 done->Signal(); |
| 564 } | 568 } |
| 565 | 569 |
| 566 } // namespace content | 570 } // namespace content |
| OLD | NEW |