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); | |
dshwang
2016/10/18 19:14:36
it requires new baseline of pixetests
| |
199 const float tex_width_scale = | 194 const float tex_width_scale = |
200 static_cast<float>(visible_sample_rect.width()) / coded_size.width(); | 195 static_cast<float>(visible_rect.width()) / coded_size.width(); |
201 const float tex_height_scale = | 196 const float tex_height_scale = |
202 static_cast<float>(visible_sample_rect.height()) / coded_size.height(); | 197 static_cast<float>(visible_rect.height()) / coded_size.height(); |
203 | 198 |
204 switch (frame_resource_type_) { | 199 switch (frame_resource_type_) { |
205 // TODO(danakj): Remove this, hide it in the hardware path. | 200 // TODO(danakj): Remove this, hide it in the hardware path. |
206 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { | 201 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { |
207 DCHECK_EQ(frame_resources_.size(), 0u); | 202 DCHECK_EQ(frame_resources_.size(), 0u); |
208 DCHECK_EQ(software_resources_.size(), 1u); | 203 DCHECK_EQ(software_resources_.size(), 1u); |
209 if (software_resources_.size() < 1u) | 204 if (software_resources_.size() < 1u) |
210 break; | 205 break; |
211 bool premultiplied_alpha = true; | 206 bool premultiplied_alpha = true; |
212 gfx::PointF uv_top_left(0.f, 0.f); | 207 gfx::PointF uv_top_left(0.f, 0.f); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 frame_->format(), media::VideoFrame::kAPlane, | 253 frame_->format(), media::VideoFrame::kAPlane, |
259 coded_size)); | 254 coded_size)); |
260 } | 255 } |
261 | 256 |
262 // Compute the UV sub-sampling factor based on the ratio between | 257 // Compute the UV sub-sampling factor based on the ratio between |
263 // |ya_tex_size| and |uv_tex_size|. | 258 // |ya_tex_size| and |uv_tex_size|. |
264 float uv_subsampling_factor_x = | 259 float uv_subsampling_factor_x = |
265 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); | 260 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); |
266 float uv_subsampling_factor_y = | 261 float uv_subsampling_factor_y = |
267 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); | 262 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); |
268 gfx::RectF ya_tex_coord_rect(visible_sample_rect); | 263 gfx::RectF ya_tex_coord_rect(visible_rect); |
269 gfx::RectF uv_tex_coord_rect( | 264 gfx::RectF uv_tex_coord_rect( |
270 visible_sample_rect.x() / uv_subsampling_factor_x, | 265 visible_rect.x() / uv_subsampling_factor_x, |
271 visible_sample_rect.y() / uv_subsampling_factor_y, | 266 visible_rect.y() / uv_subsampling_factor_y, |
272 visible_sample_rect.width() / uv_subsampling_factor_x, | 267 visible_rect.width() / uv_subsampling_factor_x, |
273 visible_sample_rect.height() / uv_subsampling_factor_y); | 268 visible_rect.height() / uv_subsampling_factor_y); |
274 | 269 |
275 YUVVideoDrawQuad* yuv_video_quad = | 270 YUVVideoDrawQuad* yuv_video_quad = |
276 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 271 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
277 yuv_video_quad->SetNew( | 272 yuv_video_quad->SetNew( |
278 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, | 273 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, |
279 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, | 274 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, |
280 frame_resources_[0].id, frame_resources_[1].id, | 275 frame_resources_[0].id, frame_resources_[1].id, |
281 frame_resources_.size() > 2 ? frame_resources_[2].id | 276 frame_resources_.size() > 2 ? frame_resources_[2].id |
282 : frame_resources_[1].id, | 277 : frame_resources_[1].id, |
283 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space, | 278 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 void VideoLayerImpl::SetNeedsRedraw() { | 367 void VideoLayerImpl::SetNeedsRedraw() { |
373 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 368 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
374 layer_tree_impl()->SetNeedsRedraw(); | 369 layer_tree_impl()->SetNeedsRedraw(); |
375 } | 370 } |
376 | 371 |
377 const char* VideoLayerImpl::LayerTypeAsString() const { | 372 const char* VideoLayerImpl::LayerTypeAsString() const { |
378 return "cc::VideoLayerImpl"; | 373 return "cc::VideoLayerImpl"; |
379 } | 374 } |
380 | 375 |
381 } // namespace cc | 376 } // namespace cc |
OLD | NEW |