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

Side by Side Diff: mojo/services/native_viewport/native_viewport_impl.cc

Issue 100823010: Wire events through to sample_app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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
« no previous file with comments | « mojo/services/native_viewport/native_viewport_impl.h ('k') | no next file » | 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/services/native_viewport/native_viewport_impl.h" 5 #include "mojo/services/native_viewport/native_viewport_impl.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/services/gles2/gles2_impl.h" 8 #include "mojo/services/gles2/gles2_impl.h"
9 #include "mojo/services/native_viewport/native_viewport.h" 9 #include "mojo/services/native_viewport/native_viewport.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 29 matching lines...) Expand all
40 gles2_.reset(new GLES2Impl(gles2_client.Pass())); 40 gles2_.reset(new GLES2Impl(gles2_client.Pass()));
41 CreateGLES2ContextIfNeeded(); 41 CreateGLES2ContextIfNeeded();
42 } 42 }
43 43
44 void NativeViewportImpl::CreateGLES2ContextIfNeeded() { 44 void NativeViewportImpl::CreateGLES2ContextIfNeeded() {
45 if (widget_ == gfx::kNullAcceleratedWidget || !gles2_) 45 if (widget_ == gfx::kNullAcceleratedWidget || !gles2_)
46 return; 46 return;
47 gles2_->CreateContext(widget_, native_viewport_->GetSize()); 47 gles2_->CreateContext(widget_, native_viewport_->GetSize());
48 } 48 }
49 49
50 bool NativeViewportImpl::OnEvent(ui::Event* event) { 50 bool NativeViewportImpl::OnEvent(ui::Event* ui_event) {
51 AllocationScope scope;
52
53 Event::Builder event;
54 event.set_action(ui_event->type());
55 event.set_time_stamp(ui_event->time_stamp().ToInternalValue());
56
57 if (ui_event->IsMouseEvent() || ui_event->IsTouchEvent()) {
58 ui::LocatedEvent* located_event = static_cast<ui::LocatedEvent*>(ui_event);
59 Point::Builder location;
60 location.set_x(located_event->location().x());
61 location.set_y(located_event->location().y());
62 event.set_location(location.Finish());
63 }
64
65 if (ui_event->IsTouchEvent()) {
66 ui::TouchEvent* touch_event = static_cast<ui::TouchEvent*>(ui_event);
67 TouchData::Builder touch_data;
68 touch_data.set_pointer_id(touch_event->touch_id());
69 event.set_touch_data(touch_data.Finish());
70 }
71
72 client_->HandleEvent(event.Finish());
51 return false; 73 return false;
52 } 74 }
53 75
54 void NativeViewportImpl::OnAcceleratedWidgetAvailable( 76 void NativeViewportImpl::OnAcceleratedWidgetAvailable(
55 gfx::AcceleratedWidget widget) { 77 gfx::AcceleratedWidget widget) {
56 widget_ = widget; 78 widget_ = widget;
57 CreateGLES2ContextIfNeeded(); 79 CreateGLES2ContextIfNeeded();
58 } 80 }
59 81
60 void NativeViewportImpl::OnResized(const gfx::Size& size) { 82 void NativeViewportImpl::OnResized(const gfx::Size& size) {
61 } 83 }
62 84
63 void NativeViewportImpl::OnDestroyed() { 85 void NativeViewportImpl::OnDestroyed() {
64 base::MessageLoop::current()->Quit(); 86 base::MessageLoop::current()->Quit();
65 } 87 }
66 88
67 } // namespace services 89 } // namespace services
68 } // namespace mojo 90 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/native_viewport/native_viewport_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698