| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 Occlusion occlusion_in_video_space = | 178 Occlusion occlusion_in_video_space = |
| 179 draw_properties() | 179 draw_properties() |
| 180 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( | 180 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( |
| 181 transform); | 181 transform); |
| 182 gfx::Rect visible_quad_rect = | 182 gfx::Rect visible_quad_rect = |
| 183 occlusion_in_video_space.GetUnoccludedContentRect(quad_rect); | 183 occlusion_in_video_space.GetUnoccludedContentRect(quad_rect); |
| 184 if (visible_quad_rect.IsEmpty()) | 184 if (visible_quad_rect.IsEmpty()) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 // Pixels for macroblocked formats. | 187 // Pixels for macroblocked formats. To prevent sampling outside the visible |
| 188 // rect, stretch the video if needed. |
| 189 gfx::Rect visible_sample_rect = frame_->visible_rect(); |
| 190 if (visible_rect.width() < coded_size.width() && visible_rect.width() > 1) |
| 191 visible_sample_rect.set_width(visible_rect.width() - 1); |
| 192 if (visible_rect.height() < coded_size.height() && visible_rect.height() > 1) |
| 193 visible_sample_rect.set_height(visible_rect.height() - 1); |
| 188 const float tex_width_scale = | 194 const float tex_width_scale = |
| 189 static_cast<float>(visible_rect.width()) / coded_size.width(); | 195 static_cast<float>(visible_sample_rect.width()) / coded_size.width(); |
| 190 const float tex_height_scale = | 196 const float tex_height_scale = |
| 191 static_cast<float>(visible_rect.height()) / coded_size.height(); | 197 static_cast<float>(visible_sample_rect.height()) / coded_size.height(); |
| 192 | 198 |
| 193 switch (frame_resource_type_) { | 199 switch (frame_resource_type_) { |
| 194 // TODO(danakj): Remove this, hide it in the hardware path. | 200 // TODO(danakj): Remove this, hide it in the hardware path. |
| 195 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { | 201 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { |
| 196 DCHECK_EQ(frame_resources_.size(), 0u); | 202 DCHECK_EQ(frame_resources_.size(), 0u); |
| 197 DCHECK_EQ(software_resources_.size(), 1u); | 203 DCHECK_EQ(software_resources_.size(), 1u); |
| 198 if (software_resources_.size() < 1u) | 204 if (software_resources_.size() < 1u) |
| 199 break; | 205 break; |
| 200 bool premultiplied_alpha = true; | 206 bool premultiplied_alpha = true; |
| 201 gfx::PointF uv_top_left(0.f, 0.f); | 207 gfx::PointF uv_top_left(0.f, 0.f); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 frame_->format(), media::VideoFrame::kAPlane, | 256 frame_->format(), media::VideoFrame::kAPlane, |
| 251 coded_size)); | 257 coded_size)); |
| 252 } | 258 } |
| 253 | 259 |
| 254 // Compute the UV sub-sampling factor based on the ratio between | 260 // Compute the UV sub-sampling factor based on the ratio between |
| 255 // |ya_tex_size| and |uv_tex_size|. | 261 // |ya_tex_size| and |uv_tex_size|. |
| 256 float uv_subsampling_factor_x = | 262 float uv_subsampling_factor_x = |
| 257 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); | 263 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); |
| 258 float uv_subsampling_factor_y = | 264 float uv_subsampling_factor_y = |
| 259 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); | 265 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); |
| 260 gfx::RectF ya_tex_coord_rect(visible_rect); | 266 gfx::RectF ya_tex_coord_rect(visible_sample_rect); |
| 261 gfx::RectF uv_tex_coord_rect( | 267 gfx::RectF uv_tex_coord_rect( |
| 262 visible_rect.x() / uv_subsampling_factor_x, | 268 visible_sample_rect.x() / uv_subsampling_factor_x, |
| 263 visible_rect.y() / uv_subsampling_factor_y, | 269 visible_sample_rect.y() / uv_subsampling_factor_y, |
| 264 visible_rect.width() / uv_subsampling_factor_x, | 270 visible_sample_rect.width() / uv_subsampling_factor_x, |
| 265 visible_rect.height() / uv_subsampling_factor_y); | 271 visible_sample_rect.height() / uv_subsampling_factor_y); |
| 266 | 272 |
| 267 YUVVideoDrawQuad* yuv_video_quad = | 273 YUVVideoDrawQuad* yuv_video_quad = |
| 268 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 274 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
| 269 yuv_video_quad->SetNew( | 275 yuv_video_quad->SetNew( |
| 270 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, | 276 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, |
| 271 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, | 277 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, |
| 272 frame_resources_[0].id, frame_resources_[1].id, | 278 frame_resources_[0].id, frame_resources_[1].id, |
| 273 frame_resources_[2].id, | 279 frame_resources_[2].id, |
| 274 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, | 280 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, |
| 275 color_space); | 281 color_space); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 void VideoLayerImpl::SetNeedsRedraw() { | 407 void VideoLayerImpl::SetNeedsRedraw() { |
| 402 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 408 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
| 403 layer_tree_impl()->SetNeedsRedraw(); | 409 layer_tree_impl()->SetNeedsRedraw(); |
| 404 } | 410 } |
| 405 | 411 |
| 406 const char* VideoLayerImpl::LayerTypeAsString() const { | 412 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 407 return "cc::VideoLayerImpl"; | 413 return "cc::VideoLayerImpl"; |
| 408 } | 414 } |
| 409 | 415 |
| 410 } // namespace cc | 416 } // namespace cc |
| OLD | NEW |