| 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 // Axis of motion is determined by coarse alignment of overall movement | 47 // Axis of motion is determined by coarse alignment of overall movement |
| 48 bool use_x = | 48 bool use_x = |
| 49 std::abs(current.y - initial.y) < std::abs(current.x - initial.x); | 49 std::abs(current.y - initial.y) < std::abs(current.x - initial.x); |
| 50 // Current direction is determined by comparison with previous point | 50 // Current direction is determined by comparison with previous point |
| 51 float delta = use_x ? (current.x - last.x) : (current.y - last.y); | 51 float delta = use_x ? (current.x - last.x) : (current.y - last.y); |
| 52 return delta > 0 ? -1 : 1; | 52 return delta > 0 ? -1 : 1; |
| 53 } | 53 } |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 SpinningCubeView::SpinningCubeView( | 56 SpinningCubeView::SpinningCubeView( |
| 57 mojo::ApplicationImpl* app_impl, | 57 mojo::InterfaceHandle<mojo::ApplicationConnector> app_connector, |
| 58 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) | 58 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) |
| 59 : GLView(app_impl, view_owner_request.Pass(), "SpinningCube"), | 59 : GLView(app_connector.Pass(), view_owner_request.Pass(), "SpinningCube"), |
| 60 choreographer_(scene(), this), | 60 choreographer_(scene(), this), |
| 61 input_handler_(GetViewServiceProvider(), this), | 61 input_handler_(GetViewServiceProvider(), this), |
| 62 weak_ptr_factory_(this) { | 62 weak_ptr_factory_(this) { |
| 63 mojo::GLContext::Scope gl_scope(gl_context()); | 63 mojo::GLContext::Scope gl_scope(gl_context()); |
| 64 cube_.Init(); | 64 cube_.Init(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 SpinningCubeView::~SpinningCubeView() {} | 67 SpinningCubeView::~SpinningCubeView() {} |
| 68 | 68 |
| 69 void SpinningCubeView::OnPropertiesChanged( | 69 void SpinningCubeView::OnPropertiesChanged( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 choreographer_.ScheduleDraw(); | 185 choreographer_.ScheduleDraw(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void SpinningCubeView::DrawCubeWithGL(const mojo::GLContext::Scope& gl_scope, | 188 void SpinningCubeView::DrawCubeWithGL(const mojo::GLContext::Scope& gl_scope, |
| 189 const mojo::Size& size) { | 189 const mojo::Size& size) { |
| 190 cube_.set_size(size.width, size.height); | 190 cube_.set_size(size.width, size.height); |
| 191 cube_.Draw(); | 191 cube_.Draw(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace examples | 194 } // namespace examples |
| OLD | NEW |