| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/video_layer_x.h" | 5 #include "chrome/browser/renderer_host/video_layer_x.h" |
| 6 | 6 |
| 7 #include "app/x11_util_internal.h" | 7 #include "app/x11_util_internal.h" |
| 8 #include "chrome/browser/renderer_host/render_process_host.h" | 8 #include "chrome/browser/renderer_host/render_process_host.h" |
| 9 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 VideoLayerX::~VideoLayerX() { | 37 VideoLayerX::~VideoLayerX() { |
| 38 // In unit tests, |display_| may be NULL. | 38 // In unit tests, |display_| may be NULL. |
| 39 if (!display_) | 39 if (!display_) |
| 40 return; | 40 return; |
| 41 | 41 |
| 42 XFreePixmap(display_, pixmap_); | 42 XFreePixmap(display_, pixmap_); |
| 43 XFreeGC(display_, static_cast<GC>(pixmap_gc_)); | 43 XFreeGC(display_, static_cast<GC>(pixmap_gc_)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void VideoLayerX::CopyTransportDIB(RenderProcessHost* process, | 46 void VideoLayerX::CopyTransportDIB(RenderProcessHost* process, |
| 47 TransportDIB::Id bitmap, | 47 TransportDIB::Id dib_id, |
| 48 TransportDIB::Handle dib_handle, |
| 48 const gfx::Rect& bitmap_rect) { | 49 const gfx::Rect& bitmap_rect) { |
| 50 TransportDIB::ScopedHandle scoped_dib_handle(dib_handle); |
| 49 if (!display_) | 51 if (!display_) |
| 50 return; | 52 return; |
| 51 | 53 |
| 52 if (bitmap_rect.IsEmpty()) | 54 if (bitmap_rect.IsEmpty()) |
| 53 return; | 55 return; |
| 54 | 56 |
| 55 if (bitmap_rect.size() != size()) { | 57 if (bitmap_rect.size() != size()) { |
| 56 LOG(ERROR) << "Scaled video layer not supported."; | 58 LOG(ERROR) << "Scaled video layer not supported."; |
| 57 return; | 59 return; |
| 58 } | 60 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 69 return; | 71 return; |
| 70 | 72 |
| 71 // Lazy allocate |rgb_frame_|. | 73 // Lazy allocate |rgb_frame_|. |
| 72 if (!rgb_frame_.get() || rgb_frame_size_ < new_rgb_frame_size) { | 74 if (!rgb_frame_.get() || rgb_frame_size_ < new_rgb_frame_size) { |
| 73 // TODO(scherkus): handle changing dimensions and re-allocating. | 75 // TODO(scherkus): handle changing dimensions and re-allocating. |
| 74 CHECK(size() == rgb_rect_.size()); | 76 CHECK(size() == rgb_rect_.size()); |
| 75 rgb_frame_.reset(new uint8[new_rgb_frame_size]); | 77 rgb_frame_.reset(new uint8[new_rgb_frame_size]); |
| 76 rgb_frame_size_ = new_rgb_frame_size; | 78 rgb_frame_size_ = new_rgb_frame_size; |
| 77 } | 79 } |
| 78 | 80 |
| 79 TransportDIB* dib = process->GetTransportDIB(bitmap); | 81 TransportDIB* dib = process->GetTransportDIB(dib_id, |
| 82 scoped_dib_handle.release()); |
| 80 if (!dib) | 83 if (!dib) |
| 81 return; | 84 return; |
| 82 | 85 |
| 83 // Perform colour space conversion. | 86 // Perform colour space conversion. |
| 84 const uint8* y_plane = reinterpret_cast<uint8*>(dib->memory()); | 87 const uint8* y_plane = reinterpret_cast<uint8*>(dib->memory()); |
| 85 const uint8* u_plane = y_plane + width * height; | 88 const uint8* u_plane = y_plane + width * height; |
| 86 const uint8* v_plane = u_plane + ((width * height) >> 2); | 89 const uint8* v_plane = u_plane + ((width * height) >> 2); |
| 87 media::ConvertYUVToRGB32(y_plane, | 90 media::ConvertYUVToRGB32(y_plane, |
| 88 u_plane, | 91 u_plane, |
| 89 v_plane, | 92 v_plane, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 101 } | 104 } |
| 102 | 105 |
| 103 void VideoLayerX::XShow(XID target) { | 106 void VideoLayerX::XShow(XID target) { |
| 104 if (rgb_rect_.IsEmpty()) | 107 if (rgb_rect_.IsEmpty()) |
| 105 return; | 108 return; |
| 106 | 109 |
| 107 XCopyArea(display_, pixmap_, target, static_cast<GC>(pixmap_gc_), | 110 XCopyArea(display_, pixmap_, target, static_cast<GC>(pixmap_gc_), |
| 108 0, 0, rgb_rect_.width(), rgb_rect_.height(), | 111 0, 0, rgb_rect_.width(), rgb_rect_.height(), |
| 109 rgb_rect_.x(), rgb_rect_.y()); | 112 rgb_rect_.x(), rgb_rect_.y()); |
| 110 } | 113 } |
| OLD | NEW |