OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |