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 bound_graphics_3d_->ReturnFrontBuffer( | 781 committed_texture_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_; |
787 committed_texture_consumed_sync_token_ = gpu::SyncToken(); | 788 committed_texture_consumed_sync_token_ = gpu::SyncToken(); |
788 | 789 |
789 if (!texture_layer_) { | 790 if (!texture_layer_) { |
790 UpdateLayer(true); | 791 UpdateLayer(true); |
791 return; | 792 return; |
792 } | 793 } |
793 | 794 |
794 PassCommittedTextureToTextureLayer(); | 795 PassCommittedTextureToTextureLayer(); |
795 texture_layer_->SetNeedsDisplay(); | 796 texture_layer_->SetNeedsDisplay(); |
796 } | 797 } |
797 | 798 |
798 void PepperPluginInstanceImpl::PassCommittedTextureToTextureLayer() { | 799 void PepperPluginInstanceImpl::PassCommittedTextureToTextureLayer() { |
799 DCHECK(bound_graphics_3d_); | 800 DCHECK(bound_graphics_3d_); |
800 | 801 |
801 if (!committed_texture_.IsValid()) | 802 if (!committed_texture_.IsValid()) |
802 return; | 803 return; |
803 | 804 |
804 std::unique_ptr<cc::SingleReleaseCallback> callback( | 805 std::unique_ptr<cc::SingleReleaseCallback> callback( |
805 cc::SingleReleaseCallback::Create(base::Bind( | 806 cc::SingleReleaseCallback::Create(base::Bind( |
806 &PepperPluginInstanceImpl::FinishedConsumingCommittedTexture, | 807 &PepperPluginInstanceImpl::FinishedConsumingCommittedTexture, |
807 weak_factory_.GetWeakPtr(), committed_texture_))); | 808 weak_factory_.GetWeakPtr(), committed_texture_, |
| 809 committed_texture_graphics_3d_))); |
808 | 810 |
809 IncrementTextureReferenceCount(committed_texture_); | 811 IncrementTextureReferenceCount(committed_texture_); |
810 texture_layer_->SetTextureMailbox(committed_texture_, std::move(callback)); | 812 texture_layer_->SetTextureMailbox(committed_texture_, std::move(callback)); |
811 } | 813 } |
812 | 814 |
813 void PepperPluginInstanceImpl::FinishedConsumingCommittedTexture( | 815 void PepperPluginInstanceImpl::FinishedConsumingCommittedTexture( |
814 const cc::TextureMailbox& texture_mailbox, | 816 const cc::TextureMailbox& texture_mailbox, |
| 817 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d, |
815 const gpu::SyncToken& sync_token, | 818 const gpu::SyncToken& sync_token, |
816 bool is_lost) { | 819 bool is_lost) { |
817 bool removed = DecrementTextureReferenceCount(texture_mailbox); | 820 bool removed = DecrementTextureReferenceCount(texture_mailbox); |
818 bool is_committed_texture = | 821 bool is_committed_texture = |
819 committed_texture_.mailbox() == texture_mailbox.mailbox(); | 822 committed_texture_.mailbox() == texture_mailbox.mailbox(); |
820 | 823 |
821 if (is_committed_texture && !is_lost) { | 824 if (is_committed_texture && !is_lost) { |
822 committed_texture_consumed_sync_token_ = sync_token; | 825 committed_texture_consumed_sync_token_ = sync_token; |
823 return; | 826 return; |
824 } | 827 } |
825 | 828 |
826 if (removed && !is_committed_texture) { | 829 if (removed && !is_committed_texture) { |
827 bound_graphics_3d_->ReturnFrontBuffer(texture_mailbox.mailbox(), sync_token, | 830 graphics_3d->ReturnFrontBuffer(texture_mailbox.mailbox(), sync_token, |
828 is_lost); | 831 is_lost); |
829 } | 832 } |
830 } | 833 } |
831 | 834 |
832 void PepperPluginInstanceImpl::InstanceCrashed() { | 835 void PepperPluginInstanceImpl::InstanceCrashed() { |
833 // Force free all resources and vars. | 836 // Force free all resources and vars. |
834 HostGlobals::Get()->InstanceCrashed(pp_instance()); | 837 HostGlobals::Get()->InstanceCrashed(pp_instance()); |
835 | 838 |
836 // Free any associated graphics. | 839 // Free any associated graphics. |
837 SetFullscreen(false); | 840 SetFullscreen(false); |
838 FlashSetFullscreen(false, false); | 841 FlashSetFullscreen(false, false); |
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3416 const cc::TextureMailbox& mailbox) const { | 3419 const cc::TextureMailbox& mailbox) const { |
3417 auto it = | 3420 auto it = |
3418 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), | 3421 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), |
3419 [&mailbox](const TextureMailboxRefCount& ref_count) { | 3422 [&mailbox](const TextureMailboxRefCount& ref_count) { |
3420 return ref_count.first.mailbox() == mailbox.mailbox(); | 3423 return ref_count.first.mailbox() == mailbox.mailbox(); |
3421 }); | 3424 }); |
3422 return it != texture_ref_counts_.end(); | 3425 return it != texture_ref_counts_.end(); |
3423 } | 3426 } |
3424 | 3427 |
3425 } // namespace content | 3428 } // namespace content |
OLD | NEW |