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

Side by Side Diff: examples/surfaces_app/child_impl.cc

Issue 871373015: De-Client Surface interface (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 "examples/surfaces_app/child_impl.h" 5 #include "examples/surfaces_app/child_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/delegated_frame_data.h" 9 #include "cc/output/delegated_frame_data.h"
10 #include "cc/quads/render_pass.h" 10 #include "cc/quads/render_pass.h"
(...skipping 15 matching lines...) Expand all
26 using cc::DrawQuad; 26 using cc::DrawQuad;
27 using cc::SolidColorDrawQuad; 27 using cc::SolidColorDrawQuad;
28 using cc::DelegatedFrameData; 28 using cc::DelegatedFrameData;
29 using cc::CompositorFrame; 29 using cc::CompositorFrame;
30 30
31 static const uint32_t kLocalId = 1u; 31 static const uint32_t kLocalId = 1u;
32 32
33 ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) 33 ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection)
34 : id_namespace_(0u) { 34 : id_namespace_(0u) {
35 surfaces_service_connection->ConnectToService(&surface_); 35 surfaces_service_connection->ConnectToService(&surface_);
36 surface_.set_client(this); 36 surface_->GetIdNamespace(
37 base::Bind(&ChildImpl::SetIdNamespace, base::Unretained(this)));
37 surface_.WaitForIncomingMethodCall(); // Wait for ID namespace to arrive. 38 surface_.WaitForIncomingMethodCall(); // Wait for ID namespace to arrive.
38 DCHECK_NE(0u, id_namespace_); 39 DCHECK_NE(0u, id_namespace_);
39 } 40 }
40 41
41 ChildImpl::~ChildImpl() { 42 ChildImpl::~ChildImpl() {
42 surface_->DestroySurface(kLocalId); 43 surface_->DestroySurface(kLocalId);
43 } 44 }
44 45
45 void ChildImpl::SetIdNamespace(uint32_t id_namespace) { 46 void ChildImpl::SetIdNamespace(uint32_t id_namespace) {
46 id_namespace_ = id_namespace; 47 id_namespace_ = id_namespace;
47 } 48 }
48 49
49 void ChildImpl::ReturnResources(
50 Array<ReturnedResourcePtr> resources) {
51 DCHECK(!resources.size());
52 }
53
54 void ChildImpl::ProduceFrame(ColorPtr color, 50 void ChildImpl::ProduceFrame(ColorPtr color,
55 SizePtr size_ptr, 51 SizePtr size_ptr,
56 const ProduceCallback& callback) { 52 const ProduceCallback& callback) {
57 gfx::Size size = size_ptr.To<gfx::Size>(); 53 gfx::Size size = size_ptr.To<gfx::Size>();
58 gfx::Rect rect(size); 54 gfx::Rect rect(size);
59 RenderPassId id(1, 1); 55 RenderPassId id(1, 1);
60 scoped_ptr<RenderPass> pass = RenderPass::Create(); 56 scoped_ptr<RenderPass> pass = RenderPass::Create();
61 pass->SetNew(id, rect, rect, gfx::Transform()); 57 pass->SetNew(id, rect, rect, gfx::Transform());
62 58
63 CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size); 59 CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size);
(...skipping 13 matching lines...) Expand all
77 surface_->CreateSurface(kLocalId); 73 surface_->CreateSurface(kLocalId);
78 surface_->SubmitFrame(kLocalId, mojo::Frame::From(*frame), mojo::Closure()); 74 surface_->SubmitFrame(kLocalId, mojo::Frame::From(*frame), mojo::Closure());
79 auto qualified_id = mojo::SurfaceId::New(); 75 auto qualified_id = mojo::SurfaceId::New();
80 qualified_id->id_namespace = id_namespace_; 76 qualified_id->id_namespace = id_namespace_;
81 qualified_id->local = kLocalId; 77 qualified_id->local = kLocalId;
82 callback.Run(qualified_id.Pass()); 78 callback.Run(qualified_id.Pass());
83 } 79 }
84 80
85 } // namespace examples 81 } // namespace examples
86 } // namespace mojo 82 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698