OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/surfaces/display.h" | 5 #include "cc/surfaces/display.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { | 61 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { |
62 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); | 62 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); |
63 if (surface) | 63 if (surface) |
64 surface->RunDrawCallbacks(); | 64 surface->RunDrawCallbacks(); |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void Display::Initialize(DisplayClient* client, | 69 void Display::Initialize(DisplayClient* client, |
70 SurfaceManager* surface_manager, | 70 SurfaceManager* surface_manager, |
71 uint32_t compositor_surface_namespace) { | 71 const FrameSinkId& frame_sink_id) { |
72 DCHECK(client); | 72 DCHECK(client); |
73 DCHECK(surface_manager); | 73 DCHECK(surface_manager); |
74 client_ = client; | 74 client_ = client; |
75 surface_manager_ = surface_manager; | 75 surface_manager_ = surface_manager; |
76 compositor_surface_namespace_ = compositor_surface_namespace; | 76 frame_sink_id_ = frame_sink_id; |
77 | 77 |
78 surface_manager_->AddObserver(this); | 78 surface_manager_->AddObserver(this); |
79 | 79 |
80 // This must be done in Initialize() so that the caller can delay this until | 80 // This must be done in Initialize() so that the caller can delay this until |
81 // they are ready to receive a BeginFrameSource. | 81 // they are ready to receive a BeginFrameSource. |
82 if (begin_frame_source_) { | 82 if (begin_frame_source_) { |
83 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(), | 83 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(), |
84 compositor_surface_namespace_); | 84 frame_sink_id_); |
85 } | 85 } |
86 | 86 |
87 bool ok = output_surface_->BindToClient(this); | 87 bool ok = output_surface_->BindToClient(this); |
88 // The context given to the Display's OutputSurface should already be | 88 // The context given to the Display's OutputSurface should already be |
89 // initialized, so Bind can not fail. | 89 // initialized, so Bind can not fail. |
90 DCHECK(ok); | 90 DCHECK(ok); |
91 InitializeRenderer(); | 91 InitializeRenderer(); |
92 } | 92 } |
93 | 93 |
94 void Display::SetSurfaceId(const SurfaceId& id, float device_scale_factor) { | 94 void Display::SetSurfaceId(const SurfaceId& id, float device_scale_factor) { |
95 DCHECK_EQ(id.client_id(), compositor_surface_namespace_); | 95 DCHECK(id.frame_sink_id() == frame_sink_id_); |
96 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) | 96 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) |
97 return; | 97 return; |
98 | 98 |
99 TRACE_EVENT0("cc", "Display::SetSurfaceId"); | 99 TRACE_EVENT0("cc", "Display::SetSurfaceId"); |
100 current_surface_id_ = id; | 100 current_surface_id_ = id; |
101 device_scale_factor_ = device_scale_factor; | 101 device_scale_factor_ = device_scale_factor; |
102 | 102 |
103 UpdateRootSurfaceResourcesLocked(); | 103 UpdateRootSurfaceResourcesLocked(); |
104 if (scheduler_) | 104 if (scheduler_) |
105 scheduler_->SetNewRootSurface(id); | 105 scheduler_->SetNewRootSurface(id); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 const SurfaceId& Display::CurrentSurfaceId() { | 429 const SurfaceId& Display::CurrentSurfaceId() { |
430 return current_surface_id_; | 430 return current_surface_id_; |
431 } | 431 } |
432 | 432 |
433 void Display::ForceImmediateDrawAndSwapIfPossible() { | 433 void Display::ForceImmediateDrawAndSwapIfPossible() { |
434 if (scheduler_) | 434 if (scheduler_) |
435 scheduler_->ForceImmediateSwapIfPossible(); | 435 scheduler_->ForceImmediateSwapIfPossible(); |
436 } | 436 } |
437 | 437 |
438 } // namespace cc | 438 } // namespace cc |
OLD | NEW |