Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: mojo/examples/sample_app/gles2_client_impl.cc

Issue 428413002: Make async waiter explicit MojoGLES2CreateContext param (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "mojo/public/cpp/environment/environment.h"
13 #include "mojo/public/cpp/utility/run_loop.h" 14 #include "mojo/public/cpp/utility/run_loop.h"
14 15
15 namespace examples { 16 namespace examples {
16 namespace { 17 namespace {
17 18
18 float CalculateDragDistance(const mojo::Point& start, const mojo::Point& end) { 19 float CalculateDragDistance(const mojo::Point& start, const mojo::Point& end) {
19 return hypot(static_cast<float>(start.x - end.x), 20 return hypot(static_cast<float>(start.x - end.x),
20 static_cast<float>(start.y - end.y)); 21 static_cast<float>(start.y - end.y));
21 } 22 }
22 23
23 float GetRandomColor() { 24 float GetRandomColor() {
24 return static_cast<float>(rand()) / static_cast<float>(RAND_MAX); 25 return static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
25 } 26 }
26 27
27 } 28 }
28 29
29 GLES2ClientImpl::GLES2ClientImpl(mojo::CommandBufferPtr command_buffer) 30 GLES2ClientImpl::GLES2ClientImpl(mojo::CommandBufferPtr command_buffer)
30 : last_time_(mojo::GetTimeTicksNow()), waiting_to_draw_(false) { 31 : last_time_(mojo::GetTimeTicksNow()), waiting_to_draw_(false) {
31 context_ = MojoGLES2CreateContext( 32 context_ =
32 command_buffer.PassMessagePipe().release().value(), 33 MojoGLES2CreateContext(command_buffer.PassMessagePipe().release().value(),
33 &ContextLostThunk, 34 &ContextLostThunk,
34 this); 35 this,
36 mojo::Environment::GetDefaultAsyncWaiter());
35 MojoGLES2MakeCurrent(context_); 37 MojoGLES2MakeCurrent(context_);
36 } 38 }
37 39
38 GLES2ClientImpl::~GLES2ClientImpl() { 40 GLES2ClientImpl::~GLES2ClientImpl() {
39 MojoGLES2DestroyContext(context_); 41 MojoGLES2DestroyContext(context_);
40 } 42 }
41 43
42 void GLES2ClientImpl::SetSize(const mojo::Size& size) { 44 void GLES2ClientImpl::SetSize(const mojo::Size& size) {
43 size_ = size; 45 size_ = size;
44 if (size_.width == 0 || size_.height == 0) 46 if (size_.width == 0 || size_.height == 0)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 float delta = static_cast<float>(offset) / 1000000.; 127 float delta = static_cast<float>(offset) / 1000000.;
126 last_time_ = now; 128 last_time_ = now;
127 cube_.UpdateForTimeDelta(delta); 129 cube_.UpdateForTimeDelta(delta);
128 cube_.Draw(); 130 cube_.Draw();
129 131
130 MojoGLES2SwapBuffers(); 132 MojoGLES2SwapBuffers();
131 WantToDraw(); 133 WantToDraw();
132 } 134 }
133 135
134 } // namespace examples 136 } // namespace examples
OLDNEW
« no previous file with comments | « mojo/examples/pepper_container_app/pepper_container_app.cc ('k') | mojo/examples/sample_app/sample_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698