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

Side by Side Diff: sky/compositor/surface_holder.cc

Issue 1213683004: Move //sky/compositor to //sky/viewer/compositor (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « sky/compositor/surface_holder.h ('k') | sky/compositor/texture_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sky/compositor/surface_holder.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/public/cpp/application/connect.h"
11 #include "mojo/public/interfaces/application/shell.mojom.h"
12 #include "sky/compositor/surface_allocator.h"
13
14 namespace sky {
15
16 SurfaceHolder::Client::~Client() {
17 }
18
19 SurfaceHolder::SurfaceHolder(Client* client, mojo::Shell* shell)
20 : client_(client),
21 id_namespace_(0u),
22 local_id_(0u),
23 returner_binding_(this),
24 weak_factory_(this) {
25 mojo::ServiceProviderPtr service_provider;
26 shell->ConnectToApplication("mojo:surfaces_service",
27 mojo::GetProxy(&service_provider), nullptr);
28 mojo::ConnectToService(service_provider.get(), &surface_);
29 surface_->GetIdNamespace(
30 base::Bind(&SurfaceHolder::SetIdNamespace, base::Unretained(this)));
31 mojo::ResourceReturnerPtr returner_ptr;
32 returner_binding_.Bind(GetProxy(&returner_ptr));
33 surface_->SetResourceReturner(returner_ptr.Pass());
34 }
35
36 SurfaceHolder::~SurfaceHolder() {
37 if (local_id_ != 0u)
38 surface_->DestroySurface(local_id_);
39 }
40
41 void SurfaceHolder::SubmitFrame(mojo::FramePtr frame,
42 const base::Closure& callback) {
43 surface_->SubmitFrame(local_id_, frame.Pass(), callback);
44 }
45
46 void SurfaceHolder::SetSize(const gfx::Size& size) {
47 if (local_id_ != 0u && size_ == size)
48 return;
49
50 if (local_id_ != 0u)
51 surface_->DestroySurface(local_id_);
52
53 local_id_++;
54 surface_->CreateSurface(local_id_);
55 size_ = size;
56
57 if (id_namespace_ != 0u)
58 SetQualifiedId();
59 }
60
61 void SurfaceHolder::SetQualifiedId() {
62 auto qualified_id = mojo::SurfaceId::New();
63 qualified_id->id_namespace = id_namespace_;
64 qualified_id->local = local_id_;
65 client_->OnSurfaceIdAvailable(qualified_id.Pass());
66 }
67
68 void SurfaceHolder::SetIdNamespace(uint32_t id_namespace) {
69 id_namespace_ = id_namespace;
70 if (local_id_ != 0u)
71 SetQualifiedId();
72 }
73
74 void SurfaceHolder::ReturnResources(
75 mojo::Array<mojo::ReturnedResourcePtr> resources) {
76 client_->ReturnResources(resources.Pass());
77 }
78
79 } // namespace sky
OLDNEW
« no previous file with comments | « sky/compositor/surface_holder.h ('k') | sky/compositor/texture_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698