| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 for (const PlaneResource& plane_resource : all_resources_) | 99 for (const PlaneResource& plane_resource : all_resources_) |
| 100 resource_provider_->DeleteResource(plane_resource.resource_id); | 100 resource_provider_->DeleteResource(plane_resource.resource_id); |
| 101 } | 101 } |
| 102 | 102 |
| 103 VideoResourceUpdater::ResourceList::iterator | 103 VideoResourceUpdater::ResourceList::iterator |
| 104 VideoResourceUpdater::AllocateResource(const gfx::Size& plane_size, | 104 VideoResourceUpdater::AllocateResource(const gfx::Size& plane_size, |
| 105 ResourceFormat format, | 105 ResourceFormat format, |
| 106 bool has_mailbox) { | 106 bool has_mailbox) { |
| 107 // TODO(danakj): Abstract out hw/sw resource create/delete from | 107 // TODO(danakj): Abstract out hw/sw resource create/delete from |
| 108 // ResourceProvider and stop using ResourceProvider in this class. | 108 // ResourceProvider and stop using ResourceProvider in this class. |
| 109 const ResourceProvider::ResourceId resource_id = | 109 const ResourceId resource_id = resource_provider_->CreateResource( |
| 110 resource_provider_->CreateResource( | 110 plane_size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 111 plane_size, GL_CLAMP_TO_EDGE, | 111 format); |
| 112 ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | |
| 113 if (resource_id == 0) | 112 if (resource_id == 0) |
| 114 return all_resources_.end(); | 113 return all_resources_.end(); |
| 115 | 114 |
| 116 gpu::Mailbox mailbox; | 115 gpu::Mailbox mailbox; |
| 117 if (has_mailbox) { | 116 if (has_mailbox) { |
| 118 DCHECK(context_provider_); | 117 DCHECK(context_provider_); |
| 119 | 118 |
| 120 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 119 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 121 | 120 |
| 122 gl->GenMailboxCHROMIUM(mailbox.name); | 121 gl->GenMailboxCHROMIUM(mailbox.name); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 video_frame->allow_overlay()); | 447 video_frame->allow_overlay()); |
| 449 external_resources.release_callbacks.push_back( | 448 external_resources.release_callbacks.push_back( |
| 450 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); | 449 base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); |
| 451 } | 450 } |
| 452 return external_resources; | 451 return external_resources; |
| 453 } | 452 } |
| 454 | 453 |
| 455 // static | 454 // static |
| 456 void VideoResourceUpdater::RecycleResource( | 455 void VideoResourceUpdater::RecycleResource( |
| 457 base::WeakPtr<VideoResourceUpdater> updater, | 456 base::WeakPtr<VideoResourceUpdater> updater, |
| 458 ResourceProvider::ResourceId resource_id, | 457 ResourceId resource_id, |
| 459 uint32 sync_point, | 458 uint32 sync_point, |
| 460 bool lost_resource, | 459 bool lost_resource, |
| 461 BlockingTaskRunner* main_thread_task_runner) { | 460 BlockingTaskRunner* main_thread_task_runner) { |
| 462 if (!updater.get()) { | 461 if (!updater.get()) { |
| 463 // Resource was already deleted. | 462 // Resource was already deleted. |
| 464 return; | 463 return; |
| 465 } | 464 } |
| 466 | 465 |
| 467 const ResourceList::iterator resource_it = std::find_if( | 466 const ResourceList::iterator resource_it = std::find_if( |
| 468 updater->all_resources_.begin(), updater->all_resources_.end(), | 467 updater->all_resources_.begin(), updater->all_resources_.end(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 481 resource_it->ref_count = 0; | 480 resource_it->ref_count = 0; |
| 482 updater->DeleteResource(resource_it); | 481 updater->DeleteResource(resource_it); |
| 483 return; | 482 return; |
| 484 } | 483 } |
| 485 | 484 |
| 486 --resource_it->ref_count; | 485 --resource_it->ref_count; |
| 487 DCHECK_GE(resource_it->ref_count, 0); | 486 DCHECK_GE(resource_it->ref_count, 0); |
| 488 } | 487 } |
| 489 | 488 |
| 490 } // namespace cc | 489 } // namespace cc |
| OLD | NEW |