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

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

Issue 2566813002: Revert of Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: 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
« no previous file with comments | « components/exo/surface.h ('k') | components/exo/surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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/surface.h" 20 #include "cc/surfaces/surface.h"
21 #include "cc/surfaces/surface_factory.h"
21 #include "cc/surfaces/surface_id_allocator.h" 22 #include "cc/surfaces/surface_id_allocator.h"
23 #include "cc/surfaces/surface_manager.h"
22 #include "components/exo/buffer.h" 24 #include "components/exo/buffer.h"
23 #include "components/exo/surface_delegate.h" 25 #include "components/exo/surface_delegate.h"
24 #include "components/exo/surface_observer.h" 26 #include "components/exo/surface_observer.h"
25 #include "third_party/khronos/GLES2/gl2.h" 27 #include "third_party/khronos/GLES2/gl2.h"
26 #include "ui/aura/env.h" 28 #include "ui/aura/env.h"
27 #include "ui/aura/window_delegate.h" 29 #include "ui/aura/window_delegate.h"
28 #include "ui/aura/window_property.h" 30 #include "ui/aura/window_property.h"
29 #include "ui/aura/window_targeter.h" 31 #include "ui/aura/window_targeter.h"
30 #include "ui/base/cursor/cursor.h" 32 #include "ui/base/cursor/cursor.h"
31 #include "ui/base/hit_test.h" 33 #include "ui/base/hit_test.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (window->parent()) 134 if (window->parent())
133 aura::Window::ConvertPointToTarget(window->parent(), window, 135 aura::Window::ConvertPointToTarget(window->parent(), window,
134 &local_point); 136 &local_point);
135 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); 137 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1)));
136 } 138 }
137 139
138 private: 140 private:
139 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); 141 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter);
140 }; 142 };
141 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
142 } // namespace 162 } // namespace
143 163
144 //////////////////////////////////////////////////////////////////////////////// 164 ////////////////////////////////////////////////////////////////////////////////
165 // SurfaceFactoryOwner, public:
166
167 SurfaceFactoryOwner::SurfaceFactoryOwner() {}
168
169 ////////////////////////////////////////////////////////////////////////////////
170 // cc::SurfaceFactoryClient overrides:
171
172 void SurfaceFactoryOwner::ReturnResources(
173 const cc::ReturnedResourceArray& resources) {
174 scoped_refptr<SurfaceFactoryOwner> holder(this);
175 for (auto& resource : resources) {
176 auto it = release_callbacks_.find(resource.id);
177 DCHECK(it != release_callbacks_.end());
178 it->second.second->Run(resource.sync_token, resource.lost);
179 release_callbacks_.erase(it);
180 }
181 }
182
183 void SurfaceFactoryOwner::WillDrawSurface(const cc::LocalFrameId& id,
184 const gfx::Rect& damage_rect) {
185 if (surface_)
186 surface_->WillDraw();
187 }
188
189 void SurfaceFactoryOwner::SetBeginFrameSource(
190 cc::BeginFrameSource* begin_frame_source) {
191 if (surface_)
192 surface_->SetBeginFrameSource(begin_frame_source);
193 }
194
195 ////////////////////////////////////////////////////////////////////////////////
196 // SurfaceFactoryOwner, private:
197
198 SurfaceFactoryOwner::~SurfaceFactoryOwner() {
199 if (surface_factory_->manager())
200 surface_factory_->manager()->InvalidateFrameSinkId(frame_sink_id_);
201 }
202
203 ////////////////////////////////////////////////////////////////////////////////
145 // Surface, public: 204 // Surface, public:
146 205
147 Surface::Surface() 206 Surface::Surface()
148 : window_(new aura::Window(new CustomWindowDelegate(this))), 207 : window_(new aura::Window(new CustomWindowDelegate(this))),
149 frame_sink_id_( 208 surface_manager_(
150 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId()) { 209 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()),
151 cc::mojom::MojoCompositorFrameSinkClientPtr frame_sink_holder_ptr; 210 factory_owner_(new SurfaceFactoryOwner) {
152 cc::mojom::MojoCompositorFrameSinkClientRequest frame_sink_client_request =
153 mojo::GetProxy(&frame_sink_holder_ptr);
154 std::unique_ptr<CompositorFrameSink> frame_sink(new CompositorFrameSink(
155 frame_sink_id_,
156 aura::Env::GetInstance()->context_factory()->GetSurfaceManager(),
157 std::move(frame_sink_holder_ptr)));
158 compositor_frame_sink_holder_ = new CompositorFrameSinkHolder(
159 this, std::move(frame_sink), std::move(frame_sink_client_request));
160 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); 211 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
161 window_->SetName("ExoSurface"); 212 window_->SetName("ExoSurface");
162 window_->SetProperty(kSurfaceKey, this); 213 window_->SetProperty(kSurfaceKey, this);
163 window_->Init(ui::LAYER_SOLID_COLOR); 214 window_->Init(ui::LAYER_SOLID_COLOR);
164 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); 215 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter));
165 window_->set_owned_by_parent(false); 216 window_->set_owned_by_parent(false);
166 window_->AddObserver(this); 217 window_->AddObserver(this);
218 factory_owner_->surface_ = this;
219 factory_owner_->frame_sink_id_ =
220 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId();
221 factory_owner_->id_allocator_.reset(new cc::SurfaceIdAllocator());
222 surface_manager_->RegisterFrameSinkId(factory_owner_->frame_sink_id_);
223 surface_manager_->RegisterSurfaceFactoryClient(factory_owner_->frame_sink_id_,
224 factory_owner_.get());
225 factory_owner_->surface_factory_.reset(new cc::SurfaceFactory(
226 factory_owner_->frame_sink_id_, surface_manager_, factory_owner_.get()));
167 aura::Env::GetInstance()->context_factory()->AddObserver(this); 227 aura::Env::GetInstance()->context_factory()->AddObserver(this);
168 } 228 }
169 229
170 Surface::~Surface() { 230 Surface::~Surface() {
171 aura::Env::GetInstance()->context_factory()->RemoveObserver(this); 231 aura::Env::GetInstance()->context_factory()->RemoveObserver(this);
172 for (SurfaceObserver& observer : observers_) 232 for (SurfaceObserver& observer : observers_)
173 observer.OnSurfaceDestroying(this); 233 observer.OnSurfaceDestroying(this);
174 234
175 window_->RemoveObserver(this); 235 window_->RemoveObserver(this);
176 window_->layer()->SetShowSolidColorContent(); 236 window_->layer()->SetShowSolidColorContent();
177 237
238 factory_owner_->surface_ = nullptr;
239
240 // Call pending frame callbacks with a null frame time to indicate that they
241 // have been cancelled.
178 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); 242 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_);
179 compositor_frame_sink_holder_->ActivateFrameCallbacks(&frame_callbacks_); 243 active_frame_callbacks_.splice(active_frame_callbacks_.end(),
180 compositor_frame_sink_holder_->CancelFrameCallbacks(); 244 frame_callbacks_);
245 for (const auto& frame_callback : active_frame_callbacks_)
246 frame_callback.Run(base::TimeTicks());
247 if (begin_frame_source_ && needs_begin_frame_)
248 begin_frame_source_->RemoveObserver(this);
181 249
182 compositor_frame_sink_holder_->GetCompositorFrameSink()->EvictFrame(); 250 factory_owner_->surface_factory_->EvictSurface();
251
252 surface_manager_->UnregisterSurfaceFactoryClient(
253 factory_owner_->frame_sink_id_);
183 } 254 }
184 255
185 // static 256 // static
186 Surface* Surface::AsSurface(const aura::Window* window) { 257 Surface* Surface::AsSurface(const aura::Window* window) {
187 return window->GetProperty(kSurfaceKey); 258 return window->GetProperty(kSurfaceKey);
188 } 259 }
189 260
190 cc::SurfaceId Surface::GetSurfaceId() const { 261 cc::SurfaceId Surface::GetSurfaceId() const {
191 return cc::SurfaceId(frame_sink_id_, local_frame_id_); 262 return cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_);
192 } 263 }
193 264
194 void Surface::Attach(Buffer* buffer) { 265 void Surface::Attach(Buffer* buffer) {
195 TRACE_EVENT1("exo", "Surface::Attach", "buffer", 266 TRACE_EVENT1("exo", "Surface::Attach", "buffer",
196 buffer ? buffer->GetSize().ToString() : "null"); 267 buffer ? buffer->GetSize().ToString() : "null");
197 268
198 has_pending_contents_ = true; 269 has_pending_contents_ = true;
199 pending_buffer_.Reset(buffer ? buffer->AsWeakPtr() : base::WeakPtr<Buffer>()); 270 pending_buffer_.Reset(buffer ? buffer->AsWeakPtr() : base::WeakPtr<Buffer>());
200 } 271 }
201 272
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 has_pending_contents_ = false; 469 has_pending_contents_ = false;
399 470
400 current_buffer_ = std::move(pending_buffer_); 471 current_buffer_ = std::move(pending_buffer_);
401 472
402 UpdateResource(true); 473 UpdateResource(true);
403 } 474 }
404 475
405 cc::LocalFrameId old_local_frame_id = local_frame_id_; 476 cc::LocalFrameId old_local_frame_id = local_frame_id_;
406 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) { 477 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) {
407 needs_commit_to_new_surface_ = false; 478 needs_commit_to_new_surface_ = false;
408 local_frame_id_ = id_allocator_.GenerateId(); 479 local_frame_id_ = factory_owner_->id_allocator_->GenerateId();
409 } 480 }
410 481
411 UpdateSurface(true); 482 UpdateSurface(true);
412 483
413 if (old_local_frame_id != local_frame_id_) { 484 if (old_local_frame_id != local_frame_id_) {
414 float contents_surface_to_layer_scale = 1.0; 485 float contents_surface_to_layer_scale = 1.0;
415 // The bounds must be updated before switching to the new surface, because 486 // The bounds must be updated before switching to the new surface, because
416 // the layer may be mirrored, in which case a surface change causes the 487 // the layer may be mirrored, in which case a surface change causes the
417 // mirror layer to update its surface using the latest bounds. 488 // mirror layer to update its surface using the latest bounds.
418 window_->layer()->SetBounds( 489 window_->layer()->SetBounds(
419 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); 490 gfx::Rect(window_->layer()->bounds().origin(), content_size_));
420 window_->layer()->SetShowSurface( 491 window_->layer()->SetShowSurface(
421 cc::SurfaceId(frame_sink_id_, local_frame_id_), 492 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_),
422 base::Bind(&CompositorFrameSinkHolder::Satisfy, 493 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)),
423 compositor_frame_sink_holder_), 494 base::Bind(&RequireCallback, base::Unretained(surface_manager_)),
424 base::Bind(&CompositorFrameSinkHolder::Require,
425 compositor_frame_sink_holder_),
426 content_size_, contents_surface_to_layer_scale, content_size_); 495 content_size_, contents_surface_to_layer_scale, content_size_);
427 window_->layer()->SetFillsBoundsOpaquely( 496 window_->layer()->SetFillsBoundsOpaquely(
428 state_.blend_mode == SkBlendMode::kSrc || 497 state_.blend_mode == SkBlendMode::kSrc ||
429 state_.opaque_region.contains( 498 state_.opaque_region.contains(
430 gfx::RectToSkIRect(gfx::Rect(content_size_)))); 499 gfx::RectToSkIRect(gfx::Rect(content_size_))));
431 } 500 }
432 501
433 // Reset damage. 502 // Reset damage.
434 pending_damage_.setEmpty(); 503 pending_damage_.setEmpty();
435 504
436 DCHECK(!current_resource_.id || 505 DCHECK(!current_resource_.id ||
437 compositor_frame_sink_holder_->HasReleaseCallbackForResource( 506 factory_owner_->release_callbacks_.count(current_resource_.id));
438 current_resource_.id));
439 507
440 // Move pending frame callbacks to the end of frame_callbacks_. 508 // Move pending frame callbacks to the end of frame_callbacks_.
441 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); 509 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_);
442 510
443 // Synchronize window hierarchy. This will position and update the stacking 511 // Synchronize window hierarchy. This will position and update the stacking
444 // order of all sub-surfaces after committing all pending state of sub-surface 512 // order of all sub-surfaces after committing all pending state of sub-surface
445 // descendants. 513 // descendants.
446 aura::Window* stacking_target = nullptr; 514 aura::Window* stacking_target = nullptr;
447 for (auto& sub_surface_entry : pending_sub_surfaces_) { 515 for (auto& sub_surface_entry : pending_sub_surfaces_) {
448 Surface* sub_surface = sub_surface_entry.first; 516 Surface* sub_surface = sub_surface_entry.first;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 601 }
534 602
535 std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const { 603 std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const {
536 std::unique_ptr<base::trace_event::TracedValue> value( 604 std::unique_ptr<base::trace_event::TracedValue> value(
537 new base::trace_event::TracedValue()); 605 new base::trace_event::TracedValue());
538 value->SetString("name", window_->layer()->name()); 606 value->SetString("name", window_->layer()->name());
539 return value; 607 return value;
540 } 608 }
541 609
542 void Surface::WillDraw() { 610 void Surface::WillDraw() {
543 compositor_frame_sink_holder_->ActivateFrameCallbacks(&frame_callbacks_); 611 active_frame_callbacks_.splice(active_frame_callbacks_.end(),
612 frame_callbacks_);
613 UpdateNeedsBeginFrame();
614 }
615
616 void Surface::SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) {
617 if (begin_frame_source_ && needs_begin_frame_) {
618 begin_frame_source_->RemoveObserver(this);
619 needs_begin_frame_ = false;
620 }
621 begin_frame_source_ = begin_frame_source;
622 UpdateNeedsBeginFrame();
544 } 623 }
545 624
546 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { 625 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() {
547 if (HasLayerHierarchyChanged()) 626 if (HasLayerHierarchyChanged())
548 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); 627 SetSurfaceHierarchyNeedsCommitToNewSurfaces();
549 } 628 }
550 629
551 void Surface::OnLostResources() { 630 void Surface::OnLostResources() {
552 if (!local_frame_id_.is_valid()) 631 if (!local_frame_id_.is_valid())
553 return; 632 return;
554 633
555 UpdateResource(false); 634 UpdateResource(false);
556 UpdateSurface(false); 635 UpdateSurface(false);
557 } 636 }
558 637
559 void Surface::OnWindowAddedToRootWindow(aura::Window* window) { 638 void Surface::OnWindowAddedToRootWindow(aura::Window* window) {
560 window->layer()->GetCompositor()->AddFrameSink(frame_sink_id_); 639 window->layer()->GetCompositor()->AddFrameSink(
640 factory_owner_->frame_sink_id_);
561 } 641 }
562 642
563 void Surface::OnWindowRemovingFromRootWindow(aura::Window* window, 643 void Surface::OnWindowRemovingFromRootWindow(aura::Window* window,
564 aura::Window* new_root) { 644 aura::Window* new_root) {
565 window->layer()->GetCompositor()->RemoveFrameSink(frame_sink_id_); 645 window->layer()->GetCompositor()->RemoveFrameSink(
646 factory_owner_->frame_sink_id_);
647 }
648
649 void Surface::OnBeginFrame(const cc::BeginFrameArgs& args) {
650 while (!active_frame_callbacks_.empty()) {
651 active_frame_callbacks_.front().Run(args.frame_time);
652 active_frame_callbacks_.pop_front();
653 }
654 last_begin_frame_args_ = args;
655 }
656
657 const cc::BeginFrameArgs& Surface::LastUsedBeginFrameArgs() const {
658 return last_begin_frame_args_;
566 } 659 }
567 660
568 Surface::State::State() : input_region(SkIRect::MakeLargest()) {} 661 Surface::State::State() : input_region(SkIRect::MakeLargest()) {}
569 662
570 Surface::State::~State() = default; 663 Surface::State::~State() = default;
571 664
572 bool Surface::State::operator==(const State& other) { 665 bool Surface::State::operator==(const State& other) {
573 return (other.crop == crop && alpha == other.alpha && 666 return (other.crop == crop && alpha == other.alpha &&
574 other.blend_mode == blend_mode && other.viewport == viewport && 667 other.blend_mode == blend_mode && other.viewport == viewport &&
575 other.opaque_region == opaque_region && 668 other.opaque_region == opaque_region &&
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 resource.id = next_resource_id_++; 736 resource.id = next_resource_id_++;
644 resource.format = cc::RGBA_8888; 737 resource.format = cc::RGBA_8888;
645 resource.filter = 738 resource.filter =
646 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; 739 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR;
647 resource.size = texture_mailbox.size_in_pixels(); 740 resource.size = texture_mailbox.size_in_pixels();
648 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), 741 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(),
649 texture_mailbox.sync_token(), 742 texture_mailbox.sync_token(),
650 texture_mailbox.target()); 743 texture_mailbox.target());
651 resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate(); 744 resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate();
652 745
653 compositor_frame_sink_holder_->AddResourceReleaseCallback( 746 factory_owner_->release_callbacks_[resource.id] = std::make_pair(
654 resource.id, std::move(texture_mailbox_release_callback)); 747 factory_owner_, std::move(texture_mailbox_release_callback));
655 current_resource_ = resource; 748 current_resource_ = resource;
656 } else { 749 } else {
657 current_resource_.id = 0; 750 current_resource_.id = 0;
658 current_resource_.size = gfx::Size(); 751 current_resource_.size = gfx::Size();
659 } 752 }
660 } 753 }
661 754
662 void Surface::UpdateSurface(bool full_damage) { 755 void Surface::UpdateSurface(bool full_damage) {
663 gfx::Size buffer_size = current_resource_.size; 756 gfx::Size buffer_size = current_resource_.size;
664 gfx::SizeF scaled_buffer_size( 757 gfx::SizeF scaled_buffer_size(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 texture_quad->set_resource_size_in_pixels(current_resource_.size); 827 texture_quad->set_resource_size_in_pixels(current_resource_.size);
735 frame.resource_list.push_back(current_resource_); 828 frame.resource_list.push_back(current_resource_);
736 } 829 }
737 } else { 830 } else {
738 cc::SolidColorDrawQuad* solid_quad = 831 cc::SolidColorDrawQuad* solid_quad =
739 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); 832 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
740 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); 833 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false);
741 } 834 }
742 835
743 frame.render_pass_list.push_back(std::move(render_pass)); 836 frame.render_pass_list.push_back(std::move(render_pass));
744 compositor_frame_sink_holder_->GetCompositorFrameSink() 837
745 ->SubmitCompositorFrame(local_frame_id_, std::move(frame)); 838 factory_owner_->surface_factory_->SubmitCompositorFrame(
839 local_frame_id_, std::move(frame), cc::SurfaceFactory::DrawCallback());
840 }
841
842 void Surface::UpdateNeedsBeginFrame() {
843 if (!begin_frame_source_)
844 return;
845
846 bool needs_begin_frame = !active_frame_callbacks_.empty();
847 if (needs_begin_frame == needs_begin_frame_)
848 return;
849
850 needs_begin_frame_ = needs_begin_frame;
851 if (needs_begin_frame)
852 begin_frame_source_->AddObserver(this);
853 else
854 begin_frame_source_->RemoveObserver(this);
746 } 855 }
747 856
748 int64_t Surface::SetPropertyInternal(const void* key, 857 int64_t Surface::SetPropertyInternal(const void* key,
749 const char* name, 858 const char* name,
750 PropertyDeallocator deallocator, 859 PropertyDeallocator deallocator,
751 int64_t value, 860 int64_t value,
752 int64_t default_value) { 861 int64_t default_value) {
753 int64_t old = GetPropertyInternal(key, default_value); 862 int64_t old = GetPropertyInternal(key, default_value);
754 if (value == default_value) { 863 if (value == default_value) {
755 prop_map_.erase(key); 864 prop_map_.erase(key);
756 } else { 865 } else {
757 Value prop_value; 866 Value prop_value;
758 prop_value.name = name; 867 prop_value.name = name;
759 prop_value.value = value; 868 prop_value.value = value;
760 prop_value.deallocator = deallocator; 869 prop_value.deallocator = deallocator;
761 prop_map_[key] = prop_value; 870 prop_map_[key] = prop_value;
762 } 871 }
763 return old; 872 return old;
764 } 873 }
765 874
766 int64_t Surface::GetPropertyInternal(const void* key, 875 int64_t Surface::GetPropertyInternal(const void* key,
767 int64_t default_value) const { 876 int64_t default_value) const {
768 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); 877 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
769 if (iter == prop_map_.end()) 878 if (iter == prop_map_.end())
770 return default_value; 879 return default_value;
771 return iter->second.value; 880 return iter->second.value;
772 } 881 }
773 882
774 } // namespace exo 883 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.h ('k') | components/exo/surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698