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/x11_video_renderer.h" | 5 #include "media/tools/player_x11/x11_video_renderer.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <X11/Xutil.h> | 8 #include <X11/Xutil.h> |
9 #include <X11/extensions/Xrender.h> | 9 #include <X11/extensions/Xrender.h> |
10 #include <X11/extensions/Xcomposite.h> | 10 #include <X11/extensions/Xcomposite.h> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
15 #include "media/base/yuv_convert.h" | 15 #include "media/base/yuv_convert.h" |
16 | 16 |
17 // Creates a 32-bit XImage. | 17 // Creates a 32-bit XImage. |
18 static XImage* CreateImage(Display* display, int width, int height) { | 18 static XImage* CreateImage(Display* display, int width, int height) { |
19 LOG(INFO) << "Allocating XImage " << width << "x" << height; | 19 VLOG(0) << "Allocating XImage " << width << "x" << height; |
20 return XCreateImage(display, | 20 return XCreateImage(display, |
21 DefaultVisual(display, DefaultScreen(display)), | 21 DefaultVisual(display, DefaultScreen(display)), |
22 DefaultDepth(display, DefaultScreen(display)), | 22 DefaultDepth(display, DefaultScreen(display)), |
23 ZPixmap, | 23 ZPixmap, |
24 0, | 24 0, |
25 static_cast<char*>(malloc(width * height * 4)), | 25 static_cast<char*>(malloc(width * height * 4)), |
26 width, | 26 width, |
27 height, | 27 height, |
28 32, | 28 32, |
29 width * 4); | 29 width * 4); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 video_frame->visible_rect().x(), | 174 video_frame->visible_rect().x(), |
175 video_frame->visible_rect().y(), | 175 video_frame->visible_rect().y(), |
176 0, 0, visible_width, visible_height); | 176 0, 0, visible_width, visible_height); |
177 XFlush(display_); | 177 XFlush(display_); |
178 XFreeGC(display_, gc); | 178 XFreeGC(display_, gc); |
179 } | 179 } |
180 | 180 |
181 void X11VideoRenderer::Initialize(gfx::Size coded_size, | 181 void X11VideoRenderer::Initialize(gfx::Size coded_size, |
182 gfx::Rect visible_rect) { | 182 gfx::Rect visible_rect) { |
183 CHECK(!image_); | 183 CHECK(!image_); |
184 LOG(INFO) << "Initializing X11 Renderer..."; | 184 VLOG(0) << "Initializing X11 Renderer..."; |
185 | 185 |
186 // Resize the window to fit that of the video. | 186 // Resize the window to fit that of the video. |
187 XResizeWindow(display_, window_, visible_rect.width(), visible_rect.height()); | 187 XResizeWindow(display_, window_, visible_rect.width(), visible_rect.height()); |
188 image_ = CreateImage(display_, coded_size.width(), coded_size.height()); | 188 image_ = CreateImage(display_, coded_size.width(), coded_size.height()); |
189 | 189 |
190 // Testing XRender support. We'll use the very basic of XRender | 190 // Testing XRender support. We'll use the very basic of XRender |
191 // so if it presents it is already good enough. We don't need | 191 // so if it presents it is already good enough. We don't need |
192 // to check its version. | 192 // to check its version. |
193 int dummy; | 193 int dummy; |
194 use_render_ = XRenderQueryExtension(display_, &dummy, &dummy); | 194 use_render_ = XRenderQueryExtension(display_, &dummy, &dummy); |
195 | 195 |
196 if (use_render_) { | 196 if (use_render_) { |
197 LOG(INFO) << "Using XRender extension."; | 197 VLOG(0) << "Using XRender extension."; |
198 | 198 |
199 // If we are using XRender, we'll create a picture representing the | 199 // If we are using XRender, we'll create a picture representing the |
200 // window. | 200 // window. |
201 XWindowAttributes attr; | 201 XWindowAttributes attr; |
202 XGetWindowAttributes(display_, window_, &attr); | 202 XGetWindowAttributes(display_, window_, &attr); |
203 | 203 |
204 XRenderPictFormat* pictformat = XRenderFindVisualFormat( | 204 XRenderPictFormat* pictformat = XRenderFindVisualFormat( |
205 display_, | 205 display_, |
206 attr.visual); | 206 attr.visual); |
207 CHECK(pictformat) << "XRender does not support default visual"; | 207 CHECK(pictformat) << "XRender does not support default visual"; |
208 | 208 |
209 picture_ = XRenderCreatePicture(display_, window_, pictformat, 0, NULL); | 209 picture_ = XRenderCreatePicture(display_, window_, pictformat, 0, NULL); |
210 CHECK(picture_) << "Backing picture not created"; | 210 CHECK(picture_) << "Backing picture not created"; |
211 } | 211 } |
212 } | 212 } |
OLD | NEW |