summaryrefslogtreecommitdiffstats
path: root/mojo/examples/sample_app/native_viewport_client_impl.cc
blob: 387a64eb79076c4ba0d5865c984c249c2e1bf75b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/examples/sample_app/native_viewport_client_impl.h"

#include <stdio.h>

#include "base/logging.h"

namespace mojo {
namespace examples {

NativeViewportClientImpl::NativeViewportClientImpl(ScopedMessagePipeHandle pipe)
    : service_(pipe.Pass()) {
  service_.SetPeer(this);
}

NativeViewportClientImpl::~NativeViewportClientImpl() {
  service_->Close();
}

void NativeViewportClientImpl::Open() {
  service_->Open();

  ScopedMessagePipeHandle gles2;
  ScopedMessagePipeHandle gles2_client;
  CreateMessagePipe(&gles2, &gles2_client);

  gles2_client_.reset(new GLES2ClientImpl(gles2.Pass()));
  service_->CreateGLES2Context(gles2_client.Pass());
}

void NativeViewportClientImpl::DidOpen() {
}

void NativeViewportClientImpl::HandleEvent(const Event& event) {
  if (!event.location().is_null()) {
    LOG(INFO) << "Located Event @"
              << event.location().x() << "," << event.location().y();
  }
}

}  // namespace examples
}  // namespace mojo