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

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

Issue 1281663002: Mandoline: Allow submitting CompositorFrames directly to mojo::Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 4 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/view_manager/surfaces/top_level_display_client.h" 5 #include "components/view_manager/surfaces/top_level_display_client.h"
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/surfaces/display.h" 8 #include "cc/surfaces/display.h"
9 #include "components/view_manager/gles2/gpu_state.h" 9 #include "components/view_manager/gles2/gpu_state.h"
10 #include "components/view_manager/surfaces/surfaces_context_provider.h" 10 #include "components/view_manager/surfaces/surfaces_context_provider.h"
11 #include "components/view_manager/surfaces/surfaces_output_surface.h" 11 #include "components/view_manager/surfaces/surfaces_output_surface.h"
12 #include "components/view_manager/surfaces/surfaces_scheduler.h" 12 #include "components/view_manager/surfaces/surfaces_scheduler.h"
13 #include "components/view_manager/surfaces/surfaces_state.h" 13 #include "components/view_manager/surfaces/surfaces_state.h"
14 #include "mojo/converters/geometry/geometry_type_converters.h"
15 #include "mojo/converters/surfaces/surfaces_type_converters.h"
16 14
17 namespace surfaces { 15 namespace surfaces {
18 namespace { 16 namespace {
19 void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) { 17 void CallCallback(const base::Closure& callback, cc::SurfaceDrawStatus status) {
20 callback.Run(); 18 callback.Run();
21 } 19 }
22 } 20 }
23 21
24 TopLevelDisplayClient::TopLevelDisplayClient( 22 TopLevelDisplayClient::TopLevelDisplayClient(
25 gfx::AcceleratedWidget widget, 23 gfx::AcceleratedWidget widget,
26 const scoped_refptr<gles2::GpuState>& gpu_state, 24 const scoped_refptr<gles2::GpuState>& gpu_state,
27 const scoped_refptr<SurfacesState>& surfaces_state) 25 const scoped_refptr<SurfacesState>& surfaces_state)
28 : gpu_state_(gpu_state), 26 : gpu_state_(gpu_state),
29 surfaces_state_(surfaces_state), 27 surfaces_state_(surfaces_state),
(...skipping 24 matching lines...) Expand all
54 TopLevelDisplayClient::~TopLevelDisplayClient() { 52 TopLevelDisplayClient::~TopLevelDisplayClient() {
55 if (display_) { 53 if (display_) {
56 factory_.Destroy(cc_id_); 54 factory_.Destroy(cc_id_);
57 surfaces_state_->scheduler()->RemoveDisplay(display_.get()); 55 surfaces_state_->scheduler()->RemoveDisplay(display_.get());
58 // By deleting the object after display_ is reset, OutputSurfaceLost can 56 // By deleting the object after display_ is reset, OutputSurfaceLost can
59 // know not to do anything (which would result in double delete). 57 // know not to do anything (which would result in double delete).
60 delete display_.release(); 58 delete display_.release();
61 } 59 }
62 } 60 }
63 61
64 void TopLevelDisplayClient::SubmitFrame(mojo::FramePtr frame, 62 void TopLevelDisplayClient::SubmitFrame(scoped_ptr<cc::CompositorFrame> frame,
65 const base::Closure& callback) { 63 const base::Closure& callback) {
66 DCHECK(pending_callback_.is_null()); 64 DCHECK(pending_callback_.is_null());
67 pending_frame_ = frame.Pass(); 65 pending_frame_ = frame.Pass();
68 pending_callback_ = callback; 66 pending_callback_ = callback;
69 if (display_) 67 if (display_)
70 Draw(); 68 Draw();
71 } 69 }
72 70
73 void TopLevelDisplayClient::Draw() { 71 void TopLevelDisplayClient::Draw() {
74 gfx::Size frame_size = 72 gfx::Size frame_size =
75 pending_frame_->passes[0]->output_rect.To<gfx::Rect>().size(); 73 pending_frame_->delegated_frame_data->render_pass_list.back()->
74 output_rect.size();
76 last_submitted_frame_size_ = frame_size; 75 last_submitted_frame_size_ = frame_size;
77 display_->Resize(frame_size); 76 display_->Resize(frame_size);
78 factory_.SubmitFrame(cc_id_, 77 factory_.SubmitFrame(cc_id_,
79 pending_frame_.To<scoped_ptr<cc::CompositorFrame>>(), 78 pending_frame_.Pass(),
80 base::Bind(&CallCallback, pending_callback_)); 79 base::Bind(&CallCallback, pending_callback_));
81 pending_frame_.reset();
82 surfaces_state_->scheduler()->SetNeedsDraw(); 80 surfaces_state_->scheduler()->SetNeedsDraw();
83 pending_callback_.Reset(); 81 pending_callback_.Reset();
84 } 82 }
85 83
86 void TopLevelDisplayClient::CommitVSyncParameters(base::TimeTicks timebase, 84 void TopLevelDisplayClient::CommitVSyncParameters(base::TimeTicks timebase,
87 base::TimeDelta interval) { 85 base::TimeDelta interval) {
88 } 86 }
89 87
90 void TopLevelDisplayClient::OutputSurfaceLost() { 88 void TopLevelDisplayClient::OutputSurfaceLost() {
91 if (!display_) // Shutdown case 89 if (!display_) // Shutdown case
(...skipping 19 matching lines...) Expand all
111 base::TimeTicks::FromInternalValue(timebase), 109 base::TimeTicks::FromInternalValue(timebase),
112 base::TimeDelta::FromInternalValue(interval)); 110 base::TimeDelta::FromInternalValue(interval));
113 } 111 }
114 112
115 void TopLevelDisplayClient::ReturnResources( 113 void TopLevelDisplayClient::ReturnResources(
116 const cc::ReturnedResourceArray& resources) { 114 const cc::ReturnedResourceArray& resources) {
117 // TODO(fsamuel): Implement this. 115 // TODO(fsamuel): Implement this.
118 } 116 }
119 117
120 } // namespace surfaces 118 } // namespace surfaces
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698