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/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(), | 85 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(), |
86 compositor_surface_namespace_); | 86 compositor_surface_namespace_); |
87 } | 87 } |
88 | 88 |
89 bool ok = output_surface_->BindToClient(this); | 89 bool ok = output_surface_->BindToClient(this); |
90 // The context given to the Display's OutputSurface should already be | 90 // The context given to the Display's OutputSurface should already be |
91 // initialized, so Bind can not fail. | 91 // initialized, so Bind can not fail. |
92 DCHECK(ok); | 92 DCHECK(ok); |
93 } | 93 } |
94 | 94 |
95 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) { | 95 void Display::SetSurfaceId(const SurfaceId& id, float device_scale_factor) { |
96 DCHECK_EQ(id.id_namespace(), compositor_surface_namespace_); | 96 DCHECK_EQ(id.client_id(), compositor_surface_namespace_); |
97 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) | 97 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) |
98 return; | 98 return; |
99 | 99 |
100 TRACE_EVENT0("cc", "Display::SetSurfaceId"); | 100 TRACE_EVENT0("cc", "Display::SetSurfaceId"); |
101 current_surface_id_ = id; | 101 current_surface_id_ = id; |
102 device_scale_factor_ = device_scale_factor; | 102 device_scale_factor_ = device_scale_factor; |
103 | 103 |
104 UpdateRootSurfaceResourcesLocked(); | 104 UpdateRootSurfaceResourcesLocked(); |
105 if (scheduler_) | 105 if (scheduler_) |
106 scheduler_->SetNewRootSurface(id); | 106 scheduler_->SetNewRootSurface(id); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 395 |
396 void Display::SetTreeActivationCallback(const base::Closure& callback) { | 396 void Display::SetTreeActivationCallback(const base::Closure& callback) { |
397 NOTREACHED(); | 397 NOTREACHED(); |
398 } | 398 } |
399 | 399 |
400 void Display::SetFullRootLayerDamage() { | 400 void Display::SetFullRootLayerDamage() { |
401 if (aggregator_ && !current_surface_id_.is_null()) | 401 if (aggregator_ && !current_surface_id_.is_null()) |
402 aggregator_->SetFullDamageForSurface(current_surface_id_); | 402 aggregator_->SetFullDamageForSurface(current_surface_id_); |
403 } | 403 } |
404 | 404 |
405 void Display::OnSurfaceDamaged(SurfaceId surface_id, bool* changed) { | 405 void Display::OnSurfaceDamaged(const SurfaceId& surface_id, bool* changed) { |
406 if (aggregator_ && | 406 if (aggregator_ && |
407 aggregator_->previous_contained_surfaces().count(surface_id)) { | 407 aggregator_->previous_contained_surfaces().count(surface_id)) { |
408 Surface* surface = surface_manager_->GetSurfaceForId(surface_id); | 408 Surface* surface = surface_manager_->GetSurfaceForId(surface_id); |
409 if (surface) { | 409 if (surface) { |
410 const CompositorFrame& current_frame = surface->GetEligibleFrame(); | 410 const CompositorFrame& current_frame = surface->GetEligibleFrame(); |
411 if (!current_frame.delegated_frame_data || | 411 if (!current_frame.delegated_frame_data || |
412 current_frame.delegated_frame_data->resource_list.empty()) { | 412 current_frame.delegated_frame_data->resource_list.empty()) { |
413 aggregator_->ReleaseResources(surface_id); | 413 aggregator_->ReleaseResources(surface_id); |
414 } | 414 } |
415 } | 415 } |
416 if (scheduler_) | 416 if (scheduler_) |
417 scheduler_->SurfaceDamaged(surface_id); | 417 scheduler_->SurfaceDamaged(surface_id); |
418 *changed = true; | 418 *changed = true; |
419 } else if (surface_id == current_surface_id_) { | 419 } else if (surface_id == current_surface_id_) { |
420 if (scheduler_) | 420 if (scheduler_) |
421 scheduler_->SurfaceDamaged(surface_id); | 421 scheduler_->SurfaceDamaged(surface_id); |
422 *changed = true; | 422 *changed = true; |
423 } | 423 } |
424 | 424 |
425 if (surface_id == current_surface_id_) | 425 if (surface_id == current_surface_id_) |
426 UpdateRootSurfaceResourcesLocked(); | 426 UpdateRootSurfaceResourcesLocked(); |
427 } | 427 } |
428 | 428 |
429 SurfaceId Display::CurrentSurfaceId() { | 429 const SurfaceId& Display::CurrentSurfaceId() { |
430 return current_surface_id_; | 430 return current_surface_id_; |
431 } | 431 } |
432 | 432 |
433 } // namespace cc | 433 } // namespace cc |
OLD | NEW |