| 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 #include "mojo/examples/sample_app/gles2_client_impl.h" | 5 #include "mojo/examples/sample_app/gles2_client_impl.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
| 9 #include <math.h> | 9 #include <math.h> |
| 10 | 10 |
| 11 #include "mojo/public/gles2/gles2.h" | 11 #include "mojo/public/gles2/gles2.h" |
| 12 #include "ui/events/event_constants.h" | 12 #include "ui/events/event_constants.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 namespace examples { | 15 namespace examples { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 float CalculateDragDistance(const gfx::PointF& start, const Point& end) { | 18 float CalculateDragDistance(const gfx::PointF& start, const Point& end) { |
| 19 return hypot(start.x() - end.x(), start.y() - end.y()); | 19 return hypot(start.x() - end.x(), start.y() - end.y()); |
| 20 } | 20 } |
| 21 | 21 |
| 22 } | 22 } |
| 23 | 23 |
| 24 GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe) | 24 GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe) |
| 25 : service_(pipe.Pass()) { | 25 : service_(pipe.Pass(), this) { |
| 26 service_.SetPeer(this); | |
| 27 } | 26 } |
| 28 | 27 |
| 29 GLES2ClientImpl::~GLES2ClientImpl() { | 28 GLES2ClientImpl::~GLES2ClientImpl() { |
| 30 service_->Destroy(); | 29 service_->Destroy(); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void GLES2ClientImpl::HandleInputEvent(const Event& event) { | 32 void GLES2ClientImpl::HandleInputEvent(const Event& event) { |
| 34 switch (event.action()) { | 33 switch (event.action()) { |
| 35 case ui::ET_MOUSE_PRESSED: | 34 case ui::ET_MOUSE_PRESSED: |
| 36 case ui::ET_TOUCH_PRESSED: | 35 case ui::ET_TOUCH_PRESSED: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 91 } |
| 93 | 92 |
| 94 void GLES2ClientImpl::StartTimer() { | 93 void GLES2ClientImpl::StartTimer() { |
| 95 last_time_ = base::Time::Now(); | 94 last_time_ = base::Time::Now(); |
| 96 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(16), | 95 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(16), |
| 97 this, &GLES2ClientImpl::Draw); | 96 this, &GLES2ClientImpl::Draw); |
| 98 } | 97 } |
| 99 | 98 |
| 100 } // namespace examples | 99 } // namespace examples |
| 101 } // namespace mojo | 100 } // namespace mojo |
| OLD | NEW |