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

Side by Side Diff: examples/ui/spinning_cube/spinning_cube_view.cc

Issue 1679023006: Reify view ownership as a message pipe. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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/ui/spinning_cube/spinning_cube_view.h ('k') | examples/ui/tile/tile_app.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/spinning_cube/spinning_cube_view.h" 5 #include "examples/ui/spinning_cube/spinning_cube_view.h"
6 6
7 #ifndef GL_GLEXT_PROTOTYPES 7 #ifndef GL_GLEXT_PROTOTYPES
8 #define GL_GLEXT_PROTOTYPES 8 #define GL_GLEXT_PROTOTYPES
9 #endif 9 #endif
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 bool use_x = 47 bool use_x =
48 std::abs(current.y - initial.y) < std::abs(current.x - initial.x); 48 std::abs(current.y - initial.y) < std::abs(current.x - initial.x);
49 // Current direction is determined by comparison with previous point 49 // Current direction is determined by comparison with previous point
50 float delta = use_x ? (current.x - last.x) : (current.y - last.y); 50 float delta = use_x ? (current.x - last.x) : (current.y - last.y);
51 return delta > 0 ? -1 : 1; 51 return delta > 0 ? -1 : 1;
52 } 52 }
53 } // namespace 53 } // namespace
54 54
55 SpinningCubeView::SpinningCubeView( 55 SpinningCubeView::SpinningCubeView(
56 mojo::ApplicationImpl* app_impl, 56 mojo::ApplicationImpl* app_impl,
57 const mojo::ui::ViewProvider::CreateViewCallback& create_view_callback) 57 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request)
58 : GLView(app_impl, "SpinningCube", create_view_callback), 58 : GLView(app_impl, view_owner_request.Pass(), "SpinningCube"),
59 choreographer_(scene(), this), 59 choreographer_(scene(), this),
60 input_handler_(view_service_provider(), this), 60 input_handler_(view_service_provider(), this),
61 weak_ptr_factory_(this) { 61 weak_ptr_factory_(this) {
62 gl_renderer()->gl_context()->MakeCurrent(); 62 gl_renderer()->gl_context()->MakeCurrent();
63 cube_.Init(); 63 cube_.Init();
64 } 64 }
65 65
66 SpinningCubeView::~SpinningCubeView() {} 66 SpinningCubeView::~SpinningCubeView() {}
67 67
68 void SpinningCubeView::OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params, 68 void SpinningCubeView::OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Loop! 183 // Loop!
184 choreographer_.ScheduleDraw(); 184 choreographer_.ScheduleDraw();
185 } 185 }
186 186
187 void SpinningCubeView::DrawCubeWithGL() { 187 void SpinningCubeView::DrawCubeWithGL() {
188 cube_.set_size(size_.width, size_.height); 188 cube_.set_size(size_.width, size_.height);
189 cube_.Draw(); 189 cube_.Draw();
190 } 190 }
191 191
192 } // namespace examples 192 } // namespace examples
OLDNEW
« no previous file with comments | « examples/ui/spinning_cube/spinning_cube_view.h ('k') | examples/ui/tile/tile_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698