OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 sync_point); | 395 sync_point); |
396 video_frame->UpdateReleaseSyncPoint(&client); | 396 video_frame->UpdateReleaseSyncPoint(&client); |
397 } | 397 } |
398 | 398 |
399 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( | 399 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
400 const scoped_refptr<media::VideoFrame>& video_frame) { | 400 const scoped_refptr<media::VideoFrame>& video_frame) { |
401 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); | 401 TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForHardwarePlanes"); |
402 media::VideoFrame::Format frame_format = video_frame->format(); | 402 media::VideoFrame::Format frame_format = video_frame->format(); |
403 | 403 |
404 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); | 404 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); |
405 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) | |
406 return VideoFrameExternalResources(); | |
407 | |
408 if (!context_provider_) | 405 if (!context_provider_) |
409 return VideoFrameExternalResources(); | 406 return VideoFrameExternalResources(); |
410 | 407 |
411 DCHECK_EQ(1u, media::VideoFrame::NumTextures(video_frame->texture_format())); | 408 size_t textures = |
412 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); | 409 media::VideoFrame::NumTextures(video_frame->texture_format()); |
410 DCHECK_GE(textures, 1u); | |
413 VideoFrameExternalResources external_resources; | 411 VideoFrameExternalResources external_resources; |
414 switch (mailbox_holder.texture_target) { | 412 switch (video_frame->texture_format()) { |
415 case GL_TEXTURE_2D: | 413 case media::VideoFrame::TEXTURE_RGBA: |
416 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; | 414 DCHECK_EQ(1u, textures); |
415 switch (video_frame->mailbox_holder(0).texture_target) { | |
416 case GL_TEXTURE_2D: | |
417 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; | |
418 break; | |
419 case GL_TEXTURE_EXTERNAL_OES: | |
420 external_resources.type = | |
421 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; | |
422 break; | |
423 case GL_TEXTURE_RECTANGLE_ARB: | |
424 external_resources.type = VideoFrameExternalResources::IO_SURFACE; | |
425 break; | |
426 default: | |
427 NOTREACHED(); | |
428 return VideoFrameExternalResources(); | |
429 } | |
417 break; | 430 break; |
418 case GL_TEXTURE_EXTERNAL_OES: | 431 case media::VideoFrame::TEXTURE_YUV_420: |
419 external_resources.type = | 432 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; |
420 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; | |
421 break; | 433 break; |
422 case GL_TEXTURE_RECTANGLE_ARB: | |
423 external_resources.type = VideoFrameExternalResources::IO_SURFACE; | |
424 break; | |
425 default: | |
426 NOTREACHED(); | |
427 return VideoFrameExternalResources(); | |
428 } | 434 } |
435 DCHECK_NE(VideoFrameExternalResources::NONE, external_resources.type); | |
hendrikw
2015/05/11 22:19:45
Would you mind moving the switch to a separate fun
| |
429 | 436 |
430 external_resources.mailboxes.push_back( | 437 for (size_t i = 0; i < textures; ++i) { |
431 TextureMailbox(mailbox_holder.mailbox, mailbox_holder.texture_target, | 438 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(i); |
432 mailbox_holder.sync_point)); | 439 external_resources.mailboxes.push_back( |
433 external_resources.mailboxes.back().set_allow_overlay( | 440 TextureMailbox(mailbox_holder.mailbox, mailbox_holder.texture_target, |
434 video_frame->allow_overlay()); | 441 mailbox_holder.sync_point)); |
435 external_resources.release_callbacks.push_back( | 442 external_resources.mailboxes.back().set_allow_overlay( |
436 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); | 443 video_frame->allow_overlay()); |
444 external_resources.release_callbacks.push_back( | |
445 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); | |
446 } | |
437 return external_resources; | 447 return external_resources; |
438 } | 448 } |
439 | 449 |
440 // static | 450 // static |
441 void VideoResourceUpdater::RecycleResource( | 451 void VideoResourceUpdater::RecycleResource( |
442 base::WeakPtr<VideoResourceUpdater> updater, | 452 base::WeakPtr<VideoResourceUpdater> updater, |
443 ResourceProvider::ResourceId resource_id, | 453 ResourceProvider::ResourceId resource_id, |
444 uint32 sync_point, | 454 uint32 sync_point, |
445 bool lost_resource, | 455 bool lost_resource, |
446 BlockingTaskRunner* main_thread_task_runner) { | 456 BlockingTaskRunner* main_thread_task_runner) { |
(...skipping 19 matching lines...) Expand all Loading... | |
466 resource_it->ref_count = 0; | 476 resource_it->ref_count = 0; |
467 updater->DeleteResource(resource_it); | 477 updater->DeleteResource(resource_it); |
468 return; | 478 return; |
469 } | 479 } |
470 | 480 |
471 --resource_it->ref_count; | 481 --resource_it->ref_count; |
472 DCHECK_GE(resource_it->ref_count, 0); | 482 DCHECK_GE(resource_it->ref_count, 0); |
473 } | 483 } |
474 | 484 |
475 } // namespace cc | 485 } // namespace cc |
OLD | NEW |