summaryrefslogtreecommitdiffstats
path: root/mojo/services/native_viewport/native_viewport_android.h
blob: ba77f83c4891446fcb523221c41d1cc4db6192f0 (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
46
47
48
49
50
51
52
53
54
// 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.

#ifndef MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_
#define MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_

#include "base/memory/weak_ptr.h"
#include "mojo/services/native_viewport/native_viewport.h"
#include "ui/gfx/size.h"

namespace gpu {
class GLInProcessContext;
}

struct ANativeWindow;

namespace mojo {
namespace services {

class NativeViewportAndroid : public NativeViewport {
 public:
  explicit NativeViewportAndroid(NativeViewportDelegate* delegate);
  virtual ~NativeViewportAndroid();

  base::WeakPtr<NativeViewportAndroid> GetWeakPtr() {
    return weak_factory_.GetWeakPtr();
  }

  void OnNativeWindowCreated(ANativeWindow* window);
  void OnNativeWindowDestroyed();
  void OnResized(const gfx::Size& size);

 private:
  // Overridden from NativeViewport:
  virtual gfx::Size GetSize() OVERRIDE;
  virtual void Close() OVERRIDE;

  void ReleaseWindow();

  NativeViewportDelegate* delegate_;
  ANativeWindow* window_;
  gfx::Size size_;

  base::WeakPtrFactory<NativeViewportAndroid> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(NativeViewportAndroid);
};


}  // namespace services
}  // namespace mojo

#endif  // MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_