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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 : display_(display), | 104 : display_(display), |
105 window_(window), | 105 window_(window), |
106 gl_context_(NULL) { | 106 gl_context_(NULL) { |
107 } | 107 } |
108 | 108 |
109 GlVideoRenderer::~GlVideoRenderer() { | 109 GlVideoRenderer::~GlVideoRenderer() { |
110 glXMakeCurrent(display_, 0, NULL); | 110 glXMakeCurrent(display_, 0, NULL); |
111 glXDestroyContext(display_, gl_context_); | 111 glXDestroyContext(display_, gl_context_); |
112 } | 112 } |
113 | 113 |
114 void GlVideoRenderer::Paint(media::VideoFrame* video_frame) { | 114 void GlVideoRenderer::Paint( |
| 115 const scoped_refptr<media::VideoFrame>& video_frame) { |
115 if (!gl_context_) | 116 if (!gl_context_) |
116 Initialize(video_frame->coded_size(), video_frame->visible_rect()); | 117 Initialize(video_frame->coded_size(), video_frame->visible_rect()); |
117 | 118 |
118 // Convert YUV frame to RGB. | 119 // Convert YUV frame to RGB. |
119 DCHECK(video_frame->format() == media::VideoFrame::YV12 || | 120 DCHECK(video_frame->format() == media::VideoFrame::YV12 || |
120 video_frame->format() == media::VideoFrame::I420 || | 121 video_frame->format() == media::VideoFrame::I420 || |
121 video_frame->format() == media::VideoFrame::YV16); | 122 video_frame->format() == media::VideoFrame::YV16); |
122 DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == | 123 DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == |
123 video_frame->stride(media::VideoFrame::kVPlane)); | 124 video_frame->stride(media::VideoFrame::kVPlane)); |
124 | 125 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 verts[0] = x0; verts[1] = y0; | 242 verts[0] = x0; verts[1] = y0; |
242 verts[2] = x0; verts[3] = y1; | 243 verts[2] = x0; verts[3] = y1; |
243 verts[4] = x1; verts[5] = y0; | 244 verts[4] = x1; verts[5] = y0; |
244 verts[6] = x1; verts[7] = y1; | 245 verts[6] = x1; verts[7] = y1; |
245 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, verts); | 246 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, verts); |
246 | 247 |
247 // We are getting called on a thread. Release the context so that it can be | 248 // We are getting called on a thread. Release the context so that it can be |
248 // made current on the main thread. | 249 // made current on the main thread. |
249 glXMakeCurrent(display_, 0, NULL); | 250 glXMakeCurrent(display_, 0, NULL); |
250 } | 251 } |
OLD | NEW |