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

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

Issue 536153002: mojo: Fix window resizing in mojo_sample_app and mojo_demo_launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « mojo/examples/sample_app/DEPS ('k') | mojo/services/view_manager/display_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "gpu/command_buffer/client/gles2_interface.h"
12 #include "mojo/public/c/gles2/gles2.h" 13 #include "mojo/public/c/gles2/gles2.h"
13 #include "mojo/public/cpp/environment/environment.h" 14 #include "mojo/public/cpp/environment/environment.h"
14 #include "mojo/public/cpp/utility/run_loop.h" 15 #include "mojo/public/cpp/utility/run_loop.h"
15 16
16 namespace examples { 17 namespace examples {
17 namespace { 18 namespace {
18 19
19 float CalculateDragDistance(const mojo::Point& start, const mojo::Point& end) { 20 float CalculateDragDistance(const mojo::Point& start, const mojo::Point& end) {
20 return hypot(static_cast<float>(start.x - end.x), 21 return hypot(static_cast<float>(start.x - end.x),
21 static_cast<float>(start.y - end.y)); 22 static_cast<float>(start.y - end.y));
(...skipping 16 matching lines...) Expand all
38 } 39 }
39 40
40 GLES2ClientImpl::~GLES2ClientImpl() { 41 GLES2ClientImpl::~GLES2ClientImpl() {
41 MojoGLES2DestroyContext(context_); 42 MojoGLES2DestroyContext(context_);
42 } 43 }
43 44
44 void GLES2ClientImpl::SetSize(const mojo::Size& size) { 45 void GLES2ClientImpl::SetSize(const mojo::Size& size) {
45 size_ = size; 46 size_ = size;
46 if (size_.width == 0 || size_.height == 0) 47 if (size_.width == 0 || size_.height == 0)
47 return; 48 return;
49 static_cast<gpu::gles2::GLES2Interface*>(
50 MojoGLES2GetGLES2Interface(context_))->ResizeCHROMIUM(size_.width,
51 size_.height,
52 1);
48 cube_.Init(size_.width, size_.height); 53 cube_.Init(size_.width, size_.height);
49 WantToDraw(); 54 WantToDraw();
50 } 55 }
51 56
52 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { 57 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) {
53 switch (event.action) { 58 switch (event.action) {
54 case mojo::EVENT_TYPE_MOUSE_PRESSED: 59 case mojo::EVENT_TYPE_MOUSE_PRESSED:
55 case mojo::EVENT_TYPE_TOUCH_PRESSED: 60 case mojo::EVENT_TYPE_TOUCH_PRESSED:
56 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) 61 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON)
57 break; 62 break;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 float delta = static_cast<float>(offset) / 1000000.; 131 float delta = static_cast<float>(offset) / 1000000.;
127 last_time_ = now; 132 last_time_ = now;
128 cube_.UpdateForTimeDelta(delta); 133 cube_.UpdateForTimeDelta(delta);
129 cube_.Draw(); 134 cube_.Draw();
130 135
131 MojoGLES2SwapBuffers(); 136 MojoGLES2SwapBuffers();
132 WantToDraw(); 137 WantToDraw();
133 } 138 }
134 139
135 } // namespace examples 140 } // namespace examples
OLDNEW
« no previous file with comments | « mojo/examples/sample_app/DEPS ('k') | mojo/services/view_manager/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698