| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/layers/quad_sink.h" | 9 #include "cc/layers/quad_sink.h" |
| 10 #include "cc/layers/video_frame_provider_client_impl.h" | 10 #include "cc/layers/video_frame_provider_client_impl.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 | 128 |
| 129 // TODO: If we're in software compositing mode, we do the YUV -> RGB | 129 // TODO: If we're in software compositing mode, we do the YUV -> RGB |
| 130 // conversion here. That involves an extra copy of each frame to a bitmap. | 130 // conversion here. That involves an extra copy of each frame to a bitmap. |
| 131 // Obviously, this is suboptimal and should be addressed once ubercompositor | 131 // Obviously, this is suboptimal and should be addressed once ubercompositor |
| 132 // starts shaping up. | 132 // starts shaping up. |
| 133 convert_yuv_ = | 133 convert_yuv_ = |
| 134 resource_provider->default_resource_type() == ResourceProvider::Bitmap && | 134 resource_provider->default_resource_type() == ResourceProvider::Bitmap && |
| 135 (format_ == media::VideoFrame::YV12 || | 135 (format_ == media::VideoFrame::YV12 || |
| 136 format_ == media::VideoFrame::YV12A || |
| 136 format_ == media::VideoFrame::YV16); | 137 format_ == media::VideoFrame::YV16); |
| 137 | 138 |
| 138 if (convert_yuv_) | 139 if (convert_yuv_) |
| 139 format_ = media::VideoFrame::RGB32; | 140 format_ = media::VideoFrame::RGB32; |
| 140 | 141 |
| 141 if (!SetupFramePlanes(resource_provider)) { | 142 if (!SetupFramePlanes(resource_provider)) { |
| 142 provider_client_impl_->PutCurrentFrame(frame_); | 143 provider_client_impl_->PutCurrentFrame(frame_); |
| 143 frame_ = NULL; | 144 frame_ = NULL; |
| 144 return; | 145 return; |
| 145 } | 146 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 yuv_video_quad->SetNew(shared_quad_state, | 210 yuv_video_quad->SetNew(shared_quad_state, |
| 210 quad_rect, | 211 quad_rect, |
| 211 opaque_rect, | 212 opaque_rect, |
| 212 tex_scale, | 213 tex_scale, |
| 213 y_plane, | 214 y_plane, |
| 214 u_plane, | 215 u_plane, |
| 215 v_plane); | 216 v_plane); |
| 216 quad_sink->Append(yuv_video_quad.PassAs<DrawQuad>(), append_quads_data); | 217 quad_sink->Append(yuv_video_quad.PassAs<DrawQuad>(), append_quads_data); |
| 217 break; | 218 break; |
| 218 } | 219 } |
| 220 case media::VideoFrame::YV12A: { |
| 221 // YUV software decoder. |
| 222 const FramePlane& y_plane = frame_planes_[media::VideoFrame::kYPlane]; |
| 223 const FramePlane& u_plane = frame_planes_[media::VideoFrame::kUPlane]; |
| 224 const FramePlane& v_plane = frame_planes_[media::VideoFrame::kVPlane]; |
| 225 const FramePlane& a_plane = frame_planes_[media::VideoFrame::kAPlane]; |
| 226 gfx::SizeF tex_scale(tex_width_scale, tex_height_scale); |
| 227 scoped_ptr<YUVVideoDrawQuad> yuva_video_quad = YUVVideoDrawQuad::Create(); |
| 228 yuva_video_quad->SetNew(shared_quad_state, |
| 229 quad_rect, |
| 230 opaque_rect, |
| 231 tex_scale, |
| 232 y_plane, |
| 233 u_plane, |
| 234 v_plane, |
| 235 a_plane); |
| 236 quad_sink->Append(yuva_video_quad.PassAs<DrawQuad>(), append_quads_data); |
| 237 break; |
| 238 } |
| 219 case media::VideoFrame::RGB32: { | 239 case media::VideoFrame::RGB32: { |
| 220 // RGBA software decoder: a converted YUV frame (see: convert_yuv_). | 240 // RGBA software decoder: a converted YUV frame (see: convert_yuv_). |
| 221 const FramePlane& plane = frame_planes_[media::VideoFrame::kRGBPlane]; | 241 const FramePlane& plane = frame_planes_[media::VideoFrame::kRGBPlane]; |
| 222 bool premultiplied_alpha = true; | 242 bool premultiplied_alpha = true; |
| 223 gfx::PointF uv_top_left(0.f, 0.f); | 243 gfx::PointF uv_top_left(0.f, 0.f); |
| 224 gfx::PointF uv_bottom_right(tex_width_scale, tex_height_scale); | 244 gfx::PointF uv_bottom_right(tex_width_scale, tex_height_scale); |
| 225 float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 245 float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 226 bool flipped = false; | 246 bool flipped = false; |
| 227 scoped_ptr<TextureDrawQuad> texture_quad = TextureDrawQuad::Create(); | 247 scoped_ptr<TextureDrawQuad> texture_quad = TextureDrawQuad::Create(); |
| 228 texture_quad->SetNew(shared_quad_state, | 248 texture_quad->SetNew(shared_quad_state, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 provider_client_impl_->PutCurrentFrame(frame_); | 345 provider_client_impl_->PutCurrentFrame(frame_); |
| 326 frame_ = NULL; | 346 frame_ = NULL; |
| 327 | 347 |
| 328 provider_client_impl_->ReleaseLock(); | 348 provider_client_impl_->ReleaseLock(); |
| 329 } | 349 } |
| 330 | 350 |
| 331 static gfx::Size VideoFrameDimension(media::VideoFrame* frame, int plane) { | 351 static gfx::Size VideoFrameDimension(media::VideoFrame* frame, int plane) { |
| 332 gfx::Size dimensions = frame->coded_size(); | 352 gfx::Size dimensions = frame->coded_size(); |
| 333 switch (frame->format()) { | 353 switch (frame->format()) { |
| 334 case media::VideoFrame::YV12: | 354 case media::VideoFrame::YV12: |
| 335 if (plane != media::VideoFrame::kYPlane) { | 355 case media::VideoFrame::YV12A: |
| 356 if (plane != media::VideoFrame::kYPlane && |
| 357 plane != media::VideoFrame::kAPlane) { |
| 336 dimensions.set_width(dimensions.width() / 2); | 358 dimensions.set_width(dimensions.width() / 2); |
| 337 dimensions.set_height(dimensions.height() / 2); | 359 dimensions.set_height(dimensions.height() / 2); |
| 338 } | 360 } |
| 339 break; | 361 break; |
| 340 case media::VideoFrame::YV16: | 362 case media::VideoFrame::YV16: |
| 341 if (plane != media::VideoFrame::kYPlane) | 363 if (plane != media::VideoFrame::kYPlane) |
| 342 dimensions.set_width(dimensions.width() / 2); | 364 dimensions.set_width(dimensions.width() / 2); |
| 343 break; | 365 break; |
| 344 default: | 366 default: |
| 345 break; | 367 break; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 363 | 385 |
| 364 resource_provider->DeleteResource(resource_id); | 386 resource_provider->DeleteResource(resource_id); |
| 365 resource_id = 0; | 387 resource_id = 0; |
| 366 } | 388 } |
| 367 | 389 |
| 368 // Convert media::VideoFrame::Format to OpenGL enum values. | 390 // Convert media::VideoFrame::Format to OpenGL enum values. |
| 369 static GLenum ConvertVFCFormatToGLenum(const media::VideoFrame::Format format) { | 391 static GLenum ConvertVFCFormatToGLenum(const media::VideoFrame::Format format) { |
| 370 switch (format) { | 392 switch (format) { |
| 371 case media::VideoFrame::YV12: | 393 case media::VideoFrame::YV12: |
| 372 case media::VideoFrame::YV16: | 394 case media::VideoFrame::YV16: |
| 395 case media::VideoFrame::YV12A: |
| 373 return GL_LUMINANCE; | 396 return GL_LUMINANCE; |
| 374 case media::VideoFrame::RGB32: | 397 case media::VideoFrame::RGB32: |
| 375 return GL_RGBA; | 398 return GL_RGBA; |
| 376 case media::VideoFrame::NATIVE_TEXTURE: | 399 case media::VideoFrame::NATIVE_TEXTURE: |
| 377 #if defined(GOOGLE_TV) | 400 #if defined(GOOGLE_TV) |
| 378 case media::VideoFrame::HOLE: | 401 case media::VideoFrame::HOLE: |
| 379 #endif | 402 #endif |
| 380 case media::VideoFrame::INVALID: | 403 case media::VideoFrame::INVALID: |
| 381 case media::VideoFrame::EMPTY: | 404 case media::VideoFrame::EMPTY: |
| 382 case media::VideoFrame::I420: | 405 case media::VideoFrame::I420: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 void VideoLayerImpl::SetProviderClientImpl( | 494 void VideoLayerImpl::SetProviderClientImpl( |
| 472 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 495 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
| 473 provider_client_impl_ = provider_client_impl; | 496 provider_client_impl_ = provider_client_impl; |
| 474 } | 497 } |
| 475 | 498 |
| 476 const char* VideoLayerImpl::LayerTypeAsString() const { | 499 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 477 return "VideoLayer"; | 500 return "VideoLayer"; |
| 478 } | 501 } |
| 479 | 502 |
| 480 } // namespace cc | 503 } // namespace cc |
| OLD | NEW |