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

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

Issue 940293003: Add a Display and ContextProvider concept to mojom, use to recreate (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | « examples/surfaces_app/embedder.h ('k') | 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
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/embedder.h" 5 #include "examples/surfaces_app/embedder.h"
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/delegated_frame_data.h" 8 #include "cc/output/delegated_frame_data.h"
9 #include "cc/quads/render_pass.h" 9 #include "cc/quads/render_pass.h"
10 #include "cc/quads/solid_color_draw_quad.h" 10 #include "cc/quads/solid_color_draw_quad.h"
11 #include "cc/quads/surface_draw_quad.h" 11 #include "cc/quads/surface_draw_quad.h"
12 #include "examples/surfaces_app/surfaces_util.h" 12 #include "examples/surfaces_app/surfaces_util.h"
13 #include "mojo/converters/surfaces/surfaces_type_converters.h" 13 #include "mojo/converters/surfaces/surfaces_type_converters.h"
14 #include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h" 14 #include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h"
15 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
17 #include "ui/gfx/transform.h" 17 #include "ui/gfx/transform.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace examples { 20 namespace examples {
21 21
22 using cc::RenderPass; 22 using cc::RenderPass;
23 using cc::RenderPassId; 23 using cc::RenderPassId;
24 using cc::SurfaceDrawQuad; 24 using cc::SurfaceDrawQuad;
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 Embedder::Embedder(uint32_t local_id, Surface* surface) 30 Embedder::Embedder(Display* display)
31 : local_id_(local_id), surface_(surface) { 31 : display_(display), frame_pending_(false) {
32 } 32 }
33 33
34 Embedder::~Embedder() { 34 Embedder::~Embedder() {
35 } 35 }
36 36
37 void Embedder::ProduceFrame(cc::SurfaceId child_one, 37 void Embedder::ProduceFrame(cc::SurfaceId child_one,
38 cc::SurfaceId child_two, 38 cc::SurfaceId child_two,
39 const gfx::Size& child_size, 39 const gfx::Size& child_size,
40 const gfx::Size& size, 40 const gfx::Size& size,
41 int offset) { 41 int offset) {
42 DCHECK(!frame_pending_);
43
42 gfx::Rect rect(size); 44 gfx::Rect rect(size);
43 RenderPassId pass_id(1, 1); 45 RenderPassId pass_id(1, 1);
44 scoped_ptr<RenderPass> pass = RenderPass::Create(); 46 scoped_ptr<RenderPass> pass = RenderPass::Create();
45 pass->SetNew(pass_id, rect, rect, gfx::Transform()); 47 pass->SetNew(pass_id, rect, rect, gfx::Transform());
46 48
47 if (!child_one.is_null()) { 49 if (!child_one.is_null()) {
48 gfx::Transform one_transform; 50 gfx::Transform one_transform;
49 one_transform.Translate(10 + child_size.width() / 2, 51 one_transform.Translate(10 + child_size.width() / 2,
50 50 + child_size.height() / 2); 52 50 + child_size.height() / 2);
51 one_transform.Translate(0, offset); 53 one_transform.Translate(0, offset);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 rect, 85 rect,
84 SK_ColorYELLOW, 86 SK_ColorYELLOW,
85 force_anti_aliasing_off); 87 force_anti_aliasing_off);
86 88
87 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); 89 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData);
88 delegated_frame_data->render_pass_list.push_back(pass.Pass()); 90 delegated_frame_data->render_pass_list.push_back(pass.Pass());
89 91
90 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 92 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
91 frame->delegated_frame_data = delegated_frame_data.Pass(); 93 frame->delegated_frame_data = delegated_frame_data.Pass();
92 94
93 surface_->SubmitFrame(local_id_, mojo::Frame::From(*frame), mojo::Closure()); 95 frame_pending_ = true;
96 display_->SubmitFrame(mojo::Frame::From(*frame),
97 [this]() { frame_pending_ = false; });
94 } 98 }
95 99
96 } // namespace examples 100 } // namespace examples
97 } // namespace mojo 101 } // namespace mojo
OLDNEW
« no previous file with comments | « examples/surfaces_app/embedder.h ('k') | examples/surfaces_app/surfaces_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698