| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bit_cast.h" | 10 #include "base/bit_cast.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 // of us or the view renders via the accelerated compositor which is | 771 // of us or the view renders via the accelerated compositor which is |
| 772 // incompatible with the move and backfill scrolling model. | 772 // incompatible with the move and backfill scrolling model. |
| 773 InvalidateRect(rect); | 773 InvalidateRect(rect); |
| 774 } | 774 } |
| 775 } | 775 } |
| 776 } | 776 } |
| 777 | 777 |
| 778 void PepperPluginInstanceImpl::CommitTextureMailbox( | 778 void PepperPluginInstanceImpl::CommitTextureMailbox( |
| 779 const cc::TextureMailbox& texture_mailbox) { | 779 const cc::TextureMailbox& texture_mailbox) { |
| 780 if (committed_texture_.IsValid() && !IsTextureInUse(committed_texture_)) { | 780 if (committed_texture_.IsValid() && !IsTextureInUse(committed_texture_)) { |
| 781 committed_texture_graphics_3d_->ReturnFrontBuffer( | 781 bound_graphics_3d_->ReturnFrontBuffer( |
| 782 committed_texture_.mailbox(), committed_texture_consumed_sync_token_, | 782 committed_texture_.mailbox(), committed_texture_consumed_sync_token_, |
| 783 false); | 783 false); |
| 784 } | 784 } |
| 785 | 785 |
| 786 committed_texture_ = texture_mailbox; | 786 committed_texture_ = texture_mailbox; |
| 787 committed_texture_graphics_3d_ = bound_graphics_3d_; | |
| 788 committed_texture_consumed_sync_token_ = gpu::SyncToken(); | 787 committed_texture_consumed_sync_token_ = gpu::SyncToken(); |
| 789 | 788 |
| 790 if (!texture_layer_) { | 789 if (!texture_layer_) { |
| 791 UpdateLayer(true); | 790 UpdateLayer(true); |
| 792 return; | 791 return; |
| 793 } | 792 } |
| 794 | 793 |
| 795 PassCommittedTextureToTextureLayer(); | 794 PassCommittedTextureToTextureLayer(); |
| 796 texture_layer_->SetNeedsDisplay(); | 795 texture_layer_->SetNeedsDisplay(); |
| 797 } | 796 } |
| 798 | 797 |
| 799 void PepperPluginInstanceImpl::PassCommittedTextureToTextureLayer() { | 798 void PepperPluginInstanceImpl::PassCommittedTextureToTextureLayer() { |
| 800 DCHECK(bound_graphics_3d_); | 799 DCHECK(bound_graphics_3d_); |
| 801 | 800 |
| 802 if (!committed_texture_.IsValid()) | 801 if (!committed_texture_.IsValid()) |
| 803 return; | 802 return; |
| 804 | 803 |
| 805 std::unique_ptr<cc::SingleReleaseCallback> callback( | 804 std::unique_ptr<cc::SingleReleaseCallback> callback( |
| 806 cc::SingleReleaseCallback::Create(base::Bind( | 805 cc::SingleReleaseCallback::Create(base::Bind( |
| 807 &PepperPluginInstanceImpl::FinishedConsumingCommittedTexture, | 806 &PepperPluginInstanceImpl::FinishedConsumingCommittedTexture, |
| 808 weak_factory_.GetWeakPtr(), committed_texture_, | 807 weak_factory_.GetWeakPtr(), committed_texture_))); |
| 809 committed_texture_graphics_3d_))); | |
| 810 | 808 |
| 811 IncrementTextureReferenceCount(committed_texture_); | 809 IncrementTextureReferenceCount(committed_texture_); |
| 812 texture_layer_->SetTextureMailbox(committed_texture_, std::move(callback)); | 810 texture_layer_->SetTextureMailbox(committed_texture_, std::move(callback)); |
| 813 } | 811 } |
| 814 | 812 |
| 815 void PepperPluginInstanceImpl::FinishedConsumingCommittedTexture( | 813 void PepperPluginInstanceImpl::FinishedConsumingCommittedTexture( |
| 816 const cc::TextureMailbox& texture_mailbox, | 814 const cc::TextureMailbox& texture_mailbox, |
| 817 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d, | |
| 818 const gpu::SyncToken& sync_token, | 815 const gpu::SyncToken& sync_token, |
| 819 bool is_lost) { | 816 bool is_lost) { |
| 820 bool removed = DecrementTextureReferenceCount(texture_mailbox); | 817 bool removed = DecrementTextureReferenceCount(texture_mailbox); |
| 821 bool is_committed_texture = | 818 bool is_committed_texture = |
| 822 committed_texture_.mailbox() == texture_mailbox.mailbox(); | 819 committed_texture_.mailbox() == texture_mailbox.mailbox(); |
| 823 | 820 |
| 824 if (is_committed_texture && !is_lost) { | 821 if (is_committed_texture && !is_lost) { |
| 825 committed_texture_consumed_sync_token_ = sync_token; | 822 committed_texture_consumed_sync_token_ = sync_token; |
| 826 return; | 823 return; |
| 827 } | 824 } |
| 828 | 825 |
| 829 if (removed && !is_committed_texture) { | 826 if (removed && !is_committed_texture) { |
| 830 graphics_3d->ReturnFrontBuffer(texture_mailbox.mailbox(), sync_token, | 827 bound_graphics_3d_->ReturnFrontBuffer(texture_mailbox.mailbox(), sync_token, |
| 831 is_lost); | 828 is_lost); |
| 832 } | 829 } |
| 833 } | 830 } |
| 834 | 831 |
| 835 void PepperPluginInstanceImpl::InstanceCrashed() { | 832 void PepperPluginInstanceImpl::InstanceCrashed() { |
| 836 // Force free all resources and vars. | 833 // Force free all resources and vars. |
| 837 HostGlobals::Get()->InstanceCrashed(pp_instance()); | 834 HostGlobals::Get()->InstanceCrashed(pp_instance()); |
| 838 | 835 |
| 839 // Free any associated graphics. | 836 // Free any associated graphics. |
| 840 SetFullscreen(false); | 837 SetFullscreen(false); |
| 841 FlashSetFullscreen(false, false); | 838 FlashSetFullscreen(false, false); |
| (...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 const cc::TextureMailbox& mailbox) const { | 3416 const cc::TextureMailbox& mailbox) const { |
| 3420 auto it = | 3417 auto it = |
| 3421 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), | 3418 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), |
| 3422 [&mailbox](const TextureMailboxRefCount& ref_count) { | 3419 [&mailbox](const TextureMailboxRefCount& ref_count) { |
| 3423 return ref_count.first.mailbox() == mailbox.mailbox(); | 3420 return ref_count.first.mailbox() == mailbox.mailbox(); |
| 3424 }); | 3421 }); |
| 3425 return it != texture_ref_counts_.end(); | 3422 return it != texture_ref_counts_.end(); |
| 3426 } | 3423 } |
| 3427 | 3424 |
| 3428 } // namespace content | 3425 } // namespace content |
| OLD | NEW |