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/surface.h" | 20 #include "cc/surfaces/surface.h" |
21 #include "cc/surfaces/surface_factory.h" | |
22 #include "cc/surfaces/surface_id_allocator.h" | 21 #include "cc/surfaces/surface_id_allocator.h" |
23 #include "cc/surfaces/surface_manager.h" | |
24 #include "components/exo/buffer.h" | 22 #include "components/exo/buffer.h" |
25 #include "components/exo/surface_delegate.h" | 23 #include "components/exo/surface_delegate.h" |
26 #include "components/exo/surface_observer.h" | 24 #include "components/exo/surface_observer.h" |
27 #include "third_party/khronos/GLES2/gl2.h" | 25 #include "third_party/khronos/GLES2/gl2.h" |
28 #include "ui/aura/env.h" | 26 #include "ui/aura/env.h" |
29 #include "ui/aura/window_delegate.h" | 27 #include "ui/aura/window_delegate.h" |
30 #include "ui/aura/window_property.h" | 28 #include "ui/aura/window_property.h" |
31 #include "ui/aura/window_targeter.h" | 29 #include "ui/aura/window_targeter.h" |
32 #include "ui/base/cursor/cursor.h" | 30 #include "ui/base/cursor/cursor.h" |
33 #include "ui/base/hit_test.h" | 31 #include "ui/base/hit_test.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 if (window->parent()) | 132 if (window->parent()) |
135 aura::Window::ConvertPointToTarget(window->parent(), window, | 133 aura::Window::ConvertPointToTarget(window->parent(), window, |
136 &local_point); | 134 &local_point); |
137 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); | 135 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); |
138 } | 136 } |
139 | 137 |
140 private: | 138 private: |
141 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); | 139 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); |
142 }; | 140 }; |
143 | 141 |
144 void SatisfyCallback(cc::SurfaceManager* manager, | 142 void SatisfyCallback(base::WeakPtr<CompositorFrameSinkHolder> frame_sink_holder, |
reveman
2016/12/07 22:13:37
Can you add a Satisfy() function to the Compositor
Alex Z.
2016/12/09 16:16:27
Done.
| |
145 const cc::SurfaceSequence& sequence) { | 143 const cc::SurfaceSequence& sequence) { |
146 std::vector<uint32_t> sequences; | 144 if (frame_sink_holder) |
147 sequences.push_back(sequence.sequence); | 145 frame_sink_holder->GetCompositorFrameSink()->Satisfy(sequence); |
148 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); | |
149 } | 146 } |
150 | 147 |
151 void RequireCallback(cc::SurfaceManager* manager, | 148 void RequireCallback(base::WeakPtr<CompositorFrameSinkHolder> frame_sink_holder, |
reveman
2016/12/07 22:13:37
Same here. Can we add a Require function to Compos
Alex Z.
2016/12/09 16:16:27
Done.
| |
152 const cc::SurfaceId& id, | 149 const cc::SurfaceId& id, |
153 const cc::SurfaceSequence& sequence) { | 150 const cc::SurfaceSequence& sequence) { |
154 cc::Surface* surface = manager->GetSurfaceForId(id); | 151 if (frame_sink_holder) { |
155 if (!surface) { | 152 frame_sink_holder->GetCompositorFrameSink()->Require(id.local_frame_id(), |
156 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 153 sequence); |
157 return; | |
158 } | 154 } |
159 surface->AddDestructionDependency(sequence); | |
160 } | 155 } |
161 | 156 |
162 } // namespace | 157 } // namespace |
163 | 158 |
164 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
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 //////////////////////////////////////////////////////////////////////////////// | |
204 // Surface, public: | 160 // Surface, public: |
205 | 161 |
206 Surface::Surface() | 162 Surface::Surface() |
207 : window_(new aura::Window(new CustomWindowDelegate(this))), | 163 : window_(new aura::Window(new CustomWindowDelegate(this))), |
208 surface_manager_( | 164 frame_sink_id_( |
209 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()), | 165 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId()) { |
210 factory_owner_(new SurfaceFactoryOwner) { | 166 cc::mojom::MojoCompositorFrameSinkClientPtr frame_sink_holder_ptr; |
167 cc::mojom::MojoCompositorFrameSinkPtr frame_sink_ptr; | |
168 cc::mojom::MojoCompositorFrameSinkClientRequest frame_sink_client_request = | |
169 mojo::GetProxy(&frame_sink_holder_ptr); | |
170 CompositorFrameSink::Create( | |
171 frame_sink_id_, | |
172 aura::Env::GetInstance()->context_factory()->GetSurfaceManager(), | |
173 std::move(frame_sink_holder_ptr), mojo::GetProxy(&frame_sink_ptr)); | |
174 compositor_frame_sink_holder_ = new CompositorFrameSinkHolder( | |
175 std::move(frame_sink_ptr), this, std::move(frame_sink_client_request)); | |
211 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 176 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
212 window_->SetName("ExoSurface"); | 177 window_->SetName("ExoSurface"); |
213 window_->SetProperty(kSurfaceKey, this); | 178 window_->SetProperty(kSurfaceKey, this); |
214 window_->Init(ui::LAYER_SOLID_COLOR); | 179 window_->Init(ui::LAYER_SOLID_COLOR); |
215 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); | 180 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); |
216 window_->set_owned_by_parent(false); | 181 window_->set_owned_by_parent(false); |
217 window_->AddObserver(this); | 182 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())); | |
227 aura::Env::GetInstance()->context_factory()->AddObserver(this); | 183 aura::Env::GetInstance()->context_factory()->AddObserver(this); |
228 } | 184 } |
229 | 185 |
230 Surface::~Surface() { | 186 Surface::~Surface() { |
231 aura::Env::GetInstance()->context_factory()->RemoveObserver(this); | 187 aura::Env::GetInstance()->context_factory()->RemoveObserver(this); |
232 for (SurfaceObserver& observer : observers_) | 188 for (SurfaceObserver& observer : observers_) |
233 observer.OnSurfaceDestroying(this); | 189 observer.OnSurfaceDestroying(this); |
234 | 190 |
235 window_->RemoveObserver(this); | 191 window_->RemoveObserver(this); |
236 window_->layer()->SetShowSolidColorContent(); | 192 window_->layer()->SetShowSolidColorContent(); |
237 | 193 |
238 factory_owner_->surface_ = nullptr; | 194 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); |
195 compositor_frame_sink_holder_->ActivateFrameCallbacks(&frame_callbacks_); | |
196 compositor_frame_sink_holder_->CancelFrameCallbacks(); | |
239 | 197 |
240 // Call pending frame callbacks with a null frame time to indicate that they | 198 compositor_frame_sink_holder_->GetCompositorFrameSink()->EvictFrame(); |
241 // have been cancelled. | |
242 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); | |
243 active_frame_callbacks_.splice(active_frame_callbacks_.end(), | |
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); | |
249 | |
250 factory_owner_->surface_factory_->EvictSurface(); | |
251 | |
252 surface_manager_->UnregisterSurfaceFactoryClient( | |
253 factory_owner_->frame_sink_id_); | |
254 } | 199 } |
255 | 200 |
256 // static | 201 // static |
257 Surface* Surface::AsSurface(const aura::Window* window) { | 202 Surface* Surface::AsSurface(const aura::Window* window) { |
258 return window->GetProperty(kSurfaceKey); | 203 return window->GetProperty(kSurfaceKey); |
259 } | 204 } |
260 | 205 |
261 cc::SurfaceId Surface::GetSurfaceId() const { | 206 cc::SurfaceId Surface::GetSurfaceId() const { |
262 return cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_); | 207 return cc::SurfaceId(frame_sink_id_, local_frame_id_); |
263 } | 208 } |
264 | 209 |
265 void Surface::Attach(Buffer* buffer) { | 210 void Surface::Attach(Buffer* buffer) { |
266 TRACE_EVENT1("exo", "Surface::Attach", "buffer", | 211 TRACE_EVENT1("exo", "Surface::Attach", "buffer", |
267 buffer ? buffer->GetSize().ToString() : "null"); | 212 buffer ? buffer->GetSize().ToString() : "null"); |
268 | 213 |
269 has_pending_contents_ = true; | 214 has_pending_contents_ = true; |
270 pending_buffer_.Reset(buffer ? buffer->AsWeakPtr() : base::WeakPtr<Buffer>()); | 215 pending_buffer_.Reset(buffer ? buffer->AsWeakPtr() : base::WeakPtr<Buffer>()); |
271 } | 216 } |
272 | 217 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 has_pending_contents_ = false; | 414 has_pending_contents_ = false; |
470 | 415 |
471 current_buffer_ = std::move(pending_buffer_); | 416 current_buffer_ = std::move(pending_buffer_); |
472 | 417 |
473 UpdateResource(true); | 418 UpdateResource(true); |
474 } | 419 } |
475 | 420 |
476 cc::LocalFrameId old_local_frame_id = local_frame_id_; | 421 cc::LocalFrameId old_local_frame_id = local_frame_id_; |
477 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) { | 422 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) { |
478 needs_commit_to_new_surface_ = false; | 423 needs_commit_to_new_surface_ = false; |
479 local_frame_id_ = factory_owner_->id_allocator_->GenerateId(); | 424 local_frame_id_ = id_allocator_.GenerateId(); |
480 } | 425 } |
481 | 426 |
482 UpdateSurface(true); | 427 UpdateSurface(true); |
483 | 428 |
484 if (old_local_frame_id != local_frame_id_) { | 429 if (old_local_frame_id != local_frame_id_) { |
485 float contents_surface_to_layer_scale = 1.0; | 430 float contents_surface_to_layer_scale = 1.0; |
486 // The bounds must be updated before switching to the new surface, because | 431 // 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 | 432 // the layer may be mirrored, in which case a surface change causes the |
488 // mirror layer to update its surface using the latest bounds. | 433 // mirror layer to update its surface using the latest bounds. |
489 window_->layer()->SetBounds( | 434 window_->layer()->SetBounds( |
490 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); | 435 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); |
491 window_->layer()->SetShowSurface( | 436 window_->layer()->SetShowSurface( |
492 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), | 437 cc::SurfaceId(frame_sink_id_, local_frame_id_), |
493 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), | 438 base::Bind(&SatisfyCallback, |
494 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), | 439 compositor_frame_sink_holder_->GetWeakPtr()), |
440 base::Bind(&RequireCallback, | |
441 compositor_frame_sink_holder_->GetWeakPtr()), | |
495 content_size_, contents_surface_to_layer_scale, content_size_); | 442 content_size_, contents_surface_to_layer_scale, content_size_); |
496 window_->layer()->SetFillsBoundsOpaquely( | 443 window_->layer()->SetFillsBoundsOpaquely( |
497 state_.blend_mode == SkBlendMode::kSrc || | 444 state_.blend_mode == SkBlendMode::kSrc || |
498 state_.opaque_region.contains( | 445 state_.opaque_region.contains( |
499 gfx::RectToSkIRect(gfx::Rect(content_size_)))); | 446 gfx::RectToSkIRect(gfx::Rect(content_size_)))); |
500 } | 447 } |
501 | 448 |
502 // Reset damage. | 449 // Reset damage. |
503 pending_damage_.setEmpty(); | 450 pending_damage_.setEmpty(); |
504 | 451 |
505 DCHECK(!current_resource_.id || | 452 DCHECK(!current_resource_.id || |
506 factory_owner_->release_callbacks_.count(current_resource_.id)); | 453 compositor_frame_sink_holder_->HasReleaseCallbacksForResource( |
454 current_resource_.id)); | |
507 | 455 |
508 // Move pending frame callbacks to the end of frame_callbacks_. | 456 // Move pending frame callbacks to the end of frame_callbacks_. |
509 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); | 457 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); |
510 | 458 |
511 // Synchronize window hierarchy. This will position and update the stacking | 459 // Synchronize window hierarchy. This will position and update the stacking |
512 // order of all sub-surfaces after committing all pending state of sub-surface | 460 // order of all sub-surfaces after committing all pending state of sub-surface |
513 // descendants. | 461 // descendants. |
514 aura::Window* stacking_target = nullptr; | 462 aura::Window* stacking_target = nullptr; |
515 for (auto& sub_surface_entry : pending_sub_surfaces_) { | 463 for (auto& sub_surface_entry : pending_sub_surfaces_) { |
516 Surface* sub_surface = sub_surface_entry.first; | 464 Surface* sub_surface = sub_surface_entry.first; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 } | 549 } |
602 | 550 |
603 std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const { | 551 std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const { |
604 std::unique_ptr<base::trace_event::TracedValue> value( | 552 std::unique_ptr<base::trace_event::TracedValue> value( |
605 new base::trace_event::TracedValue()); | 553 new base::trace_event::TracedValue()); |
606 value->SetString("name", window_->layer()->name()); | 554 value->SetString("name", window_->layer()->name()); |
607 return value; | 555 return value; |
608 } | 556 } |
609 | 557 |
610 void Surface::WillDraw() { | 558 void Surface::WillDraw() { |
611 active_frame_callbacks_.splice(active_frame_callbacks_.end(), | 559 compositor_frame_sink_holder_->ActivateFrameCallbacks(&frame_callbacks_); |
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(); | |
623 } | 560 } |
624 | 561 |
625 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { | 562 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { |
626 if (HasLayerHierarchyChanged()) | 563 if (HasLayerHierarchyChanged()) |
627 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); | 564 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); |
628 } | 565 } |
629 | 566 |
630 void Surface::OnLostResources() { | 567 void Surface::OnLostResources() { |
631 if (!local_frame_id_.is_valid()) | 568 if (!local_frame_id_.is_valid()) |
632 return; | 569 return; |
633 | 570 |
634 UpdateResource(false); | 571 UpdateResource(false); |
635 UpdateSurface(false); | 572 UpdateSurface(false); |
636 } | 573 } |
637 | 574 |
638 void Surface::OnWindowAddedToRootWindow(aura::Window* window) { | 575 void Surface::OnWindowAddedToRootWindow(aura::Window* window) { |
639 window->layer()->GetCompositor()->AddFrameSink( | 576 window->layer()->GetCompositor()->AddFrameSink(frame_sink_id_); |
640 factory_owner_->frame_sink_id_); | |
641 } | 577 } |
642 | 578 |
643 void Surface::OnWindowRemovingFromRootWindow(aura::Window* window, | 579 void Surface::OnWindowRemovingFromRootWindow(aura::Window* window, |
644 aura::Window* new_root) { | 580 aura::Window* new_root) { |
645 window->layer()->GetCompositor()->RemoveFrameSink( | 581 window->layer()->GetCompositor()->RemoveFrameSink(frame_sink_id_); |
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_; | |
659 } | 582 } |
660 | 583 |
661 Surface::State::State() : input_region(SkIRect::MakeLargest()) {} | 584 Surface::State::State() : input_region(SkIRect::MakeLargest()) {} |
662 | 585 |
663 Surface::State::~State() = default; | 586 Surface::State::~State() = default; |
664 | 587 |
665 bool Surface::State::operator==(const State& other) { | 588 bool Surface::State::operator==(const State& other) { |
666 return (other.crop == crop && alpha == other.alpha && | 589 return (other.crop == crop && alpha == other.alpha && |
667 other.blend_mode == blend_mode && other.viewport == viewport && | 590 other.blend_mode == blend_mode && other.viewport == viewport && |
668 other.opaque_region == opaque_region && | 591 other.opaque_region == opaque_region && |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 resource.id = next_resource_id_++; | 659 resource.id = next_resource_id_++; |
737 resource.format = cc::RGBA_8888; | 660 resource.format = cc::RGBA_8888; |
738 resource.filter = | 661 resource.filter = |
739 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; | 662 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; |
740 resource.size = texture_mailbox.size_in_pixels(); | 663 resource.size = texture_mailbox.size_in_pixels(); |
741 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), | 664 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), |
742 texture_mailbox.sync_token(), | 665 texture_mailbox.sync_token(), |
743 texture_mailbox.target()); | 666 texture_mailbox.target()); |
744 resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate(); | 667 resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate(); |
745 | 668 |
746 factory_owner_->release_callbacks_[resource.id] = std::make_pair( | 669 compositor_frame_sink_holder_->AddResourceReleaseCallback( |
747 factory_owner_, std::move(texture_mailbox_release_callback)); | 670 resource.id, std::move(texture_mailbox_release_callback)); |
748 current_resource_ = resource; | 671 current_resource_ = resource; |
749 } else { | 672 } else { |
750 current_resource_.id = 0; | 673 current_resource_.id = 0; |
751 current_resource_.size = gfx::Size(); | 674 current_resource_.size = gfx::Size(); |
752 } | 675 } |
753 } | 676 } |
754 | 677 |
755 void Surface::UpdateSurface(bool full_damage) { | 678 void Surface::UpdateSurface(bool full_damage) { |
756 gfx::Size buffer_size = current_resource_.size; | 679 gfx::Size buffer_size = current_resource_.size; |
757 gfx::SizeF scaled_buffer_size( | 680 gfx::SizeF scaled_buffer_size( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 texture_quad->set_resource_size_in_pixels(current_resource_.size); | 750 texture_quad->set_resource_size_in_pixels(current_resource_.size); |
828 frame.resource_list.push_back(current_resource_); | 751 frame.resource_list.push_back(current_resource_); |
829 } | 752 } |
830 } else { | 753 } else { |
831 cc::SolidColorDrawQuad* solid_quad = | 754 cc::SolidColorDrawQuad* solid_quad = |
832 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 755 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
833 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 756 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); |
834 } | 757 } |
835 | 758 |
836 frame.render_pass_list.push_back(std::move(render_pass)); | 759 frame.render_pass_list.push_back(std::move(render_pass)); |
837 | 760 compositor_frame_sink_holder_->GetCompositorFrameSink() |
838 factory_owner_->surface_factory_->SubmitCompositorFrame( | 761 ->SubmitCompositorFrame(local_frame_id_, std::move(frame)); |
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); | |
855 } | 762 } |
856 | 763 |
857 int64_t Surface::SetPropertyInternal(const void* key, | 764 int64_t Surface::SetPropertyInternal(const void* key, |
858 const char* name, | 765 const char* name, |
859 PropertyDeallocator deallocator, | 766 PropertyDeallocator deallocator, |
860 int64_t value, | 767 int64_t value, |
861 int64_t default_value) { | 768 int64_t default_value) { |
862 int64_t old = GetPropertyInternal(key, default_value); | 769 int64_t old = GetPropertyInternal(key, default_value); |
863 if (value == default_value) { | 770 if (value == default_value) { |
864 prop_map_.erase(key); | 771 prop_map_.erase(key); |
865 } else { | 772 } else { |
866 Value prop_value; | 773 Value prop_value; |
867 prop_value.name = name; | 774 prop_value.name = name; |
868 prop_value.value = value; | 775 prop_value.value = value; |
869 prop_value.deallocator = deallocator; | 776 prop_value.deallocator = deallocator; |
870 prop_map_[key] = prop_value; | 777 prop_map_[key] = prop_value; |
871 } | 778 } |
872 return old; | 779 return old; |
873 } | 780 } |
874 | 781 |
875 int64_t Surface::GetPropertyInternal(const void* key, | 782 int64_t Surface::GetPropertyInternal(const void* key, |
876 int64_t default_value) const { | 783 int64_t default_value) const { |
877 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 784 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
878 if (iter == prop_map_.end()) | 785 if (iter == prop_map_.end()) |
879 return default_value; | 786 return default_value; |
880 return iter->second.value; | 787 return iter->second.value; |
881 } | 788 } |
882 | 789 |
883 } // namespace exo | 790 } // namespace exo |
OLD | NEW |