mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
0d59c9ec54
Texture unregistration is finished on the GPU thread. The FlutterTexture implementation might not know when it is finished which leads to a race condition. Adding this callback so the FlutterTexture is aware of end of the unregistration process.
62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
// Copyright 2013 The Flutter 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_EXTERNAL_TEXTURE_GL_H_
|
|
#define FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_GL_H_
|
|
|
|
#include <GLES/gl.h>
|
|
#include "flutter/flow/texture.h"
|
|
#include "flutter/fml/platform/android/jni_weak_ref.h"
|
|
|
|
namespace flutter {
|
|
|
|
class AndroidExternalTextureGL : public flutter::Texture {
|
|
public:
|
|
AndroidExternalTextureGL(
|
|
int64_t id,
|
|
const fml::jni::JavaObjectWeakGlobalRef& surfaceTexture);
|
|
|
|
~AndroidExternalTextureGL() override;
|
|
|
|
void Paint(SkCanvas& canvas,
|
|
const SkRect& bounds,
|
|
bool freeze,
|
|
GrContext* context) override;
|
|
|
|
void OnGrContextCreated() override;
|
|
|
|
void OnGrContextDestroyed() override;
|
|
|
|
void MarkNewFrameAvailable() override;
|
|
|
|
void OnTextureUnregistered() override;
|
|
|
|
private:
|
|
void Attach(jint textureName);
|
|
|
|
void Update();
|
|
|
|
void Detach();
|
|
|
|
void UpdateTransform();
|
|
|
|
enum class AttachmentState { uninitialized, attached, detached };
|
|
|
|
fml::jni::JavaObjectWeakGlobalRef surface_texture_;
|
|
|
|
AttachmentState state_ = AttachmentState::uninitialized;
|
|
|
|
bool new_frame_ready_ = false;
|
|
|
|
GLuint texture_name_ = 0;
|
|
|
|
SkMatrix transform;
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(AndroidExternalTextureGL);
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_EXTERNAL_TEXTURE_GL_H_
|