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

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

Issue 1534693002: Delete the Surfaces service. (Closed) Base URL: git@github.com:domokit/mojo.git@cl-2d
Patch Set: rebase Created 5 years 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 | « examples/surfaces_app/child_impl.h ('k') | examples/surfaces_app/embedder.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 "examples/surfaces_app/child_impl.h"
6
7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/delegated_frame_data.h"
10 #include "cc/quads/render_pass.h"
11 #include "cc/quads/solid_color_draw_quad.h"
12 #include "examples/surfaces_app/surfaces_util.h"
13 #include "mojo/converters/geometry/geometry_type_converters.h"
14 #include "mojo/converters/surfaces/surfaces_type_converters.h"
15 #include "mojo/public/cpp/application/application_connection.h"
16 #include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
17 #include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
18 #include "ui/gfx/rect.h"
19 #include "ui/gfx/transform.h"
20
21 namespace mojo {
22 namespace examples {
23
24 using cc::RenderPass;
25 using cc::RenderPassId;
26 using cc::DrawQuad;
27 using cc::SolidColorDrawQuad;
28 using cc::DelegatedFrameData;
29 using cc::CompositorFrame;
30
31 static const uint32_t kLocalId = 1u;
32
33 ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection,
34 InterfaceRequest<Child> request)
35 : id_namespace_(0u), binding_(this, request.Pass()) {
36 surfaces_service_connection->ConnectToService(&surface_);
37 surface_->GetIdNamespace(
38 base::Bind(&ChildImpl::SetIdNamespace, base::Unretained(this)));
39 surface_.WaitForIncomingResponse(); // Wait for ID namespace to arrive.
40 DCHECK_NE(0u, id_namespace_);
41 }
42
43 ChildImpl::~ChildImpl() {
44 surface_->DestroySurface(kLocalId);
45 }
46
47 void ChildImpl::SetIdNamespace(uint32_t id_namespace) {
48 id_namespace_ = id_namespace;
49 }
50
51 void ChildImpl::ProduceFrame(ColorPtr color,
52 SizePtr size_ptr,
53 const ProduceCallback& callback) {
54 gfx::Size size = size_ptr.To<gfx::Size>();
55 gfx::Rect rect(size);
56 RenderPassId id(1, 1);
57 scoped_ptr<RenderPass> pass = RenderPass::Create();
58 pass->SetNew(id, rect, rect, gfx::Transform());
59
60 CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size);
61
62 SolidColorDrawQuad* color_quad =
63 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
64 bool force_anti_aliasing_off = false;
65 color_quad->SetNew(pass->shared_quad_state_list.back(), rect, rect,
66 color.To<SkColor>(), force_anti_aliasing_off);
67
68 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData);
69 delegated_frame_data->render_pass_list.push_back(pass.Pass());
70
71 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
72 frame->delegated_frame_data = delegated_frame_data.Pass();
73
74 surface_->CreateSurface(kLocalId);
75 surface_->SubmitFrame(kLocalId, mojo::Frame::From(*frame), mojo::Closure());
76 auto qualified_id = mojo::SurfaceId::New();
77 qualified_id->id_namespace = id_namespace_;
78 qualified_id->local = kLocalId;
79 callback.Run(qualified_id.Pass());
80 }
81
82 } // namespace examples
83 } // namespace mojo
OLDNEW
« no previous file with comments | « examples/surfaces_app/child_impl.h ('k') | examples/surfaces_app/embedder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698