| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) | 405 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) |
| 406 return VideoFrameExternalResources(); | 406 return VideoFrameExternalResources(); |
| 407 | 407 |
| 408 if (!context_provider_) | 408 if (!context_provider_) |
| 409 return VideoFrameExternalResources(); | 409 return VideoFrameExternalResources(); |
| 410 | 410 |
| 411 const gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); | 411 DCHECK_EQ(1u, media::VideoFrame::NumTextures(video_frame->texture_format())); |
| 412 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); |
| 412 VideoFrameExternalResources external_resources; | 413 VideoFrameExternalResources external_resources; |
| 413 switch (mailbox_holder->texture_target) { | 414 switch (mailbox_holder.texture_target) { |
| 414 case GL_TEXTURE_2D: | 415 case GL_TEXTURE_2D: |
| 415 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; | 416 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; |
| 416 break; | 417 break; |
| 417 case GL_TEXTURE_EXTERNAL_OES: | 418 case GL_TEXTURE_EXTERNAL_OES: |
| 418 external_resources.type = | 419 external_resources.type = |
| 419 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; | 420 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; |
| 420 break; | 421 break; |
| 421 case GL_TEXTURE_RECTANGLE_ARB: | 422 case GL_TEXTURE_RECTANGLE_ARB: |
| 422 external_resources.type = VideoFrameExternalResources::IO_SURFACE; | 423 external_resources.type = VideoFrameExternalResources::IO_SURFACE; |
| 423 break; | 424 break; |
| 424 default: | 425 default: |
| 425 NOTREACHED(); | 426 NOTREACHED(); |
| 426 return VideoFrameExternalResources(); | 427 return VideoFrameExternalResources(); |
| 427 } | 428 } |
| 428 | 429 |
| 429 external_resources.mailboxes.push_back( | 430 external_resources.mailboxes.push_back( |
| 430 TextureMailbox(mailbox_holder->mailbox, | 431 TextureMailbox(mailbox_holder.mailbox, mailbox_holder.texture_target, |
| 431 mailbox_holder->texture_target, | 432 mailbox_holder.sync_point)); |
| 432 mailbox_holder->sync_point)); | |
| 433 external_resources.mailboxes.back().set_allow_overlay( | 433 external_resources.mailboxes.back().set_allow_overlay( |
| 434 video_frame->allow_overlay()); | 434 video_frame->allow_overlay()); |
| 435 external_resources.release_callbacks.push_back( | 435 external_resources.release_callbacks.push_back( |
| 436 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); | 436 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); |
| 437 return external_resources; | 437 return external_resources; |
| 438 } | 438 } |
| 439 | 439 |
| 440 // static | 440 // static |
| 441 void VideoResourceUpdater::RecycleResource( | 441 void VideoResourceUpdater::RecycleResource( |
| 442 base::WeakPtr<VideoResourceUpdater> updater, | 442 base::WeakPtr<VideoResourceUpdater> updater, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 466 resource_it->ref_count = 0; | 466 resource_it->ref_count = 0; |
| 467 updater->DeleteResource(resource_it); | 467 updater->DeleteResource(resource_it); |
| 468 return; | 468 return; |
| 469 } | 469 } |
| 470 | 470 |
| 471 --resource_it->ref_count; | 471 --resource_it->ref_count; |
| 472 DCHECK_GE(resource_it->ref_count, 0); | 472 DCHECK_GE(resource_it->ref_count, 0); |
| 473 } | 473 } |
| 474 | 474 |
| 475 } // namespace cc | 475 } // namespace cc |
| OLD | NEW |