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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // on the same callstack as the ContextProvider being created/initialized | 97 // on the same callstack as the ContextProvider being created/initialized |
98 // or else it could miss a callback before setting this. | 98 // or else it could miss a callback before setting this. |
99 context->SetLostContextCallback(base::Bind( | 99 context->SetLostContextCallback(base::Bind( |
100 &Display::DidLoseContextProvider, | 100 &Display::DidLoseContextProvider, |
101 // Unretained is safe since the callback is unset in this class' | 101 // Unretained is safe since the callback is unset in this class' |
102 // destructor and is never posted. | 102 // destructor and is never posted. |
103 base::Unretained(this))); | 103 base::Unretained(this))); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 void Display::SetLocalSurfaceId(const LocalSurfaceId& id, | 107 void Display::SetLocalSurfaceId(const LocalSurfaceId& id) { |
108 float device_scale_factor) { | 108 if (current_surface_id_.local_surface_id() == id) |
109 if (current_surface_id_.local_surface_id() == id && | |
110 device_scale_factor_ == device_scale_factor) { | |
111 return; | 109 return; |
112 } | |
113 | 110 |
114 TRACE_EVENT0("cc", "Display::SetSurfaceId"); | 111 TRACE_EVENT0("cc", "Display::SetSurfaceId"); |
115 current_surface_id_ = SurfaceId(frame_sink_id_, id); | 112 current_surface_id_ = SurfaceId(frame_sink_id_, id); |
116 device_scale_factor_ = device_scale_factor; | |
117 | 113 |
118 UpdateRootSurfaceResourcesLocked(); | 114 UpdateRootSurfaceResourcesLocked(); |
119 if (scheduler_) | 115 if (scheduler_) |
120 scheduler_->SetNewRootSurface(current_surface_id_); | 116 scheduler_->SetNewRootSurface(current_surface_id_); |
121 } | 117 } |
122 | 118 |
| 119 void Display::SetDeviceScaleFactor(float device_scale_factor) { |
| 120 if (device_scale_factor_ == device_scale_factor) |
| 121 return; |
| 122 |
| 123 TRACE_EVENT0("cc", "Display::SetDeviceScaleFactor"); |
| 124 device_scale_factor_ = device_scale_factor; |
| 125 } |
| 126 |
123 void Display::SetVisible(bool visible) { | 127 void Display::SetVisible(bool visible) { |
124 TRACE_EVENT1("cc", "Display::SetVisible", "visible", visible); | 128 TRACE_EVENT1("cc", "Display::SetVisible", "visible", visible); |
125 if (renderer_) | 129 if (renderer_) |
126 renderer_->SetVisible(visible); | 130 renderer_->SetVisible(visible); |
127 if (scheduler_) | 131 if (scheduler_) |
128 scheduler_->SetVisible(visible); | 132 scheduler_->SetVisible(visible); |
129 visible_ = visible; | 133 visible_ = visible; |
130 | 134 |
131 if (!visible) { | 135 if (!visible) { |
132 // Damage tracker needs a full reset as renderer resources are dropped when | 136 // Damage tracker needs a full reset as renderer resources are dropped when |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 const SurfaceId& Display::CurrentSurfaceId() { | 404 const SurfaceId& Display::CurrentSurfaceId() { |
401 return current_surface_id_; | 405 return current_surface_id_; |
402 } | 406 } |
403 | 407 |
404 void Display::ForceImmediateDrawAndSwapIfPossible() { | 408 void Display::ForceImmediateDrawAndSwapIfPossible() { |
405 if (scheduler_) | 409 if (scheduler_) |
406 scheduler_->ForceImmediateSwapIfPossible(); | 410 scheduler_->ForceImmediateSwapIfPossible(); |
407 } | 411 } |
408 | 412 |
409 } // namespace cc | 413 } // namespace cc |
OLD | NEW |