Chromium Code Reviews| 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) { |
|
Fady Samuel
2017/02/02 16:34:29
drop the braces { and }.
| |
| 109 if (current_surface_id_.local_surface_id() == id && | |
| 110 device_scale_factor_ == device_scale_factor) { | |
| 111 return; | 109 return; |
| 112 } | 110 } |
| 113 | 111 |
| 114 TRACE_EVENT0("cc", "Display::SetSurfaceId"); | 112 TRACE_EVENT0("cc", "Display::SetSurfaceId"); |
| 115 current_surface_id_ = SurfaceId(frame_sink_id_, id); | 113 current_surface_id_ = SurfaceId(frame_sink_id_, id); |
| 116 device_scale_factor_ = device_scale_factor; | |
| 117 | 114 |
| 118 UpdateRootSurfaceResourcesLocked(); | 115 UpdateRootSurfaceResourcesLocked(); |
| 119 if (scheduler_) | 116 if (scheduler_) |
| 120 scheduler_->SetNewRootSurface(current_surface_id_); | 117 scheduler_->SetNewRootSurface(current_surface_id_); |
| 121 } | 118 } |
| 122 | 119 |
| 120 void Display::SetDeviceScaleFactor(float device_scale_factor) { | |
| 121 if (device_scale_factor_ == device_scale_factor) { | |
| 122 return; | |
| 123 } | |
| 124 | |
| 125 TRACE_EVENT0("cc", "Display::SetDeviceScaleFactor"); | |
| 126 device_scale_factor_ = device_scale_factor; | |
|
Fady Samuel
2017/02/02 16:34:29
We might want to mark SurfaceDamaged here.
k.devara
2017/02/03 11:35:37
I was thinking device_scale_factor may not trigger
| |
| 127 } | |
| 128 | |
| 123 void Display::SetVisible(bool visible) { | 129 void Display::SetVisible(bool visible) { |
| 124 TRACE_EVENT1("cc", "Display::SetVisible", "visible", visible); | 130 TRACE_EVENT1("cc", "Display::SetVisible", "visible", visible); |
| 125 if (renderer_) | 131 if (renderer_) |
| 126 renderer_->SetVisible(visible); | 132 renderer_->SetVisible(visible); |
| 127 if (scheduler_) | 133 if (scheduler_) |
| 128 scheduler_->SetVisible(visible); | 134 scheduler_->SetVisible(visible); |
| 129 visible_ = visible; | 135 visible_ = visible; |
| 130 | 136 |
| 131 if (!visible) { | 137 if (!visible) { |
| 132 // Damage tracker needs a full reset as renderer resources are dropped when | 138 // Damage tracker needs a full reset as renderer resources are dropped when |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 const SurfaceId& Display::CurrentSurfaceId() { | 403 const SurfaceId& Display::CurrentSurfaceId() { |
| 398 return current_surface_id_; | 404 return current_surface_id_; |
| 399 } | 405 } |
| 400 | 406 |
| 401 void Display::ForceImmediateDrawAndSwapIfPossible() { | 407 void Display::ForceImmediateDrawAndSwapIfPossible() { |
| 402 if (scheduler_) | 408 if (scheduler_) |
| 403 scheduler_->ForceImmediateSwapIfPossible(); | 409 scheduler_->ForceImmediateSwapIfPossible(); |
| 404 } | 410 } |
| 405 | 411 |
| 406 } // namespace cc | 412 } // namespace cc |
| OLD | NEW |