android_surface_gl.h 1.9 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2016 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 FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
#define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_

8
#include <jni.h>
9
#include <memory>
10

11
#include "flutter/fml/macros.h"
12 13 14
#include "flutter/shell/gpu/gpu_surface_gl.h"
#include "flutter/shell/platform/android/android_context_gl.h"
#include "flutter/shell/platform/android/android_environment_gl.h"
15
#include "flutter/shell/platform/android/android_surface.h"
16 17 18

namespace shell {

19 20
class AndroidSurfaceGL final : public GPUSurfaceGLDelegate,
                               public AndroidSurface {
21
 public:
22
  AndroidSurfaceGL();
23

24
  ~AndroidSurfaceGL() override;
25

26 27
  bool IsOffscreenContextValid() const;

28 29 30 31
  // |shell::AndroidSurface|
  bool IsValid() const override;

  // |shell::AndroidSurface|
32 33
  std::unique_ptr<Surface> CreateGPUSurface() override;

34
  // |shell::AndroidSurface|
35 36
  void TeardownOnScreenContext() override;

37
  // |shell::AndroidSurface|
38
  bool OnScreenSurfaceResize(const SkISize& size) const override;
39

40
  // |shell::AndroidSurface|
41
  bool ResourceContextMakeCurrent() override;
42

43
  // |shell::AndroidSurface|
44
  bool SetNativeWindow(fml::RefPtr<AndroidNativeWindow> window) override;
45

46
  // |shell::GPUSurfaceGLDelegate|
47 48
  bool GLContextMakeCurrent() override;

49
  // |shell::GPUSurfaceGLDelegate|
50 51
  bool GLContextClearCurrent() override;

52
  // |shell::GPUSurfaceGLDelegate|
53 54
  bool GLContextPresent() override;

55
  // |shell::GPUSurfaceGLDelegate|
56 57 58
  intptr_t GLContextFBO() const override;

 private:
59 60
  fml::RefPtr<AndroidContextGL> onscreen_context_;
  fml::RefPtr<AndroidContextGL> offscreen_context_;
61
  sk_sp<GrContext> gr_context_;
62

63
  FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceGL);
64 65 66 67 68
};

}  // namespace shell

#endif  // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_