flutter_flutter/shell/platform/android/android_external_texture_gl.h
Adlai Holler c57aff1800
Use the GrDirectContext factories instead of deprecated GrContext ones (#19962)
This is part of a larger effort to expose the difference between GrDirectContext,
which runs on the GPU thread and can directly perform operations like uploading
textures, and GrRecordingContext, which can only queue up work to be delivered
to the GrDirectContext later.
2020-07-28 13:32:09 -07:00

67 lines
1.7 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"
#include "flutter/shell/platform/android/platform_view_android_jni_impl.h"
namespace flutter {
class AndroidExternalTextureGL : public flutter::Texture {
public:
AndroidExternalTextureGL(
int64_t id,
const fml::jni::JavaObjectWeakGlobalRef& surface_texture,
std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
~AndroidExternalTextureGL() override;
void Paint(SkCanvas& canvas,
const SkRect& bounds,
bool freeze,
GrDirectContext* context,
SkFilterQuality filter_quality) 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 };
std::shared_ptr<PlatformViewAndroidJNI> jni_facade_;
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_