platform_view_android.h 1.4 KB
Newer Older
1 2 3 4
// Copyright 2015 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.

5 6
#ifndef SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_
#define SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_
7

8
#include "base/synchronization/waitable_event.h"
9 10 11 12 13 14
#include "sky/shell/platform_view.h"

struct ANativeWindow;

namespace sky {
namespace shell {
15
class ShellView;
16 17 18 19

class PlatformViewAndroid : public PlatformView {
 public:
  static bool Register(JNIEnv* env);
20 21

  PlatformViewAndroid(const Config& config);
22 23 24 25 26 27 28
  ~PlatformViewAndroid() override;

  // Called from Java
  void Detach(JNIEnv* env, jobject obj);
  void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface);
  void SurfaceDestroyed(JNIEnv* env, jobject obj);

29
  void SetShellView(std::unique_ptr<ShellView> shell_view);
30

31 32 33
 private:
  void ReleaseWindow();

34 35 36 37
  // In principle, the ShellView should own the PlatformView, but because our
  // lifetime is controlled by the Android view hierarchy, we flip around the
  // ownership and have the shell_view owned by Java. We reset this pointer in
  // |Detach|, which will eventually cause |~PlatformViewAndroid|.
38
  std::unique_ptr<ShellView> shell_view_;
A
Adam Barth 已提交
39
  gfx::AcceleratedWidget window_;
40
  base::WaitableEvent did_draw_;
41

42 43 44 45 46 47
  DISALLOW_COPY_AND_ASSIGN(PlatformViewAndroid);
};

}  // namespace shell
}  // namespace sky

48
#endif  // SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_