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

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

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/view_manager/surfaces/top_level_display_client.h"
6
7 #include "cc/output/compositor_frame.h"
8 #include "cc/surfaces/display.h"
9 #include "components/view_manager/gles2/gpu_state.h"
10 #include "components/view_manager/surfaces/surfaces_context_provider.h"
11 #include "components/view_manager/surfaces/surfaces_output_surface.h"
12 #include "components/view_manager/surfaces/surfaces_scheduler.h"
13 #include "components/view_manager/surfaces/surfaces_state.h"
14
15 namespace surfaces {
16 namespace {
17 void CallCallback(const base::Closure& callback, cc::SurfaceDrawStatus status) {
18 callback.Run();
19 }
20 }
21
22 TopLevelDisplayClient::TopLevelDisplayClient(
23 gfx::AcceleratedWidget widget,
24 const scoped_refptr<gles2::GpuState>& gpu_state,
25 const scoped_refptr<SurfacesState>& surfaces_state)
26 : gpu_state_(gpu_state),
27 surfaces_state_(surfaces_state),
28 factory_(surfaces_state->manager(), this),
29 cc_id_(static_cast<uint64_t>(surfaces_state->next_id_namespace()) << 32) {
30 factory_.Create(cc_id_);
31
32 display_.reset(new cc::Display(this, surfaces_state_->manager(), nullptr,
33 nullptr, cc::RendererSettings()));
34 surfaces_state_->scheduler()->AddDisplay(display_.get());
35
36 // TODO(brianderson): Reconcile with SurfacesScheduler crbug.com/476676
37 cc::DisplayScheduler* null_display_scheduler = nullptr;
38 display_->Initialize(
39 make_scoped_ptr(new surfaces::DirectOutputSurface(
40 new SurfacesContextProvider(this, widget, gpu_state))),
41 null_display_scheduler);
42
43 display_->Resize(last_submitted_frame_size_);
44
45 // TODO(fsamuel): Plumb the proper device scale factor.
46 display_->SetSurfaceId(cc_id_, 1.f /* device_scale_factor */);
47 }
48
49 void TopLevelDisplayClient::OnContextCreated() {
50 }
51
52 TopLevelDisplayClient::~TopLevelDisplayClient() {
53 if (display_) {
54 factory_.Destroy(cc_id_);
55 surfaces_state_->scheduler()->RemoveDisplay(display_.get());
56 // By deleting the object after display_ is reset, OutputSurfaceLost can
57 // know not to do anything (which would result in double delete).
58 delete display_.release();
59 }
60 }
61
62 void TopLevelDisplayClient::SubmitCompositorFrame(
63 scoped_ptr<cc::CompositorFrame> frame,
64 const base::Closure& callback) {
65 pending_frame_ = frame.Pass();
66
67 last_submitted_frame_size_ =
68 pending_frame_->delegated_frame_data->render_pass_list.back()->
69 output_rect.size();
70 display_->Resize(last_submitted_frame_size_);
71 factory_.SubmitCompositorFrame(cc_id_, pending_frame_.Pass(),
72 base::Bind(&CallCallback, callback));
73 surfaces_state_->scheduler()->SetNeedsDraw();
74 }
75
76 void TopLevelDisplayClient::CommitVSyncParameters(base::TimeTicks timebase,
77 base::TimeDelta interval) {
78 }
79
80 void TopLevelDisplayClient::OutputSurfaceLost() {
81 if (!display_) // Shutdown case
82 return;
83
84 // If our OutputSurface is lost we can't draw until we get a new one. For now,
85 // destroy the display and create a new one when our ContextProvider provides
86 // a new one.
87 // TODO: This is more violent than necessary - we could simply remove this
88 // display from the scheduler's set and pass a new context in to the
89 // OutputSurface. It should be able to reinitialize properly.
90 surfaces_state_->scheduler()->RemoveDisplay(display_.get());
91 display_.reset();
92 }
93
94 void TopLevelDisplayClient::SetMemoryPolicy(
95 const cc::ManagedMemoryPolicy& policy) {
96 }
97
98 void TopLevelDisplayClient::OnVSyncParametersUpdated(int64_t timebase,
99 int64_t interval) {
100 surfaces_state_->scheduler()->OnVSyncParametersUpdated(
101 base::TimeTicks::FromInternalValue(timebase),
102 base::TimeDelta::FromInternalValue(interval));
103 }
104
105 void TopLevelDisplayClient::ReturnResources(
106 const cc::ReturnedResourceArray& resources) {
107 // TODO(fsamuel): Implement this.
108 }
109
110 } // namespace surfaces
OLDNEW
« no previous file with comments | « components/view_manager/surfaces/top_level_display_client.h ('k') | components/view_manager/test_change_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698