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/flow/texture.h"
11 #include "flutter/fml/platform/android/jni_weak_ref.h"
12 #include "flutter/shell/platform/android/platform_view_android_jni_impl.h"
13 
14 namespace flutter {
15 
17  public:
19  int64_t id,
20  const fml::jni::JavaObjectWeakGlobalRef& surface_texture,
21  std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
22 
23  ~AndroidExternalTextureGL() override;
24 
25  void Paint(SkCanvas& canvas,
26  const SkRect& bounds,
27  bool freeze,
28  GrDirectContext* context,
29  SkFilterQuality filter_quality) override;
30 
31  void OnGrContextCreated() override;
32 
33  void OnGrContextDestroyed() override;
34 
35  void MarkNewFrameAvailable() override;
36 
37  void OnTextureUnregistered() override;
38 
39  private:
40  void Attach(jint textureName);
41 
42  void Update();
43 
44  void Detach();
45 
46  void UpdateTransform();
47 
48  enum class AttachmentState { uninitialized, attached, detached };
49 
50  std::shared_ptr<PlatformViewAndroidJNI> jni_facade_;
51 
52  fml::jni::JavaObjectWeakGlobalRef surface_texture_;
53 
54  AttachmentState state_ = AttachmentState::uninitialized;
55 
56  bool new_frame_ready_ = false;
57 
58  GLuint texture_name_ = 0;
59 
60  SkMatrix transform;
61 
63 };
64 
65 } // namespace flutter
66 
67 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_GL_H_
void Paint(SkCanvas &canvas, const SkRect &bounds, bool freeze, GrDirectContext *context, SkFilterQuality filter_quality) override
AndroidExternalTextureGL(int64_t id, const fml::jni::JavaObjectWeakGlobalRef &surface_texture, std::shared_ptr< PlatformViewAndroidJNI > jni_facade)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27