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

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

Issue 361123002: Mojo surfaces service and example app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « mojo/examples/surfaces_app/embedder.h ('k') | mojo/examples/surfaces_app/surfaces_app.cc » ('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 "mojo/examples/surfaces_app/embedder.h"
6
7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/delegated_frame_data.h"
9 #include "cc/quads/render_pass.h"
10 #include "cc/quads/solid_color_draw_quad.h"
11 #include "cc/quads/surface_draw_quad.h"
12 #include "mojo/examples/surfaces_app/surfaces_util.h"
13 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h"
14 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h"
15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/size.h"
17 #include "ui/gfx/transform.h"
18
19 namespace mojo {
20 namespace examples {
21
22 using cc::RenderPass;
23 using cc::SurfaceDrawQuad;
24 using cc::DrawQuad;
25 using cc::SolidColorDrawQuad;
26 using cc::DelegatedFrameData;
27 using cc::CompositorFrame;
28
29 Embedder::Embedder(surfaces::Surface* surface) : surface_(surface) {
30 }
31
32 Embedder::~Embedder() {
33 }
34
35 void Embedder::ProduceFrame(cc::SurfaceId child_one,
36 cc::SurfaceId child_two,
37 const gfx::Size& child_size,
38 const gfx::Size& size,
39 double rotation_degrees) {
40 gfx::Rect rect(size);
41 RenderPass::Id pass_id(1, 1);
42 scoped_ptr<RenderPass> pass = RenderPass::Create();
43 pass->SetNew(pass_id, rect, rect, gfx::Transform());
44
45 gfx::Transform one_transform;
46 one_transform.Translate(10 + child_size.width() / 2,
47 50 + child_size.height() / 2);
48 one_transform.Rotate(rotation_degrees);
49 one_transform.Translate(-child_size.width() / 2, -child_size.height() / 2);
50 CreateAndAppendSimpleSharedQuadState(pass.get(), one_transform, size);
51
52 scoped_ptr<SurfaceDrawQuad> surface_one_quad = SurfaceDrawQuad::Create();
53 gfx::Rect one_rect(child_size);
54 surface_one_quad->SetNew(
55 pass->shared_quad_state_list.back(), one_rect, one_rect, child_one);
56 pass->quad_list.push_back(surface_one_quad.PassAs<DrawQuad>());
57
58 gfx::Transform two_transform;
59 two_transform.Translate(10 + size.width() / 2 + child_size.width() / 2,
60 50 + child_size.height() / 2);
61 two_transform.Rotate(-rotation_degrees * 0.76);
62 two_transform.Translate(-child_size.width() / 2, -child_size.height() / 2);
63 CreateAndAppendSimpleSharedQuadState(pass.get(), two_transform, size);
64
65 scoped_ptr<SurfaceDrawQuad> surface_two_quad = SurfaceDrawQuad::Create();
66 gfx::Rect two_rect(child_size);
67 surface_two_quad->SetNew(
68 pass->shared_quad_state_list.back(), two_rect, two_rect, child_two);
69 pass->quad_list.push_back(surface_two_quad.PassAs<DrawQuad>());
70
71 CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size);
72 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create();
73 bool force_anti_aliasing_off = false;
74 color_quad->SetNew(pass->shared_quad_state_list.back(),
75 rect,
76 rect,
77 SK_ColorYELLOW,
78 force_anti_aliasing_off);
79 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>());
80
81 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData);
82 delegated_frame_data->render_pass_list.push_back(pass.Pass());
83
84 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
85 frame->delegated_frame_data = delegated_frame_data.Pass();
86
87 surface_->SubmitFrame(mojo::surfaces::SurfaceId::From(id_),
88 mojo::surfaces::Frame::From(*frame));
89 }
90
91 } // namespace examples
92 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/surfaces_app/embedder.h ('k') | mojo/examples/surfaces_app/surfaces_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698