7#include <android/hardware_buffer_jni.h>
8#include <android/sensor.h>
16#include "third_party/skia/include/core/SkAlphaType.h"
17#include "third_party/skia/include/core/SkColorType.h"
18#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
19#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
20#include "third_party/skia/include/gpu/ganesh/gl/GrGLTypes.h"
27 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade,
48 std::optional<HardwareBufferKey>
key =
50 latest_hardware_buffer);
52 if (existing_image !=
nullptr) {
58 if (!egl_image.is_valid()) {
63 if (
key.has_value()) {
69 const SkRect& bounds) {
71 if (
image.is_null()) {
75 if (hardware_buffer.is_null()) {
88 AHardwareBuffer* hardware_buffer) {
89 if (hardware_buffer ==
nullptr) {
93 EGLDisplay display = eglGetCurrentDisplay();
94 if (display == EGL_NO_DISPLAY) {
100 EGLClientBuffer client_buffer =
104 if (client_buffer ==
nullptr) {
105 FML_LOG(ERROR) <<
"eglGetNativeClientBufferAndroid returned null.";
111 eglCreateImageKHR(display, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
void ProcessFrame(PaintContext &context, const SkRect &bounds) override
Subclasses override this method to bind the latest representation of the hardware buffer wrapped by t...
void UpdateImage(JavaLocalRef &hardware_buffer, const SkRect &bounds, PaintContext &context)
ImageExternalTextureGL(int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &image_textury_entry, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade, ImageExternalTexture::ImageLifecycle lifecycle)
virtual sk_sp< flutter::DlImage > CreateDlImage(PaintContext &context, const SkRect &bounds, std::optional< HardwareBufferKey > id, impeller::UniqueEGLImageKHR &&egl_image)=0
impeller::UniqueEGLImageKHR CreateEGLImage(AHardwareBuffer *buffer)
std::unordered_map< HardwareBufferKey, GlEntry > gl_entries_
void Attach(PaintContext &context) override
External texture peered to a sequence of android.hardware.HardwareBuffers.
AHardwareBuffer * AHardwareBufferFor(const fml::jni::JavaRef< jobject > &hardware_buffer)
JavaLocalRef HardwareBufferFor(const fml::jni::JavaRef< jobject > &image)
void CloseHardwareBuffer(const fml::jni::JavaRef< jobject > &hardware_buffer)
sk_sp< flutter::DlImage > dl_image_
JavaLocalRef AcquireLatestImage()
ImageLifecycle
Whether the last image should be reset when the context is destroyed.
HardwareBufferKey AddImage(const sk_sp< flutter::DlImage > &image, HardwareBufferKey key)
Add a new image to the cache with a key, returning the key of the LRU entry that was removed.
sk_sp< flutter::DlImage > FindImage(std::optional< HardwareBufferKey > key)
Retrieve the image associated with the given [key], or nullptr.
void Clear()
Remove all entires from the image cache.
std::optional< uint64_t > GetSystemUniqueID() const
Get the system wide unique ID of the hardware buffer if possible. This is only available on Android A...
FlutterVulkanImage * image
#define FML_LOG(severity)
#define FML_DCHECK(condition)
std::nullptr_t JavaLocalRef
const ProcTable & GetProcTable()
fml::UniqueObject< EGLImageKHRWithDisplay, EGLImageKHRWithDisplayTraits > UniqueEGLImageKHR
std::shared_ptr< ContextGLES > context