| 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" |
| 11 #include "cc/debug/benchmark_instrumentation.h" | 11 #include "cc/debug/benchmark_instrumentation.h" |
| 12 #include "cc/output/compositor_frame.h" | 12 #include "cc/output/compositor_frame.h" |
| 13 #include "cc/output/direct_renderer.h" | 13 #include "cc/output/direct_renderer.h" |
| 14 #include "cc/output/gl_renderer.h" | 14 #include "cc/output/gl_renderer.h" |
| 15 #include "cc/output/renderer_settings.h" | 15 #include "cc/output/renderer_settings.h" |
| 16 #include "cc/output/software_renderer.h" | 16 #include "cc/output/software_renderer.h" |
| 17 #include "cc/output/texture_mailbox_deleter.h" | 17 #include "cc/output/texture_mailbox_deleter.h" |
| 18 #include "cc/scheduler/begin_frame_source.h" | 18 #include "cc/scheduler/begin_frame_source.h" |
| 19 #include "cc/surfaces/display_client.h" | 19 #include "cc/surfaces/display_client.h" |
| 20 #include "cc/surfaces/display_scheduler.h" | 20 #include "cc/surfaces/display_scheduler.h" |
| 21 #include "cc/surfaces/framesink_manager.h" |
| 21 #include "cc/surfaces/surface.h" | 22 #include "cc/surfaces/surface.h" |
| 22 #include "cc/surfaces/surface_aggregator.h" | 23 #include "cc/surfaces/surface_aggregator.h" |
| 23 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
| 24 #include "gpu/command_buffer/client/gles2_interface.h" | 25 #include "gpu/command_buffer/client/gles2_interface.h" |
| 25 #include "ui/gfx/buffer_types.h" | 26 #include "ui/gfx/buffer_types.h" |
| 26 | 27 |
| 27 #if defined(ENABLE_VULKAN) | 28 #if defined(ENABLE_VULKAN) |
| 28 #include "cc/output/vulkan_renderer.h" | 29 #include "cc/output/vulkan_renderer.h" |
| 29 #endif | 30 #endif |
| 30 | 31 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 scheduler_->SetBeginFrameSource(begin_frame_source); | 55 scheduler_->SetBeginFrameSource(begin_frame_source); |
| 55 } | 56 } |
| 56 } | 57 } |
| 57 | 58 |
| 58 Display::~Display() { | 59 Display::~Display() { |
| 59 // Only do this if Initialize() happened. | 60 // Only do this if Initialize() happened. |
| 60 if (client_) { | 61 if (client_) { |
| 61 if (auto* context = output_surface_->context_provider()) | 62 if (auto* context = output_surface_->context_provider()) |
| 62 context->SetLostContextCallback(base::Closure()); | 63 context->SetLostContextCallback(base::Closure()); |
| 63 if (begin_frame_source_) | 64 if (begin_frame_source_) |
| 64 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_); | 65 framesink_manager_->UnregisterBeginFrameSource(begin_frame_source_); |
| 65 surface_manager_->RemoveObserver(this); | 66 surface_manager_->RemoveObserver(this); |
| 66 } | 67 } |
| 67 if (aggregator_) { | 68 if (aggregator_) { |
| 68 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { | 69 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { |
| 69 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); | 70 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); |
| 70 if (surface) | 71 if (surface) |
| 71 surface->RunDrawCallbacks(); | 72 surface->RunDrawCallbacks(); |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 void Display::Initialize(DisplayClient* client, | 77 void Display::Initialize(DisplayClient* client, |
| 77 SurfaceManager* surface_manager) { | 78 SurfaceManager* surface_manager, |
| 79 FrameSinkManager* framesink_manager) { |
| 78 DCHECK(client); | 80 DCHECK(client); |
| 79 DCHECK(surface_manager); | 81 DCHECK(surface_manager); |
| 80 client_ = client; | 82 client_ = client; |
| 81 surface_manager_ = surface_manager; | 83 surface_manager_ = surface_manager; |
| 84 framesink_manager_ = framesink_manager; |
| 82 | 85 |
| 83 surface_manager_->AddObserver(this); | 86 surface_manager_->AddObserver(this); |
| 84 | 87 |
| 85 // This must be done in Initialize() so that the caller can delay this until | 88 // This must be done in Initialize() so that the caller can delay this until |
| 86 // they are ready to receive a BeginFrameSource. | 89 // they are ready to receive a BeginFrameSource. |
| 87 if (begin_frame_source_) { | 90 if (begin_frame_source_) { |
| 88 surface_manager_->RegisterBeginFrameSource(begin_frame_source_, | 91 framesink_manager_->RegisterBeginFrameSource(begin_frame_source_, |
| 89 frame_sink_id_); | 92 frame_sink_id_); |
| 90 } | 93 } |
| 91 | 94 |
| 92 output_surface_->BindToClient(this); | 95 output_surface_->BindToClient(this); |
| 93 InitializeRenderer(); | 96 InitializeRenderer(); |
| 94 | 97 |
| 95 if (auto* context = output_surface_->context_provider()) { | 98 if (auto* context = output_surface_->context_provider()) { |
| 96 // This depends on assumptions that Display::Initialize will happen | 99 // This depends on assumptions that Display::Initialize will happen |
| 97 // on the same callstack as the ContextProvider being created/initialized | 100 // on the same callstack as the ContextProvider being created/initialized |
| 98 // or else it could miss a callback before setting this. | 101 // or else it could miss a callback before setting this. |
| 99 context->SetLostContextCallback(base::Bind( | 102 context->SetLostContextCallback(base::Bind( |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 const SurfaceId& Display::CurrentSurfaceId() { | 400 const SurfaceId& Display::CurrentSurfaceId() { |
| 398 return current_surface_id_; | 401 return current_surface_id_; |
| 399 } | 402 } |
| 400 | 403 |
| 401 void Display::ForceImmediateDrawAndSwapIfPossible() { | 404 void Display::ForceImmediateDrawAndSwapIfPossible() { |
| 402 if (scheduler_) | 405 if (scheduler_) |
| 403 scheduler_->ForceImmediateSwapIfPossible(); | 406 scheduler_->ForceImmediateSwapIfPossible(); |
| 404 } | 407 } |
| 405 | 408 |
| 406 } // namespace cc | 409 } // namespace cc |
| OLD | NEW |