Flutter Engine
android_external_texture_gl.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 #ifndef FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_GL_H_
6 #define FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_GL_H_
7 
8 #include <GLES/gl.h>
9 
10 #include "flutter/common/graphics/texture.h"
11 #include "flutter/shell/platform/android/platform_view_android_jni_impl.h"
12 
13 namespace flutter {
14 
16  public:
18  int64_t id,
19  const fml::jni::ScopedJavaGlobalRef<jobject>& surface_texture,
20  std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
21 
22  ~AndroidExternalTextureGL() override;
23 
24  void Paint(SkCanvas& canvas,
25  const SkRect& bounds,
26  bool freeze,
27  GrDirectContext* context,
28  const SkSamplingOptions& sampling) override;
29 
30  void OnGrContextCreated() override;
31 
32  void OnGrContextDestroyed() override;
33 
34  void MarkNewFrameAvailable() override;
35 
36  void OnTextureUnregistered() override;
37 
38  private:
39  void Attach(jint textureName);
40 
41  void Update();
42 
43  void Detach();
44 
45  void UpdateTransform();
46 
47  enum class AttachmentState { uninitialized, attached, detached };
48 
49  std::shared_ptr<PlatformViewAndroidJNI> jni_facade_;
50 
52 
53  AttachmentState state_ = AttachmentState::uninitialized;
54 
55  bool new_frame_ready_ = false;
56 
57  GLuint texture_name_ = 0;
58 
59  SkMatrix transform;
60 
62 };
63 
64 } // namespace flutter
65 
66 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_GL_H_
void Paint(SkCanvas &canvas, const SkRect &bounds, bool freeze, GrDirectContext *context, const SkSamplingOptions &sampling) override
AndroidExternalTextureGL(int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture, std::shared_ptr< PlatformViewAndroidJNI > jni_facade)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27