OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cast/test/linux_output_window.h" | 5 #include "media/cast/test/linux_output_window.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
9 #include "third_party/libyuv/include/libyuv/convert.h" | 11 #include "third_party/libyuv/include/libyuv/convert.h" |
10 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
11 | 13 |
12 namespace media { | 14 namespace media { |
13 namespace cast { | 15 namespace cast { |
14 namespace test { | 16 namespace test { |
15 | 17 |
16 LinuxOutputWindow::LinuxOutputWindow(int x_pos, | 18 LinuxOutputWindow::LinuxOutputWindow(int x_pos, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Attach image to display. | 113 // Attach image to display. |
112 if (!XShmAttach(display_, &shminfo_)) { | 114 if (!XShmAttach(display_, &shminfo_)) { |
113 VLOG(1) << "XShmAttach failed"; | 115 VLOG(1) << "XShmAttach failed"; |
114 NOTREACHED(); | 116 NOTREACHED(); |
115 } | 117 } |
116 XSync(display_, false); | 118 XSync(display_, false); |
117 } | 119 } |
118 | 120 |
119 void LinuxOutputWindow::RenderFrame( | 121 void LinuxOutputWindow::RenderFrame( |
120 const scoped_refptr<media::VideoFrame>& video_frame) { | 122 const scoped_refptr<media::VideoFrame>& video_frame) { |
121 CHECK_LE(video_frame->coded_size().width(), image_->width); | 123 const gfx::Size damage_size(std::min(video_frame->visible_rect().width(), |
122 CHECK_LE(video_frame->coded_size().height(), image_->height); | 124 image_->width), |
123 libyuv::I420ToARGB(video_frame->data(VideoFrame::kYPlane), | 125 std::min(video_frame->visible_rect().height(), |
124 video_frame->stride(VideoFrame::kYPlane), | 126 image_->height)); |
125 video_frame->data(VideoFrame::kUPlane), | 127 |
126 video_frame->stride(VideoFrame::kUPlane), | 128 if (damage_size.width() < image_->width || |
127 video_frame->data(VideoFrame::kVPlane), | 129 damage_size.height() < image_->height) |
128 video_frame->stride(VideoFrame::kVPlane), | 130 memset(image_->data, 0x00, image_->bytes_per_line * image_->height); |
129 reinterpret_cast<uint8_t*>(image_->data), | 131 |
130 image_->bytes_per_line, | 132 if (!damage_size.IsEmpty()) { |
131 video_frame->coded_size().width(), | 133 libyuv::I420ToARGB(video_frame->visible_data(VideoFrame::kYPlane), |
132 video_frame->coded_size().height()); | 134 video_frame->stride(VideoFrame::kYPlane), |
| 135 video_frame->visible_data(VideoFrame::kUPlane), |
| 136 video_frame->stride(VideoFrame::kUPlane), |
| 137 video_frame->visible_data(VideoFrame::kVPlane), |
| 138 video_frame->stride(VideoFrame::kVPlane), |
| 139 reinterpret_cast<uint8_t*>(image_->data), |
| 140 image_->bytes_per_line, |
| 141 damage_size.width(), |
| 142 damage_size.height()); |
| 143 } |
133 | 144 |
134 // Place image in window. | 145 // Place image in window. |
135 XShmPutImage(display_, | 146 XShmPutImage(display_, |
136 window_, | 147 window_, |
137 gc_, | 148 gc_, |
138 image_, | 149 image_, |
139 0, | 150 0, |
140 0, | 151 0, |
141 0, | 152 0, |
142 0, | 153 0, |
143 video_frame->coded_size().width(), | 154 image_->width, |
144 video_frame->coded_size().height(), | 155 image_->height, |
145 true); | 156 true); |
146 | 157 |
147 // Very important for the image to update properly! | 158 // Very important for the image to update properly! |
148 XSync(display_, false); | 159 XSync(display_, false); |
149 } | 160 } |
150 | 161 |
151 } // namespace test | 162 } // namespace test |
152 } // namespace cast | 163 } // namespace cast |
153 } // namespace media | 164 } // namespace media |
OLD | NEW |