OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "mojo/examples/sample_app/native_viewport_client_impl.h" | |
6 | |
7 #include <stdio.h> | |
8 | |
9 #include "base/logging.h" | |
10 #include "base/message_loop/message_loop.h" | |
11 | |
12 namespace mojo { | |
13 namespace examples { | |
14 | |
15 NativeViewportClientImpl::NativeViewportClientImpl(ScopedMessagePipeHandle pipe) | |
16 : service_(pipe.Pass()) { | |
17 service_.SetPeer(this); | |
18 } | |
19 | |
20 NativeViewportClientImpl::~NativeViewportClientImpl() { | |
21 service_->Close(); | |
22 } | |
23 | |
24 void NativeViewportClientImpl::Open() { | |
25 service_->Open(); | |
26 | |
27 ScopedMessagePipeHandle gles2; | |
28 ScopedMessagePipeHandle gles2_client; | |
29 CreateMessagePipe(&gles2, &gles2_client); | |
30 | |
31 gles2_client_.reset(new GLES2ClientImpl(gles2.Pass())); | |
32 service_->CreateGLES2Context(gles2_client.Pass()); | |
33 } | |
34 | |
35 void NativeViewportClientImpl::OnCreated() { | |
36 } | |
37 | |
38 void NativeViewportClientImpl::OnDestroyed() { | |
39 base::MessageLoop::current()->Quit(); | |
40 } | |
41 | |
42 void NativeViewportClientImpl::OnEvent(const Event& event) { | |
43 if (!event.location().is_null()) { | |
44 gles2_client_->HandleInputEvent(event); | |
45 service_->AckEvent(event); | |
46 } | |
47 } | |
48 | |
49 } // namespace examples | |
50 } // namespace mojo | |
OLD | NEW |