Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: components/exo/surface.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (window->parent()) 134 if (window->parent())
135 aura::Window::ConvertPointToTarget(window->parent(), window, 135 aura::Window::ConvertPointToTarget(window->parent(), window,
136 &local_point); 136 &local_point);
137 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); 137 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1)));
138 } 138 }
139 139
140 private: 140 private:
141 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); 141 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter);
142 }; 142 };
143 143
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 144 } // namespace
163 145
164 //////////////////////////////////////////////////////////////////////////////// 146 ////////////////////////////////////////////////////////////////////////////////
165 // SurfaceFactoryOwner, public: 147 // SurfaceFactoryOwner, public:
166 148
167 SurfaceFactoryOwner::SurfaceFactoryOwner() {} 149 SurfaceFactoryOwner::SurfaceFactoryOwner() {}
168 150
169 //////////////////////////////////////////////////////////////////////////////// 151 ////////////////////////////////////////////////////////////////////////////////
170 // cc::SurfaceFactoryClient overrides: 152 // cc::SurfaceFactoryClient overrides:
171 153
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 463
482 UpdateSurface(true); 464 UpdateSurface(true);
483 465
484 if (old_local_frame_id != local_frame_id_) { 466 if (old_local_frame_id != local_frame_id_) {
485 float contents_surface_to_layer_scale = 1.0; 467 float contents_surface_to_layer_scale = 1.0;
486 // The bounds must be updated before switching to the new surface, because 468 // 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 469 // the layer may be mirrored, in which case a surface change causes the
488 // mirror layer to update its surface using the latest bounds. 470 // mirror layer to update its surface using the latest bounds.
489 window_->layer()->SetBounds( 471 window_->layer()->SetBounds(
490 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); 472 gfx::Rect(window_->layer()->bounds().origin(), content_size_));
491 window_->layer()->SetShowSurface( 473 cc::SurfaceRefPtr surface_ref = surface_manager_->NewSurfaceRef(
492 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), 474 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_),
493 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), 475 contents_surface_to_layer_scale, content_size_);
494 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), 476 window_->layer()->SetShowSurface(std::move(surface_ref), content_size_);
495 content_size_, contents_surface_to_layer_scale, content_size_);
496 window_->layer()->SetFillsBoundsOpaquely( 477 window_->layer()->SetFillsBoundsOpaquely(
497 state_.blend_mode == SkBlendMode::kSrc || 478 state_.blend_mode == SkBlendMode::kSrc ||
498 state_.opaque_region.contains( 479 state_.opaque_region.contains(
499 gfx::RectToSkIRect(gfx::Rect(content_size_)))); 480 gfx::RectToSkIRect(gfx::Rect(content_size_))));
500 } 481 }
501 482
502 // Reset damage. 483 // Reset damage.
503 pending_damage_.setEmpty(); 484 pending_damage_.setEmpty();
504 485
505 DCHECK(!current_resource_.id || 486 DCHECK(!current_resource_.id ||
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 854
874 int64_t Surface::GetPropertyInternal(const void* key, 855 int64_t Surface::GetPropertyInternal(const void* key,
875 int64_t default_value) const { 856 int64_t default_value) const {
876 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); 857 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
877 if (iter == prop_map_.end()) 858 if (iter == prop_map_.end())
878 return default_value; 859 return default_value;
879 return iter->second.value; 860 return iter->second.value;
880 } 861 }
881 862
882 } // namespace exo 863 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698