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

Side by Side Diff: mojo/examples/compositor_app/compositor_host.cc

Issue 640023004: cc: Make OutputSurface::SwapBuffers pure virtual (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@latinfo
Patch Set: rebase, comment, removed unused includes Created 6 years, 2 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 | « mojo/examples/compositor_app/compositor_host.h ('k') | mojo/mojo.gyp » ('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 2013 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/compositor_app/compositor_host.h"
6
7 #include "cc/layers/layer.h"
8 #include "cc/layers/solid_color_layer.h"
9 #include "cc/output/begin_frame_args.h"
10 #include "cc/output/context_provider.h"
11 #include "cc/output/output_surface.h"
12 #include "cc/trees/layer_tree_host.h"
13 #include "mojo/cc/context_provider_mojo.h"
14
15 namespace mojo {
16 namespace examples {
17
18 CompositorHost::CompositorHost(ScopedMessagePipeHandle command_buffer_handle)
19 : command_buffer_handle_(command_buffer_handle.Pass()),
20 compositor_thread_("compositor") {
21 DCHECK(command_buffer_handle_.is_valid());
22 bool started = compositor_thread_.Start();
23 DCHECK(started);
24
25 cc::LayerTreeSettings settings;
26 tree_ = cc::LayerTreeHost::CreateThreaded(
27 this,
28 NULL,
29 settings,
30 base::MessageLoopProxy::current(),
31 compositor_thread_.message_loop_proxy());
32 SetupScene();
33 }
34
35 CompositorHost::~CompositorHost() {}
36
37 void CompositorHost::SetSize(const gfx::Size& viewport_size) {
38 tree_->SetViewportSize(viewport_size);
39 tree_->SetLayerTreeHostClientReady();
40 }
41
42 void CompositorHost::SetupScene() {
43 scoped_refptr<cc::Layer> root_layer = cc::SolidColorLayer::Create();
44 root_layer->SetBounds(gfx::Size(500, 500));
45 root_layer->SetBackgroundColor(SK_ColorBLUE);
46 root_layer->SetIsDrawable(true);
47 tree_->SetRootLayer(root_layer);
48
49 child_layer_ = cc::SolidColorLayer::Create();
50 child_layer_->SetBounds(gfx::Size(100, 100));
51 child_layer_->SetBackgroundColor(SK_ColorGREEN);
52 child_layer_->SetIsDrawable(true);
53 gfx::Transform child_transform;
54 child_transform.Translate(200, 200);
55 child_layer_->SetTransform(child_transform);
56 root_layer->AddChild(child_layer_);
57 }
58
59 void CompositorHost::WillBeginMainFrame(int frame_id) {}
60 void CompositorHost::DidBeginMainFrame() {}
61
62 void CompositorHost::BeginMainFrame(const cc::BeginFrameArgs& args) {
63 // TODO(jamesr): Should use cc's animation system.
64 static const double kDegreesPerSecond = 70.0;
65 double time_in_seconds = (args.frame_time - base::TimeTicks()).InSecondsF();
66 double child_rotation_degrees = kDegreesPerSecond * time_in_seconds;
67 gfx::Transform child_transform;
68 child_transform.Translate(200, 200);
69 child_transform.Rotate(child_rotation_degrees);
70 child_layer_->SetTransform(child_transform);
71 tree_->SetNeedsAnimate();
72 }
73
74 void CompositorHost::Layout() {}
75 void CompositorHost::ApplyViewportDeltas(const gfx::Vector2d& inner_delta,
76 const gfx::Vector2d& outer_delta,
77 float page_scale,
78 float top_controls_delta) {}
79 void CompositorHost::ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
80 float page_scale,
81 float top_controls_delta) {}
82
83 void CompositorHost::RequestNewOutputSurface(bool fallback) {
84 tree_->SetOutputSurface(make_scoped_ptr(new cc::OutputSurface(
85 new ContextProviderMojo(command_buffer_handle_.Pass()))));
86 }
87
88 void CompositorHost::DidInitializeOutputSurface() {
89 }
90
91 void CompositorHost::WillCommit() {}
92 void CompositorHost::DidCommit() {}
93 void CompositorHost::DidCommitAndDrawFrame() {}
94 void CompositorHost::DidCompleteSwapBuffers() {}
95
96 } // namespace examples
97 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/compositor_app/compositor_host.h ('k') | mojo/mojo.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698