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 } |
hendrikw
2015/05/11 18:53:39
You should probably have a default and NOTREACHED(
Daniele Castagna
2015/05/11 19:09:12
We opted to add a DCHECK to verify that extenral_r
| |
429 | 435 |
430 external_resources.mailboxes.push_back( | 436 for (size_t i = 0; i < textures; ++i) { |
431 TextureMailbox(mailbox_holder.mailbox, mailbox_holder.texture_target, | 437 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(i); |
432 mailbox_holder.sync_point)); | 438 external_resources.mailboxes.push_back( |
433 external_resources.mailboxes.back().set_allow_overlay( | 439 TextureMailbox(mailbox_holder.mailbox, mailbox_holder.texture_target, |
434 video_frame->allow_overlay()); | 440 mailbox_holder.sync_point)); |
435 external_resources.release_callbacks.push_back( | 441 external_resources.mailboxes.back().set_allow_overlay( |
436 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); | 442 video_frame->allow_overlay()); |
443 external_resources.release_callbacks.push_back( | |
444 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); | |
445 } | |
437 return external_resources; | 446 return external_resources; |
438 } | 447 } |
439 | 448 |
440 // static | 449 // static |
441 void VideoResourceUpdater::RecycleResource( | 450 void VideoResourceUpdater::RecycleResource( |
442 base::WeakPtr<VideoResourceUpdater> updater, | 451 base::WeakPtr<VideoResourceUpdater> updater, |
443 ResourceProvider::ResourceId resource_id, | 452 ResourceProvider::ResourceId resource_id, |
444 uint32 sync_point, | 453 uint32 sync_point, |
445 bool lost_resource, | 454 bool lost_resource, |
446 BlockingTaskRunner* main_thread_task_runner) { | 455 BlockingTaskRunner* main_thread_task_runner) { |
(...skipping 19 matching lines...) Expand all Loading... | |
466 resource_it->ref_count = 0; | 475 resource_it->ref_count = 0; |
467 updater->DeleteResource(resource_it); | 476 updater->DeleteResource(resource_it); |
468 return; | 477 return; |
469 } | 478 } |
470 | 479 |
471 --resource_it->ref_count; | 480 --resource_it->ref_count; |
472 DCHECK_GE(resource_it->ref_count, 0); | 481 DCHECK_GE(resource_it->ref_count, 0); |
473 } | 482 } |
474 | 483 |
475 } // namespace cc | 484 } // namespace cc |
OLD | NEW |