| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "base/trace_event/trace_event_argument.h" | 14 #include "base/trace_event/trace_event_argument.h" |
| 15 #include "cc/quads/render_pass.h" | 15 #include "cc/quads/render_pass.h" |
| 16 #include "cc/quads/shared_quad_state.h" | 16 #include "cc/quads/shared_quad_state.h" |
| 17 #include "cc/quads/solid_color_draw_quad.h" | 17 #include "cc/quads/solid_color_draw_quad.h" |
| 18 #include "cc/quads/texture_draw_quad.h" | 18 #include "cc/quads/texture_draw_quad.h" |
| 19 #include "cc/resources/single_release_callback.h" | 19 #include "cc/resources/single_release_callback.h" |
| 20 #include "cc/surfaces/direct_surface_embedding.h" |
| 20 #include "cc/surfaces/surface.h" | 21 #include "cc/surfaces/surface.h" |
| 21 #include "cc/surfaces/surface_factory.h" | 22 #include "cc/surfaces/surface_factory.h" |
| 22 #include "cc/surfaces/surface_id_allocator.h" | 23 #include "cc/surfaces/surface_id_allocator.h" |
| 23 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
| 24 #include "components/exo/buffer.h" | 25 #include "components/exo/buffer.h" |
| 25 #include "components/exo/surface_delegate.h" | 26 #include "components/exo/surface_delegate.h" |
| 26 #include "components/exo/surface_observer.h" | 27 #include "components/exo/surface_observer.h" |
| 27 #include "third_party/khronos/GLES2/gl2.h" | 28 #include "third_party/khronos/GLES2/gl2.h" |
| 28 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
| 29 #include "ui/aura/window_delegate.h" | 30 #include "ui/aura/window_delegate.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 if (window->parent()) | 135 if (window->parent()) |
| 135 aura::Window::ConvertPointToTarget(window->parent(), window, | 136 aura::Window::ConvertPointToTarget(window->parent(), window, |
| 136 &local_point); | 137 &local_point); |
| 137 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); | 138 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); |
| 138 } | 139 } |
| 139 | 140 |
| 140 private: | 141 private: |
| 141 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); | 142 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 void SatisfyCallback(cc::SurfaceManager* manager, | |
| 145 const cc::SurfaceSequence& sequence) { | |
| 146 std::vector<uint32_t> sequences; | |
| 147 sequences.push_back(sequence.sequence); | |
| 148 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); | |
| 149 } | |
| 150 | |
| 151 void RequireCallback(cc::SurfaceManager* manager, | |
| 152 const cc::SurfaceId& id, | |
| 153 const cc::SurfaceSequence& sequence) { | |
| 154 cc::Surface* surface = manager->GetSurfaceForId(id); | |
| 155 if (!surface) { | |
| 156 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | |
| 157 return; | |
| 158 } | |
| 159 surface->AddDestructionDependency(sequence); | |
| 160 } | |
| 161 | |
| 162 } // namespace | 145 } // namespace |
| 163 | 146 |
| 164 //////////////////////////////////////////////////////////////////////////////// | 147 //////////////////////////////////////////////////////////////////////////////// |
| 165 // SurfaceFactoryOwner, public: | 148 // SurfaceFactoryOwner, public: |
| 166 | 149 |
| 167 SurfaceFactoryOwner::SurfaceFactoryOwner() {} | 150 SurfaceFactoryOwner::SurfaceFactoryOwner() {} |
| 168 | 151 |
| 169 //////////////////////////////////////////////////////////////////////////////// | 152 //////////////////////////////////////////////////////////////////////////////// |
| 170 // cc::SurfaceFactoryClient overrides: | 153 // cc::SurfaceFactoryClient overrides: |
| 171 | 154 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 464 |
| 482 UpdateSurface(true); | 465 UpdateSurface(true); |
| 483 | 466 |
| 484 if (old_local_frame_id != local_frame_id_) { | 467 if (old_local_frame_id != local_frame_id_) { |
| 485 float contents_surface_to_layer_scale = 1.0; | 468 float contents_surface_to_layer_scale = 1.0; |
| 486 // The bounds must be updated before switching to the new surface, because | 469 // The bounds must be updated before switching to the new surface, because |
| 487 // the layer may be mirrored, in which case a surface change causes the | 470 // the layer may be mirrored, in which case a surface change causes the |
| 488 // mirror layer to update its surface using the latest bounds. | 471 // mirror layer to update its surface using the latest bounds. |
| 489 window_->layer()->SetBounds( | 472 window_->layer()->SetBounds( |
| 490 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); | 473 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); |
| 491 window_->layer()->SetShowSurface( | 474 cc::SurfaceId surface_id(factory_owner_->frame_sink_id_, local_frame_id_); |
| 492 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), | 475 cc::SurfaceInfo surface_info(surface_id, contents_surface_to_layer_scale, |
| 493 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), | 476 content_size_); |
| 494 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), | 477 auto surface_ref = base::MakeUnique<cc::DirectSurfaceEmbedding>( |
| 495 content_size_, contents_surface_to_layer_scale, content_size_); | 478 surface_info, surface_manager_); |
| 479 window_->layer()->SetShowSurface(std::move(surface_ref), content_size_); |
| 496 window_->layer()->SetFillsBoundsOpaquely( | 480 window_->layer()->SetFillsBoundsOpaquely( |
| 497 state_.blend_mode == SkBlendMode::kSrc || | 481 state_.blend_mode == SkBlendMode::kSrc || |
| 498 state_.opaque_region.contains( | 482 state_.opaque_region.contains( |
| 499 gfx::RectToSkIRect(gfx::Rect(content_size_)))); | 483 gfx::RectToSkIRect(gfx::Rect(content_size_)))); |
| 500 } | 484 } |
| 501 | 485 |
| 502 // Reset damage. | 486 // Reset damage. |
| 503 pending_damage_.setEmpty(); | 487 pending_damage_.setEmpty(); |
| 504 | 488 |
| 505 DCHECK(!current_resource_.id || | 489 DCHECK(!current_resource_.id || |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 | 857 |
| 874 int64_t Surface::GetPropertyInternal(const void* key, | 858 int64_t Surface::GetPropertyInternal(const void* key, |
| 875 int64_t default_value) const { | 859 int64_t default_value) const { |
| 876 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 860 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 877 if (iter == prop_map_.end()) | 861 if (iter == prop_map_.end()) |
| 878 return default_value; | 862 return default_value; |
| 879 return iter->second.value; | 863 return iter->second.value; |
| 880 } | 864 } |
| 881 | 865 |
| 882 } // namespace exo | 866 } // namespace exo |
| OLD | NEW |