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

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

Issue 1245683004: Mandoline: Merge Surfaces and Views apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Rob's 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 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 "components/view_manager/surfaces/surfaces_impl.h" 5 #include "components/view_manager/surfaces/surfaces_impl.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/resources/returned_resource.h" 9 #include "cc/resources/returned_resource.h"
10 #include "cc/surfaces/surface_id_allocator.h" 10 #include "cc/surfaces/surface_id_allocator.h"
11 #include "components/view_manager/surfaces/surfaces_scheduler.h" 11 #include "components/view_manager/surfaces/surfaces_scheduler.h"
12 #include "components/view_manager/surfaces/surfaces_service_application.h"
13 #include "mojo/converters/geometry/geometry_type_converters.h" 12 #include "mojo/converters/geometry/geometry_type_converters.h"
14 #include "mojo/converters/surfaces/surfaces_type_converters.h" 13 #include "mojo/converters/surfaces/surfaces_type_converters.h"
15 14
16 using mojo::SurfaceIdPtr; 15 using mojo::SurfaceIdPtr;
17 16
18 namespace surfaces { 17 namespace surfaces {
19 18
20 namespace { 19 namespace {
21 void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) { 20 void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) {
22 callback.Run(); 21 callback.Run();
23 } 22 }
24 } 23 }
25 24
26 SurfacesImpl::SurfacesImpl(SurfacesServiceApplication* application, 25 SurfacesImpl::SurfacesImpl(const scoped_refptr<SurfacesState>& state,
27 cc::SurfaceManager* manager,
28 uint32_t id_namespace,
29 SurfacesScheduler* scheduler,
30 mojo::InterfaceRequest<mojo::Surface> request) 26 mojo::InterfaceRequest<mojo::Surface> request)
31 : application_(application), 27 : state_(state),
32 manager_(manager), 28 id_namespace_(state->next_id_namespace()),
33 factory_(manager, this), 29 factory_(state->manager(), this),
34 id_namespace_(id_namespace),
35 scheduler_(scheduler),
36 binding_(this, request.Pass()) { 30 binding_(this, request.Pass()) {
37 } 31 }
38 32
39 SurfacesImpl::~SurfacesImpl() { 33 SurfacesImpl::~SurfacesImpl() {
40 application_->SurfaceDestroyed(this);
41 factory_.DestroyAll(); 34 factory_.DestroyAll();
42 } 35 }
43 36
44 void SurfacesImpl::GetIdNamespace( 37 void SurfacesImpl::GetIdNamespace(
45 const Surface::GetIdNamespaceCallback& callback) { 38 const Surface::GetIdNamespaceCallback& callback) {
46 callback.Run(id_namespace_); 39 callback.Run(id_namespace_);
47 } 40 }
48 41
49 void SurfacesImpl::SetResourceReturner(mojo::ResourceReturnerPtr returner) { 42 void SurfacesImpl::SetResourceReturner(mojo::ResourceReturnerPtr returner) {
50 returner_ = returner.Pass(); 43 returner_ = returner.Pass();
51 } 44 }
52 45
53 void SurfacesImpl::CreateSurface(uint32_t local_id) { 46 void SurfacesImpl::CreateSurface(uint32_t local_id) {
54 factory_.Create(QualifyIdentifier(local_id)); 47 factory_.Create(QualifyIdentifier(local_id));
55 } 48 }
56 49
57 void SurfacesImpl::SubmitFrame(uint32_t local_id, 50 void SurfacesImpl::SubmitFrame(uint32_t local_id,
58 mojo::FramePtr frame, 51 mojo::FramePtr frame,
59 const mojo::Closure& callback) { 52 const mojo::Closure& callback) {
60 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame"); 53 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame");
61 factory_.SubmitFrame(QualifyIdentifier(local_id), 54 factory_.SubmitFrame(QualifyIdentifier(local_id),
62 frame.To<scoped_ptr<cc::CompositorFrame>>(), 55 frame.To<scoped_ptr<cc::CompositorFrame>>(),
63 base::Bind(&CallCallback, callback)); 56 base::Bind(&CallCallback, callback));
64 scheduler_->SetNeedsDraw(); 57 state_->scheduler()->SetNeedsDraw();
65 } 58 }
66 59
67 void SurfacesImpl::DestroySurface(uint32_t local_id) { 60 void SurfacesImpl::DestroySurface(uint32_t local_id) {
68 factory_.Destroy(QualifyIdentifier(local_id)); 61 factory_.Destroy(QualifyIdentifier(local_id));
69 } 62 }
70 63
71 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { 64 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
72 if (resources.empty() || !returner_) 65 if (resources.empty() || !returner_)
73 return; 66 return;
74 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); 67 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size());
75 for (size_t i = 0; i < resources.size(); ++i) { 68 for (size_t i = 0; i < resources.size(); ++i) {
76 ret[i] = mojo::ReturnedResource::From(resources[i]); 69 ret[i] = mojo::ReturnedResource::From(resources[i]);
77 } 70 }
78 returner_->ReturnResources(ret.Pass()); 71 returner_->ReturnResources(ret.Pass());
79 } 72 }
80 73
81 cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) { 74 cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) {
82 return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id); 75 return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id);
83 } 76 }
84 77
85 } // namespace mojo 78 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698