Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: cc/surfaces/display.cc

Issue 2411793008: Adds BeginFrameControl via DevTools.
Patch Set: BFC prototype v2 with allow_latency_opts and waiting for BFOs. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/display_begin_frame_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 const RendererSettings& settings, 35 const RendererSettings& settings,
36 const FrameSinkId& frame_sink_id, 36 const FrameSinkId& frame_sink_id,
37 std::unique_ptr<BeginFrameSource> begin_frame_source, 37 std::unique_ptr<BeginFrameSource> begin_frame_source,
38 std::unique_ptr<OutputSurface> output_surface, 38 std::unique_ptr<OutputSurface> output_surface,
39 std::unique_ptr<DisplayScheduler> scheduler, 39 std::unique_ptr<DisplayScheduler> scheduler,
40 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter) 40 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter)
41 : bitmap_manager_(bitmap_manager), 41 : bitmap_manager_(bitmap_manager),
42 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 42 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
43 settings_(settings), 43 settings_(settings),
44 frame_sink_id_(frame_sink_id), 44 frame_sink_id_(frame_sink_id),
45 begin_frame_source_(std::move(begin_frame_source)), 45 begin_frame_source_(
46 new DisplayBeginFrameSource(std::move(begin_frame_source))),
46 output_surface_(std::move(output_surface)), 47 output_surface_(std::move(output_surface)),
47 scheduler_(std::move(scheduler)), 48 scheduler_(std::move(scheduler)),
48 texture_mailbox_deleter_(std::move(texture_mailbox_deleter)) { 49 texture_mailbox_deleter_(std::move(texture_mailbox_deleter)) {
49 DCHECK(output_surface_); 50 DCHECK(output_surface_);
50 DCHECK_EQ(!scheduler_, !begin_frame_source_); 51 DCHECK_EQ(!scheduler_, !begin_frame_source_->GetTargetSource());
51 DCHECK(frame_sink_id_.is_valid()); 52 DCHECK(frame_sink_id_.is_valid());
52 if (scheduler_) 53 if (scheduler_) {
53 scheduler_->SetClient(this); 54 scheduler_->SetClient(this);
55 scheduler_->SetBeginFrameSource(begin_frame_source_.get());
56 }
54 } 57 }
55 58
56 Display::~Display() { 59 Display::~Display() {
57 // Only do this if Initialize() happened. 60 // Only do this if Initialize() happened.
58 if (client_) { 61 if (client_) {
59 if (auto* context = output_surface_->context_provider()) 62 if (auto* context = output_surface_->context_provider())
60 context->SetLostContextCallback(base::Closure()); 63 context->SetLostContextCallback(base::Closure());
61 if (begin_frame_source_) 64 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_.get());
62 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_.get());
63 surface_manager_->RemoveObserver(this); 65 surface_manager_->RemoveObserver(this);
64 } 66 }
65 if (aggregator_) { 67 if (aggregator_) {
66 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { 68 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) {
67 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); 69 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first);
68 if (surface) 70 if (surface)
69 surface->RunDrawCallbacks(); 71 surface->RunDrawCallbacks();
70 } 72 }
71 } 73 }
72 } 74 }
73 75
74 void Display::Initialize(DisplayClient* client, 76 void Display::Initialize(DisplayClient* client,
75 SurfaceManager* surface_manager) { 77 SurfaceManager* surface_manager) {
76 DCHECK(client); 78 DCHECK(client);
77 DCHECK(surface_manager); 79 DCHECK(surface_manager);
78 client_ = client; 80 client_ = client;
79 surface_manager_ = surface_manager; 81 surface_manager_ = surface_manager;
80 82
81 surface_manager_->AddObserver(this); 83 surface_manager_->AddObserver(this);
82 84
83 // This must be done in Initialize() so that the caller can delay this until 85 // This must be done in Initialize() so that the caller can delay this until
84 // they are ready to receive a BeginFrameSource. 86 // they are ready to receive a BeginFrameSource.
85 if (begin_frame_source_) { 87 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(),
86 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(), 88 frame_sink_id_);
87 frame_sink_id_);
88 }
89 89
90 output_surface_->BindToClient(this); 90 output_surface_->BindToClient(this);
91 InitializeRenderer(); 91 InitializeRenderer();
92 92
93 if (auto* context = output_surface_->context_provider()) { 93 if (auto* context = output_surface_->context_provider()) {
94 // This depends on assumptions that Display::Initialize will happen 94 // This depends on assumptions that Display::Initialize will happen
95 // on the same callstack as the ContextProvider being created/initialized 95 // on the same callstack as the ContextProvider being created/initialized
96 // or else it could miss a callback before setting this. 96 // or else it could miss a callback before setting this.
97 context->SetLostContextCallback(base::Bind( 97 context->SetLostContextCallback(base::Bind(
98 &Display::DidLoseContextProvider, 98 &Display::DidLoseContextProvider,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 const SurfaceId& Display::CurrentSurfaceId() { 401 const SurfaceId& Display::CurrentSurfaceId() {
402 return current_surface_id_; 402 return current_surface_id_;
403 } 403 }
404 404
405 void Display::ForceImmediateDrawAndSwapIfPossible() { 405 void Display::ForceImmediateDrawAndSwapIfPossible() {
406 if (scheduler_) 406 if (scheduler_)
407 scheduler_->ForceImmediateSwapIfPossible(); 407 scheduler_->ForceImmediateSwapIfPossible();
408 } 408 }
409 409
410 void Display::SwapBeginFrameSource(
411 std::unique_ptr<BeginFrameSource>* begin_frame_source) {
412 begin_frame_source_->SwapTargetSource(begin_frame_source);
413 }
414
410 } // namespace cc 415 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/display_begin_frame_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698