OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/layers/video_layer_impl.h" | 5 #include "cc/layers/video_layer_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 draw_properties() | 184 draw_properties() |
185 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( | 185 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( |
186 transform); | 186 transform); |
187 gfx::Rect visible_quad_rect = | 187 gfx::Rect visible_quad_rect = |
188 occlusion_in_video_space.GetUnoccludedContentRect(quad_rect); | 188 occlusion_in_video_space.GetUnoccludedContentRect(quad_rect); |
189 if (visible_quad_rect.IsEmpty()) | 189 if (visible_quad_rect.IsEmpty()) |
190 return; | 190 return; |
191 | 191 |
192 // Pixels for macroblocked formats. To prevent sampling outside the visible | 192 // Pixels for macroblocked formats. To prevent sampling outside the visible |
193 // rect, stretch the video if needed. | 193 // rect, stretch the video if needed. |
| 194 gfx::Rect visible_sample_rect = frame_->visible_rect(); |
| 195 if (visible_rect.width() < coded_size.width() && visible_rect.width() > 1) |
| 196 visible_sample_rect.set_width(visible_rect.width() - 1); |
| 197 if (visible_rect.height() < coded_size.height() && visible_rect.height() > 1) |
| 198 visible_sample_rect.set_height(visible_rect.height() - 1); |
194 const float tex_width_scale = | 199 const float tex_width_scale = |
195 static_cast<float>(visible_rect.width()) / coded_size.width(); | 200 static_cast<float>(visible_sample_rect.width()) / coded_size.width(); |
196 const float tex_height_scale = | 201 const float tex_height_scale = |
197 static_cast<float>(visible_rect.height()) / coded_size.height(); | 202 static_cast<float>(visible_sample_rect.height()) / coded_size.height(); |
198 | 203 |
199 switch (frame_resource_type_) { | 204 switch (frame_resource_type_) { |
200 // TODO(danakj): Remove this, hide it in the hardware path. | 205 // TODO(danakj): Remove this, hide it in the hardware path. |
201 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { | 206 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { |
202 DCHECK_EQ(frame_resources_.size(), 0u); | 207 DCHECK_EQ(frame_resources_.size(), 0u); |
203 DCHECK_EQ(software_resources_.size(), 1u); | 208 DCHECK_EQ(software_resources_.size(), 1u); |
204 if (software_resources_.size() < 1u) | 209 if (software_resources_.size() < 1u) |
205 break; | 210 break; |
206 bool premultiplied_alpha = true; | 211 bool premultiplied_alpha = true; |
207 gfx::PointF uv_top_left(0.f, 0.f); | 212 gfx::PointF uv_top_left(0.f, 0.f); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 frame_->format(), media::VideoFrame::kAPlane, | 258 frame_->format(), media::VideoFrame::kAPlane, |
254 coded_size)); | 259 coded_size)); |
255 } | 260 } |
256 | 261 |
257 // Compute the UV sub-sampling factor based on the ratio between | 262 // Compute the UV sub-sampling factor based on the ratio between |
258 // |ya_tex_size| and |uv_tex_size|. | 263 // |ya_tex_size| and |uv_tex_size|. |
259 float uv_subsampling_factor_x = | 264 float uv_subsampling_factor_x = |
260 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); | 265 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); |
261 float uv_subsampling_factor_y = | 266 float uv_subsampling_factor_y = |
262 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); | 267 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); |
263 gfx::RectF ya_tex_coord_rect(visible_rect); | 268 gfx::RectF ya_tex_coord_rect(visible_sample_rect); |
264 gfx::RectF uv_tex_coord_rect( | 269 gfx::RectF uv_tex_coord_rect( |
265 visible_rect.x() / uv_subsampling_factor_x, | 270 visible_sample_rect.x() / uv_subsampling_factor_x, |
266 visible_rect.y() / uv_subsampling_factor_y, | 271 visible_sample_rect.y() / uv_subsampling_factor_y, |
267 visible_rect.width() / uv_subsampling_factor_x, | 272 visible_sample_rect.width() / uv_subsampling_factor_x, |
268 visible_rect.height() / uv_subsampling_factor_y); | 273 visible_sample_rect.height() / uv_subsampling_factor_y); |
269 | 274 |
270 YUVVideoDrawQuad* yuv_video_quad = | 275 YUVVideoDrawQuad* yuv_video_quad = |
271 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 276 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
272 yuv_video_quad->SetNew( | 277 yuv_video_quad->SetNew( |
273 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, | 278 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, |
274 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, | 279 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, |
275 frame_resources_[0].id, frame_resources_[1].id, | 280 frame_resources_[0].id, frame_resources_[1].id, |
276 frame_resources_.size() > 2 ? frame_resources_[2].id | 281 frame_resources_.size() > 2 ? frame_resources_[2].id |
277 : frame_resources_[1].id, | 282 : frame_resources_[1].id, |
278 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space, | 283 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 void VideoLayerImpl::SetNeedsRedraw() { | 372 void VideoLayerImpl::SetNeedsRedraw() { |
368 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 373 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
369 layer_tree_impl()->SetNeedsRedraw(); | 374 layer_tree_impl()->SetNeedsRedraw(); |
370 } | 375 } |
371 | 376 |
372 const char* VideoLayerImpl::LayerTypeAsString() const { | 377 const char* VideoLayerImpl::LayerTypeAsString() const { |
373 return "cc::VideoLayerImpl"; | 378 return "cc::VideoLayerImpl"; |
374 } | 379 } |
375 | 380 |
376 } // namespace cc | 381 } // namespace cc |
OLD | NEW |