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 #include <stdlib.h> | 10 #include <stdlib.h> |
11 | 11 |
12 #include "mojo/public/c/gles2/gles2.h" | 12 #include "mojo/public/c/gles2/gles2.h" |
13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace examples { | 16 namespace examples { |
17 namespace { | 17 namespace { |
18 | 18 |
19 float CalculateDragDistance(const gfx::PointF& start, const Point& end) { | 19 float CalculateDragDistance(const gfx::PointF& start, const Point& end) { |
20 return hypot(start.x() - end.x, start.y() - end.y); | 20 return hypot(start.x() - end.x, start.y() - end.y); |
21 } | 21 } |
22 | 22 |
23 float GetRandomColor() { | 23 float GetRandomColor() { |
24 return static_cast<float>(rand()) / static_cast<float>(RAND_MAX); | 24 return static_cast<float>(rand()) / static_cast<float>(RAND_MAX); |
25 } | 25 } |
26 | 26 |
27 } | 27 } |
28 | 28 |
29 GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe) | 29 GLES2ClientImpl::GLES2ClientImpl(CommandBufferPtr command_buffer) |
30 : getting_animation_frames_(false) { | 30 : getting_animation_frames_(false) { |
31 context_ = MojoGLES2CreateContext( | 31 context_ = MojoGLES2CreateContext( |
32 pipe.release().value(), | 32 command_buffer.PassMessagePipe().release().value(), |
33 &ContextLostThunk, | 33 &ContextLostThunk, |
34 &DrawAnimationFrameThunk, | 34 &DrawAnimationFrameThunk, |
35 this); | 35 this); |
36 MojoGLES2MakeCurrent(context_); | 36 MojoGLES2MakeCurrent(context_); |
37 } | 37 } |
38 | 38 |
39 GLES2ClientImpl::~GLES2ClientImpl() { | 39 GLES2ClientImpl::~GLES2ClientImpl() { |
40 MojoGLES2DestroyContext(context_); | 40 MojoGLES2DestroyContext(context_); |
41 } | 41 } |
42 | 42 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 last_time_ = GetTimeTicksNow(); | 119 last_time_ = GetTimeTicksNow(); |
120 } | 120 } |
121 | 121 |
122 void GLES2ClientImpl::CancelAnimationFrames() { | 122 void GLES2ClientImpl::CancelAnimationFrames() { |
123 getting_animation_frames_ = false; | 123 getting_animation_frames_ = false; |
124 MojoGLES2CancelAnimationFrames(context_); | 124 MojoGLES2CancelAnimationFrames(context_); |
125 } | 125 } |
126 | 126 |
127 } // namespace examples | 127 } // namespace examples |
128 } // namespace mojo | 128 } // namespace mojo |
OLD | NEW |