| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef GL_GLEXT_PROTOTYPES | 5 #ifndef GL_GLEXT_PROTOTYPES |
| 6 #define GL_GLEXT_PROTOTYPES | 6 #define GL_GLEXT_PROTOTYPES |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "examples/spinning_cube/gles2_client_impl.h" | 9 #include "examples/spinning_cube/gles2_client_impl.h" |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 size_ = size; | 70 size_ = size; |
| 71 cube_.set_size(size_.width, size_.height); | 71 cube_.set_size(size_.width, size_.height); |
| 72 if (size_.width == 0 || size_.height == 0 || !context_) | 72 if (size_.width == 0 || size_.height == 0 || !context_) |
| 73 return; | 73 return; |
| 74 MGLResizeSurface(size_.width, size_.height); | 74 MGLResizeSurface(size_.width, size_.height); |
| 75 WantToDraw(); | 75 WantToDraw(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { | 78 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { |
| 79 switch (event.action) { | 79 switch (event.action) { |
| 80 case mojo::EVENT_TYPE_POINTER_DOWN: | 80 case mojo::EventType::POINTER_DOWN: |
| 81 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) | 81 if (event.flags & mojo::EventFlags::RIGHT_MOUSE_BUTTON) |
| 82 break; | 82 break; |
| 83 capture_point_.x = event.pointer_data->x; | 83 capture_point_.x = event.pointer_data->x; |
| 84 capture_point_.y = event.pointer_data->y; | 84 capture_point_.y = event.pointer_data->y; |
| 85 last_drag_point_ = capture_point_; | 85 last_drag_point_ = capture_point_; |
| 86 drag_start_time_ = mojo::GetTimeTicksNow(); | 86 drag_start_time_ = mojo::GetTimeTicksNow(); |
| 87 cube_.SetFlingMultiplier(0.0f, 1.0f); | 87 cube_.SetFlingMultiplier(0.0f, 1.0f); |
| 88 break; | 88 break; |
| 89 case mojo::EVENT_TYPE_POINTER_MOVE: { | 89 case mojo::EventType::POINTER_MOVE: { |
| 90 if (!(event.flags & mojo::EVENT_FLAGS_LEFT_MOUSE_BUTTON) && | 90 if (!(event.flags & mojo::EventFlags::LEFT_MOUSE_BUTTON) && |
| 91 event.pointer_data->kind == mojo::POINTER_KIND_MOUSE) { | 91 event.pointer_data->kind == mojo::PointerKind::MOUSE) { |
| 92 break; | 92 break; |
| 93 } | 93 } |
| 94 mojo::PointF event_location; | 94 mojo::PointF event_location; |
| 95 event_location.x = event.pointer_data->x; | 95 event_location.x = event.pointer_data->x; |
| 96 event_location.y = event.pointer_data->y; | 96 event_location.y = event.pointer_data->y; |
| 97 int direction = GetEventDirection(event_location, | 97 int direction = GetEventDirection(event_location, |
| 98 capture_point_, | 98 capture_point_, |
| 99 last_drag_point_); | 99 last_drag_point_); |
| 100 cube_.UpdateForDragDistance( | 100 cube_.UpdateForDragDistance( |
| 101 direction * CalculateDragDistance(last_drag_point_, event_location)); | 101 direction * CalculateDragDistance(last_drag_point_, event_location)); |
| 102 WantToDraw(); | 102 WantToDraw(); |
| 103 | 103 |
| 104 last_drag_point_ = event_location; | 104 last_drag_point_ = event_location; |
| 105 break; | 105 break; |
| 106 } | 106 } |
| 107 case mojo::EVENT_TYPE_POINTER_UP: { | 107 case mojo::EventType::POINTER_UP: { |
| 108 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) { | 108 if (event.flags & mojo::EventFlags::RIGHT_MOUSE_BUTTON) { |
| 109 cube_.set_color(GetRandomColor(), GetRandomColor(), GetRandomColor()); | 109 cube_.set_color(GetRandomColor(), GetRandomColor(), GetRandomColor()); |
| 110 break; | 110 break; |
| 111 } | 111 } |
| 112 mojo::PointF event_location; | 112 mojo::PointF event_location; |
| 113 event_location.x = event.pointer_data->x; | 113 event_location.x = event.pointer_data->x; |
| 114 event_location.y = event.pointer_data->y; | 114 event_location.y = event.pointer_data->y; |
| 115 MojoTimeTicks offset = mojo::GetTimeTicksNow() - drag_start_time_; | 115 MojoTimeTicks offset = mojo::GetTimeTicksNow() - drag_start_time_; |
| 116 float delta = static_cast<float>(offset) / 1000000.f; | 116 float delta = static_cast<float>(offset) / 1000000.f; |
| 117 // Last drag point is the same as current point here; use initial capture | 117 // Last drag point is the same as current point here; use initial capture |
| 118 // point instead | 118 // point instead |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 float delta = static_cast<float>(offset) / 1000000.; | 174 float delta = static_cast<float>(offset) / 1000000.; |
| 175 last_time_ = now; | 175 last_time_ = now; |
| 176 cube_.UpdateForTimeDelta(delta); | 176 cube_.UpdateForTimeDelta(delta); |
| 177 cube_.Draw(); | 177 cube_.Draw(); |
| 178 | 178 |
| 179 MGLSwapBuffers(); | 179 MGLSwapBuffers(); |
| 180 WantToDraw(); | 180 WantToDraw(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace examples | 183 } // namespace examples |
| OLD | NEW |