| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 253 } |
| 254 | 254 |
| 255 void Surface::Attach(Buffer* buffer) { | 255 void Surface::Attach(Buffer* buffer) { |
| 256 TRACE_EVENT1("exo", "Surface::Attach", "buffer", | 256 TRACE_EVENT1("exo", "Surface::Attach", "buffer", |
| 257 buffer ? buffer->GetSize().ToString() : "null"); | 257 buffer ? buffer->GetSize().ToString() : "null"); |
| 258 | 258 |
| 259 has_pending_contents_ = true; | 259 has_pending_contents_ = true; |
| 260 pending_buffer_.Reset(buffer ? buffer->AsWeakPtr() : base::WeakPtr<Buffer>()); | 260 pending_buffer_.Reset(buffer ? buffer->AsWeakPtr() : base::WeakPtr<Buffer>()); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void Surface::SetAcquireFence(std::unique_ptr<gfx::GpuFence> fence) { |
| 264 TRACE_EVENT1("exo", "Surface::FenceAcquire", "fence", !!fence); |
| 265 |
| 266 pending_fence_ = std::move(fence); |
| 267 } |
| 268 |
| 263 void Surface::Damage(const gfx::Rect& damage) { | 269 void Surface::Damage(const gfx::Rect& damage) { |
| 264 TRACE_EVENT1("exo", "Surface::Damage", "damage", damage.ToString()); | 270 TRACE_EVENT1("exo", "Surface::Damage", "damage", damage.ToString()); |
| 265 | 271 |
| 266 pending_damage_.op(gfx::RectToSkIRect(damage), SkRegion::kUnion_Op); | 272 pending_damage_.op(gfx::RectToSkIRect(damage), SkRegion::kUnion_Op); |
| 267 } | 273 } |
| 268 | 274 |
| 269 void Surface::RequestFrameCallback(const FrameCallback& callback) { | 275 void Surface::RequestFrameCallback(const FrameCallback& callback) { |
| 270 TRACE_EVENT0("exo", "Surface::RequestFrameCallback"); | 276 TRACE_EVENT0("exo", "Surface::RequestFrameCallback"); |
| 271 | 277 |
| 272 pending_frame_callbacks_.push_back(callback); | 278 pending_frame_callbacks_.push_back(callback); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 has_pending_layer_changes_ = false; | 465 has_pending_layer_changes_ = false; |
| 460 | 466 |
| 461 state_ = pending_state_; | 467 state_ = pending_state_; |
| 462 pending_state_.only_visible_on_secure_output = false; | 468 pending_state_.only_visible_on_secure_output = false; |
| 463 | 469 |
| 464 // We update contents if Attach() has been called since last commit. | 470 // We update contents if Attach() has been called since last commit. |
| 465 if (has_pending_contents_) { | 471 if (has_pending_contents_) { |
| 466 has_pending_contents_ = false; | 472 has_pending_contents_ = false; |
| 467 | 473 |
| 468 current_buffer_ = std::move(pending_buffer_); | 474 current_buffer_ = std::move(pending_buffer_); |
| 475 fence_ = std::move(pending_fence_); |
| 469 | 476 |
| 470 UpdateResource(true); | 477 UpdateResource(true); |
| 471 } | 478 } |
| 472 | 479 |
| 473 cc::LocalFrameId old_local_frame_id = local_frame_id_; | 480 cc::LocalFrameId old_local_frame_id = local_frame_id_; |
| 474 if (needs_commit_to_new_surface_ || local_frame_id_.is_null()) { | 481 if (needs_commit_to_new_surface_ || local_frame_id_.is_null()) { |
| 475 needs_commit_to_new_surface_ = false; | 482 needs_commit_to_new_surface_ = false; |
| 476 local_frame_id_ = factory_owner_->id_allocator_->GenerateId(); | 483 local_frame_id_ = factory_owner_->id_allocator_->GenerateId(); |
| 477 factory_owner_->surface_factory_->Create(local_frame_id_); | 484 factory_owner_->surface_factory_->Create(local_frame_id_); |
| 478 } | 485 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 layer_size, contents_surface_to_layer_scale, layer_size); | 715 layer_size, contents_surface_to_layer_scale, layer_size); |
| 709 } | 716 } |
| 710 | 717 |
| 711 void Surface::UpdateResource(bool client_usage) { | 718 void Surface::UpdateResource(bool client_usage) { |
| 712 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; | 719 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; |
| 713 | 720 |
| 714 cc::TextureMailbox texture_mailbox; | 721 cc::TextureMailbox texture_mailbox; |
| 715 if (current_buffer_.buffer()) { | 722 if (current_buffer_.buffer()) { |
| 716 texture_mailbox_release_callback = | 723 texture_mailbox_release_callback = |
| 717 current_buffer_.buffer()->ProduceTextureMailbox( | 724 current_buffer_.buffer()->ProduceTextureMailbox( |
| 718 &texture_mailbox, state_.only_visible_on_secure_output, | 725 &texture_mailbox, fence_.get(), |
| 719 client_usage); | 726 state_.only_visible_on_secure_output, client_usage); |
| 720 } | 727 } |
| 721 | 728 |
| 722 if (texture_mailbox_release_callback) { | 729 if (texture_mailbox_release_callback) { |
| 723 cc::TransferableResource resource; | 730 cc::TransferableResource resource; |
| 724 resource.id = next_resource_id_++; | 731 resource.id = next_resource_id_++; |
| 725 resource.format = cc::RGBA_8888; | 732 resource.format = cc::RGBA_8888; |
| 726 resource.filter = | 733 resource.filter = |
| 727 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; | 734 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; |
| 728 resource.size = texture_mailbox.size_in_pixels(); | 735 resource.size = texture_mailbox.size_in_pixels(); |
| 729 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), | 736 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 856 |
| 850 int64_t Surface::GetPropertyInternal(const void* key, | 857 int64_t Surface::GetPropertyInternal(const void* key, |
| 851 int64_t default_value) const { | 858 int64_t default_value) const { |
| 852 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 859 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 853 if (iter == prop_map_.end()) | 860 if (iter == prop_map_.end()) |
| 854 return default_value; | 861 return default_value; |
| 855 return iter->second.value; | 862 return iter->second.value; |
| 856 } | 863 } |
| 857 | 864 |
| 858 } // namespace exo | 865 } // namespace exo |
| OLD | NEW |