Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: cc/layers/video_layer_impl.cc

Issue 12998003: Fix VideoLayerImpl upload of YUV->RGBA converted frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@git-svn
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/video_layer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 void VideoLayerImpl::FramePlane::FreeData(ResourceProvider* resource_provider) { 360 void VideoLayerImpl::FramePlane::FreeData(ResourceProvider* resource_provider) {
361 if (!resource_id) 361 if (!resource_id)
362 return; 362 return;
363 363
364 resource_provider->DeleteResource(resource_id); 364 resource_provider->DeleteResource(resource_id);
365 resource_id = 0; 365 resource_id = 0;
366 } 366 }
367 367
368 // Convert media::VideoFrame::Format to OpenGL enum values. 368 // Convert media::VideoFrame::Format to OpenGL enum values.
369 static GLenum ConvertVFCFormatToGLenum(const media::VideoFrame& frame) { 369 static GLenum ConvertVFCFormatToGLenum(const media::VideoFrame::Format format) {
370 switch (frame.format()) { 370 switch (format) {
371 case media::VideoFrame::YV12: 371 case media::VideoFrame::YV12:
372 case media::VideoFrame::YV16: 372 case media::VideoFrame::YV16:
373 return GL_LUMINANCE; 373 return GL_LUMINANCE;
374 case media::VideoFrame::RGB32:
375 return GL_RGBA;
374 case media::VideoFrame::NATIVE_TEXTURE: 376 case media::VideoFrame::NATIVE_TEXTURE:
375 return frame.texture_target();
376 #if defined(GOOGLE_TV) 377 #if defined(GOOGLE_TV)
377 case media::VideoFrame::HOLE: 378 case media::VideoFrame::HOLE:
danakj 2013/03/21 22:38:31 i don't see what prevents this from being called w
sheu 2013/03/21 22:42:26 NumPlanes will return 0 for HOLE, so SetupFramePla
danakj 2013/03/21 22:47:53 Ah okay.
378 return GL_INVALID_VALUE;
379 #endif 379 #endif
380 case media::VideoFrame::INVALID: 380 case media::VideoFrame::INVALID:
381 case media::VideoFrame::RGB32:
382 case media::VideoFrame::EMPTY: 381 case media::VideoFrame::EMPTY:
383 case media::VideoFrame::I420: 382 case media::VideoFrame::I420:
384 NOTREACHED(); 383 NOTREACHED();
385 break; 384 break;
386 } 385 }
387 return GL_INVALID_VALUE; 386 return GL_INVALID_VALUE;
388 } 387 }
389 388
390 size_t VideoLayerImpl::NumPlanes() const {
391 if (!frame_)
392 return 0;
393
394 if (convert_yuv_)
395 return 1;
396
397 return media::VideoFrame::NumPlanes(frame_->format());
398 }
399
400 bool VideoLayerImpl::SetupFramePlanes(ResourceProvider* resource_provider) { 389 bool VideoLayerImpl::SetupFramePlanes(ResourceProvider* resource_provider) {
401 const size_t plane_count = NumPlanes(); 390 const size_t plane_count = media::VideoFrame::NumPlanes(format_);
402 if (!plane_count) 391 if (!plane_count)
403 return true; 392 return true;
404 393
405 const int max_texture_size = resource_provider->max_texture_size(); 394 const int max_texture_size = resource_provider->max_texture_size();
406 const GLenum pixel_format = ConvertVFCFormatToGLenum(*frame_); 395 const GLenum pixel_format = ConvertVFCFormatToGLenum(format_);
407 for (size_t plane_index = 0; plane_index < plane_count; ++plane_index) { 396 for (size_t plane_index = 0; plane_index < plane_count; ++plane_index) {
408 VideoLayerImpl::FramePlane* plane = &frame_planes_[plane_index]; 397 VideoLayerImpl::FramePlane* plane = &frame_planes_[plane_index];
409 398
410 gfx::Size required_texture_size = VideoFrameDimension(frame_, plane_index); 399 gfx::Size required_texture_size = VideoFrameDimension(frame_, plane_index);
411 // TODO: Remove the test against max_texture_size when tiled layers are 400 // TODO: Remove the test against max_texture_size when tiled layers are
412 // implemented. 401 // implemented.
413 if (required_texture_size.IsEmpty() || 402 if (required_texture_size.IsEmpty() ||
414 required_texture_size.width() > max_texture_size || 403 required_texture_size.width() > max_texture_size ||
415 required_texture_size.height() > max_texture_size) 404 required_texture_size.height() > max_texture_size)
416 return false; 405 return false;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 446 }
458 return true; 447 return true;
459 } 448 }
460 449
461 void VideoLayerImpl::FreeFramePlanes(ResourceProvider* resource_provider) { 450 void VideoLayerImpl::FreeFramePlanes(ResourceProvider* resource_provider) {
462 for (size_t i = 0; i < media::VideoFrame::kMaxPlanes; ++i) 451 for (size_t i = 0; i < media::VideoFrame::kMaxPlanes; ++i)
463 frame_planes_[i].FreeData(resource_provider); 452 frame_planes_[i].FreeData(resource_provider);
464 } 453 }
465 454
466 void VideoLayerImpl::FreeUnusedFramePlanes(ResourceProvider* resource_provider) { 455 void VideoLayerImpl::FreeUnusedFramePlanes(ResourceProvider* resource_provider) {
467 size_t first_unused_plane = NumPlanes(); 456 size_t first_unused_plane = (frame_ ? media::VideoFrame::NumPlanes(format_) :
danakj 2013/03/21 22:38:31 how about just an early out if !frame_?
sheu 2013/03/21 22:42:26 We'll still want to deallocate all the planes, for
danakj 2013/03/21 22:47:53 I see! Can you wrap this a little differently, by
sheu 2013/03/21 22:50:39 That's the way I would have done things, but I was
457 0);
468 for (size_t i = first_unused_plane; i < media::VideoFrame::kMaxPlanes; ++i) 458 for (size_t i = first_unused_plane; i < media::VideoFrame::kMaxPlanes; ++i)
469 frame_planes_[i].FreeData(resource_provider); 459 frame_planes_[i].FreeData(resource_provider);
470 } 460 }
471 461
472 void VideoLayerImpl::DidLoseOutputSurface() { 462 void VideoLayerImpl::DidLoseOutputSurface() {
473 FreeFramePlanes(layer_tree_impl()->resource_provider()); 463 FreeFramePlanes(layer_tree_impl()->resource_provider());
474 } 464 }
475 465
476 void VideoLayerImpl::SetNeedsRedraw() { 466 void VideoLayerImpl::SetNeedsRedraw() {
477 layer_tree_impl()->SetNeedsRedraw(); 467 layer_tree_impl()->SetNeedsRedraw();
478 } 468 }
479 469
480 void VideoLayerImpl::SetProviderClientImpl( 470 void VideoLayerImpl::SetProviderClientImpl(
481 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { 471 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) {
482 provider_client_impl_ = provider_client_impl; 472 provider_client_impl_ = provider_client_impl;
483 } 473 }
484 474
485 const char* VideoLayerImpl::LayerTypeAsString() const { 475 const char* VideoLayerImpl::LayerTypeAsString() const {
486 return "VideoLayer"; 476 return "VideoLayer";
487 } 477 }
488 478
489 } // namespace cc 479 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698