| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (callback) { | 87 if (callback) { |
| 88 callback->Run(); | 88 callback->Run(); |
| 89 delete callback; | 89 delete callback; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool X11VideoRenderer::OnInitialize(media::VideoDecoder* decoder) { | 93 bool X11VideoRenderer::OnInitialize(media::VideoDecoder* decoder) { |
| 94 LOG(INFO) << "Initializing X11 Renderer..."; | 94 LOG(INFO) << "Initializing X11 Renderer..."; |
| 95 | 95 |
| 96 // Resize the window to fit that of the video. | 96 // Resize the window to fit that of the video. |
| 97 int width = decoder->width(); | 97 int width = decoder->natural_size().width(); |
| 98 int height = decoder->height(); | 98 int height = decoder->natural_size().height(); |
| 99 XResizeWindow(display_, window_, width, height); | 99 XResizeWindow(display_, window_, width, height); |
| 100 | 100 |
| 101 // Allocate an XImage for caching RGB result. | 101 // Allocate an XImage for caching RGB result. |
| 102 image_ = CreateImage(display_, width, height); | 102 image_ = CreateImage(display_, width, height); |
| 103 | 103 |
| 104 // Testing XRender support. We'll use the very basic of XRender | 104 // Testing XRender support. We'll use the very basic of XRender |
| 105 // so if it presents it is already good enough. We don't need | 105 // so if it presents it is already good enough. We don't need |
| 106 // to check its version. | 106 // to check its version. |
| 107 int dummy; | 107 int dummy; |
| 108 use_render_ = XRenderQueryExtension(display_, &dummy, &dummy); | 108 use_render_ = XRenderQueryExtension(display_, &dummy, &dummy); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // If XRender is not used, simply put the image to the server. | 229 // If XRender is not used, simply put the image to the server. |
| 230 // This will have a tearing effect but this is OK. | 230 // This will have a tearing effect but this is OK. |
| 231 // TODO(hclam): Upload the image to a pixmap and do XCopyArea() | 231 // TODO(hclam): Upload the image to a pixmap and do XCopyArea() |
| 232 // to the window. | 232 // to the window. |
| 233 GC gc = XCreateGC(display_, window_, 0, NULL); | 233 GC gc = XCreateGC(display_, window_, 0, NULL); |
| 234 XPutImage(display_, window_, gc, image_, | 234 XPutImage(display_, window_, gc, image_, |
| 235 0, 0, 0, 0, width, height); | 235 0, 0, 0, 0, width, height); |
| 236 XFlush(display_); | 236 XFlush(display_); |
| 237 XFreeGC(display_, gc); | 237 XFreeGC(display_, gc); |
| 238 } | 238 } |
| OLD | NEW |