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

Side by Side Diff: components/mus/surfaces/top_level_display_client.cc

Issue 1821863002: Hook up ui::Compositor to Display's BeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; refactor mus output surface Created 4 years, 8 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/mus/surfaces/top_level_display_client.h" 5 #include "components/mus/surfaces/top_level_display_client.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/copy_output_request.h" 9 #include "cc/output/copy_output_request.h"
10 #include "cc/scheduler/begin_frame_source.h" 10 #include "cc/scheduler/begin_frame_source.h"
(...skipping 20 matching lines...) Expand all
31 gfx::AcceleratedWidget widget, 31 gfx::AcceleratedWidget widget,
32 const scoped_refptr<GpuState>& gpu_state, 32 const scoped_refptr<GpuState>& gpu_state,
33 const scoped_refptr<SurfacesState>& surfaces_state) 33 const scoped_refptr<SurfacesState>& surfaces_state)
34 : task_runner_(base::ThreadTaskRunnerHandle::Get()), 34 : task_runner_(base::ThreadTaskRunnerHandle::Get()),
35 surfaces_state_(surfaces_state), 35 surfaces_state_(surfaces_state),
36 factory_(surfaces_state->manager(), this), 36 factory_(surfaces_state->manager(), this),
37 cc_id_(static_cast<uint64_t>(surfaces_state->next_id_namespace()) << 32) { 37 cc_id_(static_cast<uint64_t>(surfaces_state->next_id_namespace()) << 32) {
38 factory_.Create(cc_id_); 38 factory_.Create(cc_id_);
39 39
40 display_.reset(new cc::Display(this, surfaces_state_->manager(), nullptr, 40 display_.reset(new cc::Display(this, surfaces_state_->manager(), nullptr,
41 nullptr, cc::RendererSettings())); 41 nullptr, cc::RendererSettings(),
42 cc_id_.id_namespace()));
42 43
43 scoped_ptr<cc::OutputSurface> output_surface = 44 scoped_ptr<cc::OutputSurface> output_surface =
44 make_scoped_ptr(new DirectOutputSurface( 45 make_scoped_ptr(new DirectOutputSurface(
45 new SurfacesContextProvider(this, widget, gpu_state))); 46 new SurfacesContextProvider(widget, gpu_state), task_runner_.get()));
46 47
47 int max_frames_pending = output_surface->capabilities().max_frames_pending; 48 int max_frames_pending = output_surface->capabilities().max_frames_pending;
48 DCHECK_GT(max_frames_pending, 0); 49 DCHECK_GT(max_frames_pending, 0);
49 50
50 synthetic_frame_source_.reset(new cc::SyntheticBeginFrameSource(
51 task_runner_.get(), cc::BeginFrameArgs::DefaultInterval()));
52
53 scheduler_.reset(
54 new cc::DisplayScheduler(display_.get(), synthetic_frame_source_.get(),
55 task_runner_.get(), max_frames_pending));
56
57 if (gpu_state->HardwareRenderingAvailable()) { 51 if (gpu_state->HardwareRenderingAvailable()) {
58 display_->Initialize(std::move(output_surface), scheduler_.get()); 52 display_->Initialize(std::move(output_surface), task_runner_.get());
59 } else { 53 } else {
60 // TODO(rjkroege): Implement software compositing. 54 // TODO(rjkroege): Implement software compositing.
61 } 55 }
62 display_->Resize(last_submitted_frame_size_); 56 display_->Resize(last_submitted_frame_size_);
63 57
64 // TODO(fsamuel): Plumb the proper device scale factor. 58 // TODO(fsamuel): Plumb the proper device scale factor.
65 display_->SetSurfaceId(cc_id_, 1.f /* device_scale_factor */); 59 display_->SetSurfaceId(cc_id_, 1.f /* device_scale_factor */);
66 } 60 }
67 61
68 TopLevelDisplayClient::~TopLevelDisplayClient() { 62 TopLevelDisplayClient::~TopLevelDisplayClient() {
(...skipping 11 matching lines...) Expand all
80 display_->Resize(last_submitted_frame_size_); 74 display_->Resize(last_submitted_frame_size_);
81 factory_.SubmitCompositorFrame(cc_id_, std::move(pending_frame_), 75 factory_.SubmitCompositorFrame(cc_id_, std::move(pending_frame_),
82 base::Bind(&CallCallback, callback)); 76 base::Bind(&CallCallback, callback));
83 } 77 }
84 78
85 void TopLevelDisplayClient::RequestCopyOfOutput( 79 void TopLevelDisplayClient::RequestCopyOfOutput(
86 scoped_ptr<cc::CopyOutputRequest> output_request) { 80 scoped_ptr<cc::CopyOutputRequest> output_request) {
87 factory_.RequestCopyOfSurface(cc_id_, std::move(output_request)); 81 factory_.RequestCopyOfSurface(cc_id_, std::move(output_request));
88 } 82 }
89 83
90 void TopLevelDisplayClient::CommitVSyncParameters(base::TimeTicks timebase,
91 base::TimeDelta interval) {}
92
93 void TopLevelDisplayClient::OutputSurfaceLost() { 84 void TopLevelDisplayClient::OutputSurfaceLost() {
94 if (!display_) // Shutdown case 85 if (!display_) // Shutdown case
95 return; 86 return;
96 display_.reset(); 87 display_.reset();
97 } 88 }
98 89
99 void TopLevelDisplayClient::SetMemoryPolicy( 90 void TopLevelDisplayClient::SetMemoryPolicy(
100 const cc::ManagedMemoryPolicy& policy) {} 91 const cc::ManagedMemoryPolicy& policy) {}
101 92
102 void TopLevelDisplayClient::OnVSyncParametersUpdated(int64_t timebase,
103 int64_t interval) {
104 auto timebase_time_ticks = base::TimeTicks::FromInternalValue(timebase);
105 auto interval_time_delta = base::TimeDelta::FromInternalValue(interval);
106
107 if (interval_time_delta.is_zero()) {
108 // TODO(brianderson): We should not be receiving 0 intervals.
109 interval_time_delta = cc::BeginFrameArgs::DefaultInterval();
110 }
111
112 synthetic_frame_source_->OnUpdateVSyncParameters(timebase_time_ticks,
113 interval_time_delta);
114 }
115
116 void TopLevelDisplayClient::ReturnResources( 93 void TopLevelDisplayClient::ReturnResources(
117 const cc::ReturnedResourceArray& resources) { 94 const cc::ReturnedResourceArray& resources) {
118 // TODO(fsamuel): Implement this. 95 // TODO(fsamuel): Implement this.
119 } 96 }
120 97
121 void TopLevelDisplayClient::SetBeginFrameSource( 98 void TopLevelDisplayClient::SetBeginFrameSource(
122 cc::BeginFrameSource* begin_frame_source) { 99 cc::BeginFrameSource* begin_frame_source) {
123 // TODO(tansell): Implement this. 100 // TODO(tansell): Implement this.
124 } 101 }
125 102
126 } // namespace mus 103 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698