| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 uv_top_left, | 226 uv_top_left, |
| 227 uv_bottom_right, | 227 uv_bottom_right, |
| 228 SK_ColorTRANSPARENT, | 228 SK_ColorTRANSPARENT, |
| 229 opacity, | 229 opacity, |
| 230 flipped, | 230 flipped, |
| 231 nearest_neighbor); | 231 nearest_neighbor); |
| 232 ValidateQuadResources(texture_quad); | 232 ValidateQuadResources(texture_quad); |
| 233 break; | 233 break; |
| 234 } | 234 } |
| 235 case VideoFrameExternalResources::YUV_RESOURCE: { | 235 case VideoFrameExternalResources::YUV_RESOURCE: { |
| 236 DCHECK_GE(frame_resources_.size(), 3u); | |
| 237 | |
| 238 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; | 236 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; |
| 239 int videoframe_color_space; | 237 int videoframe_color_space; |
| 240 if (frame_->metadata()->GetInteger(media::VideoFrameMetadata::COLOR_SPACE, | 238 if (frame_->metadata()->GetInteger(media::VideoFrameMetadata::COLOR_SPACE, |
| 241 &videoframe_color_space)) { | 239 &videoframe_color_space)) { |
| 242 if (videoframe_color_space == media::COLOR_SPACE_JPEG) { | 240 if (videoframe_color_space == media::COLOR_SPACE_JPEG) { |
| 243 color_space = YUVVideoDrawQuad::JPEG; | 241 color_space = YUVVideoDrawQuad::JPEG; |
| 244 } else if (videoframe_color_space == media::COLOR_SPACE_HD_REC709) { | 242 } else if (videoframe_color_space == media::COLOR_SPACE_HD_REC709) { |
| 245 color_space = YUVVideoDrawQuad::REC_709; | 243 color_space = YUVVideoDrawQuad::REC_709; |
| 246 } | 244 } |
| 247 } | 245 } |
| 248 | 246 |
| 249 const gfx::Size ya_tex_size = coded_size; | 247 const gfx::Size ya_tex_size = coded_size; |
| 250 gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( | 248 gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( |
| 251 frame_->format(), media::VideoFrame::kUPlane, coded_size); | 249 frame_->format(), media::VideoFrame::kUPlane, coded_size); |
| 252 | 250 |
| 253 if (frame_->HasTextures()) { | 251 if (frame_->HasTextures()) { |
| 254 DCHECK_EQ(media::PIXEL_FORMAT_I420, frame_->format()); | 252 if (frame_->format() == media::PIXEL_FORMAT_NV12) { |
| 255 DCHECK_EQ(3u, frame_resources_.size()); // Alpha is not supported yet. | 253 DCHECK_EQ(2u, frame_resources_.size()); |
| 254 } else { |
| 255 DCHECK_EQ(media::PIXEL_FORMAT_I420, frame_->format()); |
| 256 DCHECK_EQ(3u, |
| 257 frame_resources_.size()); // Alpha is not supported yet. |
| 258 } |
| 256 } else { | 259 } else { |
| 257 DCHECK(uv_tex_size == | 260 DCHECK(uv_tex_size == |
| 258 media::VideoFrame::PlaneSize( | 261 media::VideoFrame::PlaneSize( |
| 259 frame_->format(), media::VideoFrame::kVPlane, coded_size)); | 262 frame_->format(), media::VideoFrame::kVPlane, coded_size)); |
| 263 DCHECK_GE(frame_resources_.size(), 3u); |
| 260 DCHECK(frame_resources_.size() <= 3 || | 264 DCHECK(frame_resources_.size() <= 3 || |
| 261 ya_tex_size == media::VideoFrame::PlaneSize( | 265 ya_tex_size == media::VideoFrame::PlaneSize( |
| 262 frame_->format(), media::VideoFrame::kAPlane, | 266 frame_->format(), media::VideoFrame::kAPlane, |
| 263 coded_size)); | 267 coded_size)); |
| 264 } | 268 } |
| 265 | 269 |
| 266 // Compute the UV sub-sampling factor based on the ratio between | 270 // Compute the UV sub-sampling factor based on the ratio between |
| 267 // |ya_tex_size| and |uv_tex_size|. | 271 // |ya_tex_size| and |uv_tex_size|. |
| 268 float uv_subsampling_factor_x = | 272 float uv_subsampling_factor_x = |
| 269 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); | 273 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); |
| 270 float uv_subsampling_factor_y = | 274 float uv_subsampling_factor_y = |
| 271 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); | 275 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); |
| 272 gfx::RectF ya_tex_coord_rect(visible_sample_rect); | 276 gfx::RectF ya_tex_coord_rect(visible_sample_rect); |
| 273 gfx::RectF uv_tex_coord_rect( | 277 gfx::RectF uv_tex_coord_rect( |
| 274 visible_sample_rect.x() / uv_subsampling_factor_x, | 278 visible_sample_rect.x() / uv_subsampling_factor_x, |
| 275 visible_sample_rect.y() / uv_subsampling_factor_y, | 279 visible_sample_rect.y() / uv_subsampling_factor_y, |
| 276 visible_sample_rect.width() / uv_subsampling_factor_x, | 280 visible_sample_rect.width() / uv_subsampling_factor_x, |
| 277 visible_sample_rect.height() / uv_subsampling_factor_y); | 281 visible_sample_rect.height() / uv_subsampling_factor_y); |
| 278 | 282 |
| 279 YUVVideoDrawQuad* yuv_video_quad = | 283 YUVVideoDrawQuad* yuv_video_quad = |
| 280 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 284 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
| 281 yuv_video_quad->SetNew( | 285 yuv_video_quad->SetNew( |
| 282 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, | 286 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, |
| 283 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, | 287 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, |
| 284 frame_resources_[0].id, frame_resources_[1].id, | 288 frame_resources_[0].id, frame_resources_[1].id, |
| 285 frame_resources_[2].id, | 289 frame_resources_.size() > 2 ? frame_resources_[2].id |
| 290 : frame_resources_[1].id, |
| 286 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space, | 291 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space, |
| 287 frame_resource_offset_, frame_resource_multiplier_); | 292 frame_resource_offset_, frame_resource_multiplier_); |
| 288 ValidateQuadResources(yuv_video_quad); | 293 ValidateQuadResources(yuv_video_quad); |
| 289 break; | 294 break; |
| 290 } | 295 } |
| 291 case VideoFrameExternalResources::RGBA_RESOURCE: | 296 case VideoFrameExternalResources::RGBA_RESOURCE: |
| 292 case VideoFrameExternalResources::RGBA_PREMULTIPLIED_RESOURCE: | 297 case VideoFrameExternalResources::RGBA_PREMULTIPLIED_RESOURCE: |
| 293 case VideoFrameExternalResources::RGB_RESOURCE: { | 298 case VideoFrameExternalResources::RGB_RESOURCE: { |
| 294 DCHECK_EQ(frame_resources_.size(), 1u); | 299 DCHECK_EQ(frame_resources_.size(), 1u); |
| 295 if (frame_resources_.size() < 1u) | 300 if (frame_resources_.size() < 1u) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 void VideoLayerImpl::SetNeedsRedraw() { | 418 void VideoLayerImpl::SetNeedsRedraw() { |
| 414 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 419 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
| 415 layer_tree_impl()->SetNeedsRedraw(); | 420 layer_tree_impl()->SetNeedsRedraw(); |
| 416 } | 421 } |
| 417 | 422 |
| 418 const char* VideoLayerImpl::LayerTypeAsString() const { | 423 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 419 return "cc::VideoLayerImpl"; | 424 return "cc::VideoLayerImpl"; |
| 420 } | 425 } |
| 421 | 426 |
| 422 } // namespace cc | 427 } // namespace cc |
| OLD | NEW |