| 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.h" | 10 #include "base/message_loop.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 gl_context_(NULL) { | 114 gl_context_(NULL) { |
| 115 } | 115 } |
| 116 | 116 |
| 117 GlVideoRenderer::~GlVideoRenderer() { | 117 GlVideoRenderer::~GlVideoRenderer() { |
| 118 glXMakeCurrent(display_, 0, NULL); | 118 glXMakeCurrent(display_, 0, NULL); |
| 119 glXDestroyContext(display_, gl_context_); | 119 glXDestroyContext(display_, gl_context_); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void GlVideoRenderer::Paint(media::VideoFrame* video_frame) { | 122 void GlVideoRenderer::Paint(media::VideoFrame* video_frame) { |
| 123 if (!gl_context_) | 123 if (!gl_context_) |
| 124 Initialize(video_frame->width(), video_frame->height()); | 124 Initialize(video_frame->data_size().width(), |
| 125 video_frame->data_size().height()); |
| 125 | 126 |
| 126 // Convert YUV frame to RGB. | 127 // Convert YUV frame to RGB. |
| 127 DCHECK(video_frame->format() == media::VideoFrame::YV12 || | 128 DCHECK(video_frame->format() == media::VideoFrame::YV12 || |
| 128 video_frame->format() == media::VideoFrame::YV16); | 129 video_frame->format() == media::VideoFrame::YV16); |
| 129 DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == | 130 DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == |
| 130 video_frame->stride(media::VideoFrame::kVPlane)); | 131 video_frame->stride(media::VideoFrame::kVPlane)); |
| 131 | 132 |
| 132 if (glXGetCurrentContext() != gl_context_ || | 133 if (glXGetCurrentContext() != gl_context_ || |
| 133 glXGetCurrentDrawable() != window_) { | 134 glXGetCurrentDrawable() != window_) { |
| 134 glXMakeCurrent(display_, window_, gl_context_); | 135 glXMakeCurrent(display_, window_, gl_context_); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 241 |
| 241 int tc_location = glGetAttribLocation(program, "in_tc"); | 242 int tc_location = glGetAttribLocation(program, "in_tc"); |
| 242 glEnableVertexAttribArray(tc_location); | 243 glEnableVertexAttribArray(tc_location); |
| 243 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, | 244 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, |
| 244 kTextureCoords); | 245 kTextureCoords); |
| 245 | 246 |
| 246 // We are getting called on a thread. Release the context so that it can be | 247 // We are getting called on a thread. Release the context so that it can be |
| 247 // made current on the main thread. | 248 // made current on the main thread. |
| 248 glXMakeCurrent(display_, 0, NULL); | 249 glXMakeCurrent(display_, 0, NULL); |
| 249 } | 250 } |
| OLD | NEW |