OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/surface.h" | 5 #include "components/exo/surface.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 } | 651 } |
652 | 652 |
653 void Surface::SetSurfaceHierarchyNeedsCommitToNewSurfaces() { | 653 void Surface::SetSurfaceHierarchyNeedsCommitToNewSurfaces() { |
654 needs_commit_to_new_surface_ = true; | 654 needs_commit_to_new_surface_ = true; |
655 for (auto& sub_surface_entry : pending_sub_surfaces_) { | 655 for (auto& sub_surface_entry : pending_sub_surfaces_) { |
656 sub_surface_entry.first->SetSurfaceHierarchyNeedsCommitToNewSurfaces(); | 656 sub_surface_entry.first->SetSurfaceHierarchyNeedsCommitToNewSurfaces(); |
657 } | 657 } |
658 } | 658 } |
659 | 659 |
660 void Surface::UpdateResource(bool client_usage) { | 660 void Surface::UpdateResource(bool client_usage) { |
661 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; | 661 if (!current_buffer_.buffer() || |
662 | 662 !current_buffer_.buffer()->ProduceTransferableResource( |
663 cc::TextureMailbox texture_mailbox; | 663 compositor_frame_sink_holder_.get(), next_resource_id_++, |
664 if (current_buffer_.buffer()) { | 664 state_.only_visible_on_secure_output, client_usage, |
665 texture_mailbox_release_callback = | 665 ¤t_resource_)) { |
666 current_buffer_.buffer()->ProduceTextureMailbox( | |
667 &texture_mailbox, state_.only_visible_on_secure_output, | |
668 client_usage); | |
669 } | |
670 | |
671 if (texture_mailbox_release_callback) { | |
672 cc::TransferableResource resource; | |
673 resource.id = next_resource_id_++; | |
674 resource.format = cc::RGBA_8888; | |
675 resource.filter = | |
676 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; | |
677 resource.size = texture_mailbox.size_in_pixels(); | |
678 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), | |
679 texture_mailbox.sync_token(), | |
680 texture_mailbox.target()); | |
681 resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate(); | |
682 | |
683 compositor_frame_sink_holder_->AddResourceReleaseCallback( | |
684 resource.id, std::move(texture_mailbox_release_callback)); | |
685 current_resource_ = resource; | |
686 } else { | |
687 current_resource_.id = 0; | 666 current_resource_.id = 0; |
688 current_resource_.size = gfx::Size(); | 667 current_resource_.size = gfx::Size(); |
689 } | 668 } |
690 } | 669 } |
691 | 670 |
692 void Surface::UpdateSurface(bool full_damage) { | 671 void Surface::UpdateSurface(bool full_damage) { |
693 gfx::Size buffer_size = current_resource_.size; | 672 gfx::Size buffer_size = current_resource_.size; |
694 gfx::SizeF scaled_buffer_size( | 673 gfx::SizeF scaled_buffer_size( |
695 gfx::ScaleSize(gfx::SizeF(buffer_size), 1.0f / state_.buffer_scale)); | 674 gfx::ScaleSize(gfx::SizeF(buffer_size), 1.0f / state_.buffer_scale)); |
696 | 675 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 | 774 |
796 int64_t Surface::GetPropertyInternal(const void* key, | 775 int64_t Surface::GetPropertyInternal(const void* key, |
797 int64_t default_value) const { | 776 int64_t default_value) const { |
798 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 777 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
799 if (iter == prop_map_.end()) | 778 if (iter == prop_map_.end()) |
800 return default_value; | 779 return default_value; |
801 return iter->second.value; | 780 return iter->second.value; |
802 } | 781 } |
803 | 782 |
804 } // namespace exo | 783 } // namespace exo |
OLD | NEW |