| 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 "media/tools/player_x11/gl_video_renderer.h" | 5 #include "media/tools/player_x11/gl_video_renderer.h" |
| 6 | 6 |
| 7 #include <X11/Xutil.h> | 7 #include <X11/Xutil.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, | 133 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, |
| 134 GL_LUMINANCE, GL_UNSIGNED_BYTE, video_frame->data(i)); | 134 GL_LUMINANCE, GL_UNSIGNED_BYTE, video_frame->data(i)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 137 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
| 138 glXSwapBuffers(display_, window_); | 138 glXSwapBuffers(display_, window_); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void GlVideoRenderer::Initialize(gfx::Size coded_size, gfx::Rect visible_rect) { | 141 void GlVideoRenderer::Initialize(gfx::Size coded_size, gfx::Rect visible_rect) { |
| 142 CHECK(!gl_context_); | 142 CHECK(!gl_context_); |
| 143 LOG(INFO) << "Initializing GL Renderer..."; | 143 VLOG(0) << "Initializing GL Renderer..."; |
| 144 | 144 |
| 145 // Resize the window to fit that of the video. | 145 // Resize the window to fit that of the video. |
| 146 XResizeWindow(display_, window_, visible_rect.width(), visible_rect.height()); | 146 XResizeWindow(display_, window_, visible_rect.width(), visible_rect.height()); |
| 147 | 147 |
| 148 gl_context_ = InitGLContext(display_, window_); | 148 gl_context_ = InitGLContext(display_, window_); |
| 149 CHECK(gl_context_) << "Failed to initialize GL context"; | 149 CHECK(gl_context_) << "Failed to initialize GL context"; |
| 150 | 150 |
| 151 // Create 3 textures, one for each plane, and bind them to different | 151 // Create 3 textures, one for each plane, and bind them to different |
| 152 // texture units. | 152 // texture units. |
| 153 glGenTextures(3, textures_); | 153 glGenTextures(3, textures_); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 verts[0] = x0; verts[1] = y0; | 240 verts[0] = x0; verts[1] = y0; |
| 241 verts[2] = x0; verts[3] = y1; | 241 verts[2] = x0; verts[3] = y1; |
| 242 verts[4] = x1; verts[5] = y0; | 242 verts[4] = x1; verts[5] = y0; |
| 243 verts[6] = x1; verts[7] = y1; | 243 verts[6] = x1; verts[7] = y1; |
| 244 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, verts); | 244 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, verts); |
| 245 | 245 |
| 246 // We are getting called on a thread. Release the context so that it can be | 246 // We are getting called on a thread. Release the context so that it can be |
| 247 // made current on the main thread. | 247 // made current on the main thread. |
| 248 glXMakeCurrent(display_, 0, NULL); | 248 glXMakeCurrent(display_, 0, NULL); |
| 249 } | 249 } |
| OLD | NEW |