| 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 11 matching lines...) Expand all Loading... |
| 22 namespace cc { | 22 namespace cc { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const ResourceFormat kRGBResourceFormat = RGBA_8888; | 26 const ResourceFormat kRGBResourceFormat = RGBA_8888; |
| 27 | 27 |
| 28 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { | 28 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { |
| 29 public: | 29 public: |
| 30 explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {} | 30 explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {} |
| 31 ~SyncPointClientImpl() override {} | 31 ~SyncPointClientImpl() override {} |
| 32 uint32 InsertSyncPoint() override { | 32 uint32 InsertSyncPoint() override { return gl_->InsertSyncPointCHROMIUM(); } |
| 33 return GLC(gl_, gl_->InsertSyncPointCHROMIUM()); | |
| 34 } | |
| 35 void WaitSyncPoint(uint32 sync_point) override { | 33 void WaitSyncPoint(uint32 sync_point) override { |
| 36 GLC(gl_, gl_->WaitSyncPointCHROMIUM(sync_point)); | 34 gl_->WaitSyncPointCHROMIUM(sync_point); |
| 37 } | 35 } |
| 38 | 36 |
| 39 private: | 37 private: |
| 40 gpu::gles2::GLES2Interface* gl_; | 38 gpu::gles2::GLES2Interface* gl_; |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 } // namespace | 41 } // namespace |
| 44 | 42 |
| 45 VideoResourceUpdater::PlaneResource::PlaneResource( | 43 VideoResourceUpdater::PlaneResource::PlaneResource( |
| 46 unsigned int resource_id, | 44 unsigned int resource_id, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 99 ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
| 102 if (resource_id == 0) | 100 if (resource_id == 0) |
| 103 return all_resources_.end(); | 101 return all_resources_.end(); |
| 104 | 102 |
| 105 gpu::Mailbox mailbox; | 103 gpu::Mailbox mailbox; |
| 106 if (has_mailbox) { | 104 if (has_mailbox) { |
| 107 DCHECK(context_provider_); | 105 DCHECK(context_provider_); |
| 108 | 106 |
| 109 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 107 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 110 | 108 |
| 111 GLC(gl, gl->GenMailboxCHROMIUM(mailbox.name)); | 109 gl->GenMailboxCHROMIUM(mailbox.name); |
| 112 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id); | 110 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id); |
| 113 GLC(gl, gl->ProduceTextureDirectCHROMIUM(lock.texture_id(), GL_TEXTURE_2D, | 111 gl->ProduceTextureDirectCHROMIUM(lock.texture_id(), GL_TEXTURE_2D, |
| 114 mailbox.name)); | 112 mailbox.name); |
| 115 } | 113 } |
| 116 all_resources_.push_front( | 114 all_resources_.push_front( |
| 117 PlaneResource(resource_id, plane_size, format, mailbox)); | 115 PlaneResource(resource_id, plane_size, format, mailbox)); |
| 118 return all_resources_.begin(); | 116 return all_resources_.begin(); |
| 119 } | 117 } |
| 120 | 118 |
| 121 void VideoResourceUpdater::DeleteResource(ResourceList::iterator resource_it) { | 119 void VideoResourceUpdater::DeleteResource(ResourceList::iterator resource_it) { |
| 122 DCHECK_EQ(resource_it->ref_count, 0); | 120 DCHECK_EQ(resource_it->ref_count, 0); |
| 123 resource_provider_->DeleteResource(resource_it->resource_id); | 121 resource_provider_->DeleteResource(resource_it->resource_id); |
| 124 all_resources_.erase(resource_it); | 122 all_resources_.erase(resource_it); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 const ResourceList::iterator resource_it = std::find_if( | 438 const ResourceList::iterator resource_it = std::find_if( |
| 441 updater->all_resources_.begin(), updater->all_resources_.end(), | 439 updater->all_resources_.begin(), updater->all_resources_.end(), |
| 442 [resource_id](const PlaneResource& plane_resource) { | 440 [resource_id](const PlaneResource& plane_resource) { |
| 443 return plane_resource.resource_id == resource_id; | 441 return plane_resource.resource_id == resource_id; |
| 444 }); | 442 }); |
| 445 if (resource_it == updater->all_resources_.end()) | 443 if (resource_it == updater->all_resources_.end()) |
| 446 return; | 444 return; |
| 447 | 445 |
| 448 ContextProvider* context_provider = updater->context_provider_; | 446 ContextProvider* context_provider = updater->context_provider_; |
| 449 if (context_provider && sync_point) { | 447 if (context_provider && sync_point) { |
| 450 GLC(context_provider->ContextGL(), | 448 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point); |
| 451 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point)); | |
| 452 } | 449 } |
| 453 | 450 |
| 454 if (lost_resource) { | 451 if (lost_resource) { |
| 455 resource_it->ref_count = 0; | 452 resource_it->ref_count = 0; |
| 456 updater->DeleteResource(resource_it); | 453 updater->DeleteResource(resource_it); |
| 457 return; | 454 return; |
| 458 } | 455 } |
| 459 | 456 |
| 460 --resource_it->ref_count; | 457 --resource_it->ref_count; |
| 461 DCHECK_GE(resource_it->ref_count, 0); | 458 DCHECK_GE(resource_it->ref_count, 0); |
| 462 } | 459 } |
| 463 | 460 |
| 464 } // namespace cc | 461 } // namespace cc |
| OLD | NEW |