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

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: Move Android external BFS into output surface too 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 18 matching lines...) Expand all
29 29
30 TopLevelDisplayClient::TopLevelDisplayClient( 30 TopLevelDisplayClient::TopLevelDisplayClient(
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 surfaces_state_->manager()->RegisterSurfaceIdNamespace(cc_id_.id_namespace());
39 40
40 display_.reset(new cc::Display(this, surfaces_state_->manager(), nullptr, 41 display_.reset(new cc::Display(this, surfaces_state_->manager(), nullptr,
41 nullptr, cc::RendererSettings())); 42 nullptr, cc::RendererSettings(),
43 cc_id_.id_namespace()));
42 44
43 scoped_ptr<cc::OutputSurface> output_surface = 45 scoped_ptr<cc::OutputSurface> output_surface =
44 make_scoped_ptr(new DirectOutputSurface( 46 make_scoped_ptr(new DirectOutputSurface(
45 new SurfacesContextProvider(this, widget, gpu_state))); 47 new SurfacesContextProvider(widget, gpu_state), task_runner_.get()));
46 48
47 int max_frames_pending = output_surface->capabilities().max_frames_pending; 49 int max_frames_pending = output_surface->capabilities().max_frames_pending;
48 DCHECK_GT(max_frames_pending, 0); 50 DCHECK_GT(max_frames_pending, 0);
49 51
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()) { 52 if (gpu_state->HardwareRenderingAvailable()) {
58 display_->Initialize(std::move(output_surface), scheduler_.get()); 53 display_->Initialize(std::move(output_surface));
59 } else { 54 } else {
60 // TODO(rjkroege): Implement software compositing. 55 // TODO(rjkroege): Implement software compositing.
61 } 56 }
62 display_->Resize(last_submitted_frame_size_); 57 display_->Resize(last_submitted_frame_size_);
63 58
64 // TODO(fsamuel): Plumb the proper device scale factor. 59 // TODO(fsamuel): Plumb the proper device scale factor.
65 display_->SetSurfaceId(cc_id_, 1.f /* device_scale_factor */); 60 display_->SetSurfaceId(cc_id_, 1.f /* device_scale_factor */);
66 } 61 }
67 62
68 TopLevelDisplayClient::~TopLevelDisplayClient() { 63 TopLevelDisplayClient::~TopLevelDisplayClient() {
64 surfaces_state_->manager()->InvalidateSurfaceIdNamespace(
65 cc_id_.id_namespace());
69 factory_.Destroy(cc_id_); 66 factory_.Destroy(cc_id_);
70 } 67 }
71 68
72 void TopLevelDisplayClient::SubmitCompositorFrame( 69 void TopLevelDisplayClient::SubmitCompositorFrame(
73 scoped_ptr<cc::CompositorFrame> frame, 70 scoped_ptr<cc::CompositorFrame> frame,
74 const base::Closure& callback) { 71 const base::Closure& callback) {
75 pending_frame_ = std::move(frame); 72 pending_frame_ = std::move(frame);
76 73
77 last_submitted_frame_size_ = 74 last_submitted_frame_size_ =
78 pending_frame_->delegated_frame_data->render_pass_list.back() 75 pending_frame_->delegated_frame_data->render_pass_list.back()
79 ->output_rect.size(); 76 ->output_rect.size();
80 display_->Resize(last_submitted_frame_size_); 77 display_->Resize(last_submitted_frame_size_);
81 factory_.SubmitCompositorFrame(cc_id_, std::move(pending_frame_), 78 factory_.SubmitCompositorFrame(cc_id_, std::move(pending_frame_),
82 base::Bind(&CallCallback, callback)); 79 base::Bind(&CallCallback, callback));
83 } 80 }
84 81
85 void TopLevelDisplayClient::RequestCopyOfOutput( 82 void TopLevelDisplayClient::RequestCopyOfOutput(
86 scoped_ptr<cc::CopyOutputRequest> output_request) { 83 scoped_ptr<cc::CopyOutputRequest> output_request) {
87 factory_.RequestCopyOfSurface(cc_id_, std::move(output_request)); 84 factory_.RequestCopyOfSurface(cc_id_, std::move(output_request));
88 } 85 }
89 86
90 void TopLevelDisplayClient::CommitVSyncParameters(base::TimeTicks timebase,
91 base::TimeDelta interval) {}
92
93 void TopLevelDisplayClient::OutputSurfaceLost() { 87 void TopLevelDisplayClient::OutputSurfaceLost() {
94 if (!display_) // Shutdown case 88 if (!display_) // Shutdown case
95 return; 89 return;
96 display_.reset(); 90 display_.reset();
97 } 91 }
98 92
99 void TopLevelDisplayClient::SetMemoryPolicy( 93 void TopLevelDisplayClient::SetMemoryPolicy(
100 const cc::ManagedMemoryPolicy& policy) {} 94 const cc::ManagedMemoryPolicy& policy) {}
101 95
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( 96 void TopLevelDisplayClient::ReturnResources(
117 const cc::ReturnedResourceArray& resources) { 97 const cc::ReturnedResourceArray& resources) {
118 // TODO(fsamuel): Implement this. 98 // TODO(fsamuel): Implement this.
119 } 99 }
120 100
121 void TopLevelDisplayClient::SetBeginFrameSource( 101 void TopLevelDisplayClient::SetBeginFrameSource(
122 cc::BeginFrameSource* begin_frame_source) { 102 cc::BeginFrameSource* begin_frame_source) {
123 // TODO(tansell): Implement this. 103 // TODO(tansell): Implement this.
124 } 104 }
125 105
126 } // namespace mus 106 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698