| OLD | NEW |
| 1 // Copyright (c) 2011 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 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 X11VideoRenderer::~X11VideoRenderer() { | 79 X11VideoRenderer::~X11VideoRenderer() { |
| 80 if (image_) | 80 if (image_) |
| 81 XDestroyImage(image_); | 81 XDestroyImage(image_); |
| 82 if (use_render_) | 82 if (use_render_) |
| 83 XRenderFreePicture(display_, picture_); | 83 XRenderFreePicture(display_, picture_); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void X11VideoRenderer::Paint(media::VideoFrame* video_frame) { | 86 void X11VideoRenderer::Paint(media::VideoFrame* video_frame) { |
| 87 int width = video_frame->width(); | 87 int width = video_frame->data_size().width(); |
| 88 int height = video_frame->height(); | 88 int height = video_frame->data_size().height(); |
| 89 | 89 |
| 90 if (!image_) | 90 if (!image_) |
| 91 Initialize(width, height); | 91 Initialize(width, height); |
| 92 | 92 |
| 93 // Check if we need to reallocate our XImage. | 93 // Check if we need to reallocate our XImage. |
| 94 if (image_->width != width || image_->height != height) { | 94 if (image_->width != width || image_->height != height) { |
| 95 XDestroyImage(image_); | 95 XDestroyImage(image_); |
| 96 image_ = CreateImage(display_, width, height); | 96 image_ = CreateImage(display_, width, height); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Convert YUV frame to RGB. | 99 // Convert YUV frame to RGB. |
| 100 DCHECK(video_frame->format() == media::VideoFrame::YV12 || | 100 DCHECK(video_frame->format() == media::VideoFrame::YV12 || |
| 101 video_frame->format() == media::VideoFrame::YV16); | 101 video_frame->format() == media::VideoFrame::YV16); |
| 102 DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == | 102 DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == |
| 103 video_frame->stride(media::VideoFrame::kVPlane)); | 103 video_frame->stride(media::VideoFrame::kVPlane)); |
| 104 | 104 |
| 105 DCHECK(image_->data); | 105 DCHECK(image_->data); |
| 106 media::YUVType yuv_type = | 106 media::YUVType yuv_type = |
| 107 (video_frame->format() == media::VideoFrame::YV12) ? | 107 (video_frame->format() == media::VideoFrame::YV12) ? |
| 108 media::YV12 : media::YV16; | 108 media::YV12 : media::YV16; |
| 109 media::ConvertYUVToRGB32(video_frame->data(media::VideoFrame::kYPlane), | 109 media::ConvertYUVToRGB32(video_frame->data(media::VideoFrame::kYPlane), |
| 110 video_frame->data(media::VideoFrame::kUPlane), | 110 video_frame->data(media::VideoFrame::kUPlane), |
| 111 video_frame->data(media::VideoFrame::kVPlane), | 111 video_frame->data(media::VideoFrame::kVPlane), |
| 112 (uint8*)image_->data, | 112 (uint8*)image_->data, |
| 113 video_frame->width(), | 113 video_frame->data_size().width(), |
| 114 video_frame->height(), | 114 video_frame->data_size().height(), |
| 115 video_frame->stride(media::VideoFrame::kYPlane), | 115 video_frame->stride(media::VideoFrame::kYPlane), |
| 116 video_frame->stride(media::VideoFrame::kUPlane), | 116 video_frame->stride(media::VideoFrame::kUPlane), |
| 117 image_->bytes_per_line, | 117 image_->bytes_per_line, |
| 118 yuv_type); | 118 yuv_type); |
| 119 | 119 |
| 120 if (use_render_) { | 120 if (use_render_) { |
| 121 // If XRender is used, we'll upload the image to a pixmap. And then | 121 // If XRender is used, we'll upload the image to a pixmap. And then |
| 122 // creats a picture from the pixmap and composite the picture over | 122 // creats a picture from the pixmap and composite the picture over |
| 123 // the picture represending the window. | 123 // the picture represending the window. |
| 124 | 124 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 200 |
| 201 XRenderPictFormat* pictformat = XRenderFindVisualFormat( | 201 XRenderPictFormat* pictformat = XRenderFindVisualFormat( |
| 202 display_, | 202 display_, |
| 203 attr.visual); | 203 attr.visual); |
| 204 CHECK(pictformat) << "XRender does not support default visual"; | 204 CHECK(pictformat) << "XRender does not support default visual"; |
| 205 | 205 |
| 206 picture_ = XRenderCreatePicture(display_, window_, pictformat, 0, NULL); | 206 picture_ = XRenderCreatePicture(display_, window_, pictformat, 0, NULL); |
| 207 CHECK(picture_) << "Backing picture not created"; | 207 CHECK(picture_) << "Backing picture not created"; |
| 208 } | 208 } |
| 209 } | 209 } |
| OLD | NEW |