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

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

Issue 504443002: Update mojo surfaces bindings and mojo/cc/ glue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 "mojo/examples/surfaces_app/child_impl.h" 5 #include "mojo/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"
11 #include "cc/quads/solid_color_draw_quad.h" 11 #include "cc/quads/solid_color_draw_quad.h"
12 #include "mojo/examples/surfaces_app/surfaces_util.h" 12 #include "mojo/examples/surfaces_app/surfaces_util.h"
13 #include "mojo/public/cpp/application/application_connection.h" 13 #include "mojo/public/cpp/application/application_connection.h"
14 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 14 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
15 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" 15 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h"
16 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" 16 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h"
17 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" 17 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h"
18 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
19 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
20 20
21 namespace mojo { 21 namespace mojo {
22 namespace examples { 22 namespace examples {
23 23
24 using cc::RenderPass; 24 using cc::RenderPass;
25 using cc::DrawQuad; 25 using cc::DrawQuad;
26 using cc::SolidColorDrawQuad; 26 using cc::SolidColorDrawQuad;
27 using cc::DelegatedFrameData; 27 using cc::DelegatedFrameData;
28 using cc::CompositorFrame; 28 using cc::CompositorFrame;
29 29
30 ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) { 30 ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection)
31 surfaces_service_connection->ConnectToService(&surface_); 31 : weak_factory_(this) {
32 surface_.set_client(this); 32 surfaces_service_connection->ConnectToService(&surfaces_service_);
33 surfaces_service_->CreateSurfaceConnection(base::Bind(
34 &ChildImpl::SurfaceConnectionCreated, weak_factory_.GetWeakPtr()));
33 } 35 }
34 36
35 ChildImpl::~ChildImpl() { 37 ChildImpl::~ChildImpl() {
36 surface_->DestroySurface(mojo::SurfaceId::From(id_)); 38 if (surface_)
39 surface_->DestroySurface(mojo::SurfaceId::From(id_));
37 } 40 }
38 41
39 void ChildImpl::ProduceFrame( 42 void ChildImpl::ProduceFrame(
40 ColorPtr color, 43 ColorPtr color,
41 SizePtr size, 44 SizePtr size,
42 const mojo::Callback<void(SurfaceIdPtr id)>& callback) { 45 const mojo::Callback<void(SurfaceIdPtr id)>& callback) {
43 color_ = color.To<SkColor>(); 46 color_ = color.To<SkColor>();
44 size_ = size.To<gfx::Size>(); 47 size_ = size.To<gfx::Size>();
45 produce_callback_ = callback; 48 produce_callback_ = callback;
46 if (allocator_) 49 if (allocator_)
47 Draw(); 50 Draw();
48 } 51 }
49 52
50 void ChildImpl::SetIdNamespace(uint32_t id_namespace) { 53 void ChildImpl::SurfaceConnectionCreated(SurfacePtr surface,
54 uint32_t id_namespace) {
55 surface_ = surface.Pass();
56 surface_.set_client(this);
51 allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); 57 allocator_.reset(new cc::SurfaceIdAllocator(id_namespace));
52 if (!produce_callback_.is_null()) 58 if (!produce_callback_.is_null())
53 Draw(); 59 Draw();
54 } 60 }
55 61
56 void ChildImpl::ReturnResources( 62 void ChildImpl::ReturnResources(
57 Array<ReturnedResourcePtr> resources) { 63 Array<ReturnedResourcePtr> resources) {
58 DCHECK(!resources.size()); 64 DCHECK(!resources.size());
59 } 65 }
60 66
(...skipping 23 matching lines...) Expand all
84 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 90 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
85 frame->delegated_frame_data = delegated_frame_data.Pass(); 91 frame->delegated_frame_data = delegated_frame_data.Pass();
86 92
87 surface_->SubmitFrame(mojo::SurfaceId::From(id_), 93 surface_->SubmitFrame(mojo::SurfaceId::From(id_),
88 mojo::Frame::From(*frame)); 94 mojo::Frame::From(*frame));
89 produce_callback_.Run(SurfaceId::From(id_)); 95 produce_callback_.Run(SurfaceId::From(id_));
90 } 96 }
91 97
92 } // namespace examples 98 } // namespace examples
93 } // namespace mojo 99 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698