Skip to content

Commit 5dd660c

Browse files
Reland Introduce TextureRegistry.ImageTexture and HardwareBufferExternalTextureGL (flutter#44278)
Introduce TextureRegistry.ImageTexture and HardwareBufferExternalTextureGL - Introduce TextureRegistry.ImageTexture and related machinery. - Introduce HardwareBufferExternalTextureGL and related machinery. - Introduce ImageReaderPlatformViewRenderTarget. NOTE: ImageReaderPlatformViewRenderTarget requires Android 26. NOTE: This CL does not enable using ImageReaderPlatformViewRenderTarget yet. Additional fixes: - Relax JNI lookup for classes and methods that aren't available in API 22 - Add @keep annotations on code that is only referenced by JNI
1 parent 152a9e5 commit 5dd660c

36 files changed

+1158
-51
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,8 +1686,11 @@ ORIGIN: ../../../flutter/impeller/toolkit/egl/display.cc + ../../../flutter/LICE
16861686
ORIGIN: ../../../flutter/impeller/toolkit/egl/display.h + ../../../flutter/LICENSE
16871687
ORIGIN: ../../../flutter/impeller/toolkit/egl/egl.cc + ../../../flutter/LICENSE
16881688
ORIGIN: ../../../flutter/impeller/toolkit/egl/egl.h + ../../../flutter/LICENSE
1689+
ORIGIN: ../../../flutter/impeller/toolkit/egl/image.h + ../../../flutter/LICENSE
16891690
ORIGIN: ../../../flutter/impeller/toolkit/egl/surface.cc + ../../../flutter/LICENSE
16901691
ORIGIN: ../../../flutter/impeller/toolkit/egl/surface.h + ../../../flutter/LICENSE
1692+
ORIGIN: ../../../flutter/impeller/toolkit/gles/gles.h + ../../../flutter/LICENSE
1693+
ORIGIN: ../../../flutter/impeller/toolkit/gles/texture.h + ../../../flutter/LICENSE
16911694
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.cc + ../../../flutter/LICENSE
16921695
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.h + ../../../flutter/LICENSE
16931696
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_render_context_skia.cc + ../../../flutter/LICENSE
@@ -2322,6 +2325,8 @@ ORIGIN: ../../../flutter/shell/platform/android/external_view_embedder/surface_p
23222325
ORIGIN: ../../../flutter/shell/platform/android/external_view_embedder/surface_pool.h + ../../../flutter/LICENSE
23232326
ORIGIN: ../../../flutter/shell/platform/android/flutter_main.cc + ../../../flutter/LICENSE
23242327
ORIGIN: ../../../flutter/shell/platform/android/flutter_main.h + ../../../flutter/LICENSE
2328+
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc + ../../../flutter/LICENSE
2329+
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.h + ../../../flutter/LICENSE
23252330
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/FlutterInjector.java + ../../../flutter/LICENSE
23262331
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/Log.java + ../../../flutter/LICENSE
23272332
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/app/FlutterActivity.java + ../../../flutter/LICENSE
@@ -2463,6 +2468,8 @@ ORIGIN: ../../../flutter/shell/platform/android/jni/jni_mock.h + ../../../flutte
24632468
ORIGIN: ../../../flutter/shell/platform/android/jni/platform_view_android_jni.cc + ../../../flutter/LICENSE
24642469
ORIGIN: ../../../flutter/shell/platform/android/jni/platform_view_android_jni.h + ../../../flutter/LICENSE
24652470
ORIGIN: ../../../flutter/shell/platform/android/library_loader.cc + ../../../flutter/LICENSE
2471+
ORIGIN: ../../../flutter/shell/platform/android/ndk_helpers.cc + ../../../flutter/LICENSE
2472+
ORIGIN: ../../../flutter/shell/platform/android/ndk_helpers.h + ../../../flutter/LICENSE
24662473
ORIGIN: ../../../flutter/shell/platform/android/platform_message_handler_android.h + ../../../flutter/LICENSE
24672474
ORIGIN: ../../../flutter/shell/platform/android/platform_message_response_android.cc + ../../../flutter/LICENSE
24682475
ORIGIN: ../../../flutter/shell/platform/android/platform_message_response_android.h + ../../../flutter/LICENSE
@@ -4382,8 +4389,13 @@ FILE: ../../../flutter/impeller/toolkit/egl/display.cc
43824389
FILE: ../../../flutter/impeller/toolkit/egl/display.h
43834390
FILE: ../../../flutter/impeller/toolkit/egl/egl.cc
43844391
FILE: ../../../flutter/impeller/toolkit/egl/egl.h
4392+
FILE: ../../../flutter/impeller/toolkit/egl/image.cc
4393+
FILE: ../../../flutter/impeller/toolkit/egl/image.h
43854394
FILE: ../../../flutter/impeller/toolkit/egl/surface.cc
43864395
FILE: ../../../flutter/impeller/toolkit/egl/surface.h
4396+
FILE: ../../../flutter/impeller/toolkit/gles/gles.h
4397+
FILE: ../../../flutter/impeller/toolkit/gles/texture.cc
4398+
FILE: ../../../flutter/impeller/toolkit/gles/texture.h
43874399
FILE: ../../../flutter/impeller/tools/malioc.json
43884400
FILE: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.cc
43894401
FILE: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.h
@@ -5020,6 +5032,8 @@ FILE: ../../../flutter/shell/platform/android/external_view_embedder/surface_poo
50205032
FILE: ../../../flutter/shell/platform/android/external_view_embedder/surface_pool.h
50215033
FILE: ../../../flutter/shell/platform/android/flutter_main.cc
50225034
FILE: ../../../flutter/shell/platform/android/flutter_main.h
5035+
FILE: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc
5036+
FILE: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.h
50235037
FILE: ../../../flutter/shell/platform/android/io/flutter/FlutterInjector.java
50245038
FILE: ../../../flutter/shell/platform/android/io/flutter/Log.java
50255039
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterActivity.java
@@ -5137,6 +5151,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextInpu
51375151
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java
51385152
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java
51395153
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/platform/AccessibilityEventsDelegate.java
5154+
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/platform/ImageReaderPlatformViewRenderTarget.java
51405155
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/platform/PlatformOverlayView.java
51415156
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java
51425157
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/platform/PlatformView.java
@@ -5169,6 +5184,8 @@ FILE: ../../../flutter/shell/platform/android/jni/jni_mock.h
51695184
FILE: ../../../flutter/shell/platform/android/jni/platform_view_android_jni.cc
51705185
FILE: ../../../flutter/shell/platform/android/jni/platform_view_android_jni.h
51715186
FILE: ../../../flutter/shell/platform/android/library_loader.cc
5187+
FILE: ../../../flutter/shell/platform/android/ndk_helpers.cc
5188+
FILE: ../../../flutter/shell/platform/android/ndk_helpers.h
51725189
FILE: ../../../flutter/shell/platform/android/platform_message_handler_android.cc
51735190
FILE: ../../../flutter/shell/platform/android/platform_message_handler_android.h
51745191
FILE: ../../../flutter/shell/platform/android/platform_message_response_android.cc

impeller/toolkit/egl/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ impeller_component("egl") {
1414
"display.h",
1515
"egl.cc",
1616
"egl.h",
17+
"image.cc",
18+
"image.h",
1719
"surface.cc",
1820
"surface.h",
1921
]

impeller/toolkit/egl/egl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#pragma once
66

77
#include <EGL/egl.h>
8+
#define EGL_EGLEXT_PROTOTYPES
9+
#include <EGL/eglext.h>
810

911
#include <functional>
1012

impeller/toolkit/egl/image.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "flutter/impeller/toolkit/egl/image.h"
2+
3+
namespace impeller {}

impeller/toolkit/egl/image.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
#pragma once
6+
7+
#include "flutter/fml/unique_object.h"
8+
#include "flutter/impeller/toolkit/egl/egl.h"
9+
10+
namespace impeller {
11+
12+
// Simple holder of an EGLImage and the owning EGLDisplay.
13+
struct EGLImageWithDisplay {
14+
EGLImage image = EGL_NO_IMAGE;
15+
EGLDisplay display = EGL_NO_DISPLAY;
16+
17+
constexpr bool operator==(const EGLImageWithDisplay& other) const {
18+
return image == other.image && display == other.display;
19+
}
20+
21+
constexpr bool operator!=(const EGLImageWithDisplay& other) const {
22+
return !(*this == other);
23+
}
24+
};
25+
26+
struct EGLImageWithDisplayTraits {
27+
static EGLImageWithDisplay InvalidValue() {
28+
return {EGL_NO_IMAGE, EGL_NO_DISPLAY};
29+
}
30+
31+
static bool IsValid(const EGLImageWithDisplay& value) {
32+
return value != InvalidValue();
33+
}
34+
35+
static void Free(EGLImageWithDisplay image) {
36+
eglDestroyImage(image.display, image.image);
37+
}
38+
};
39+
40+
using UniqueEGLImage =
41+
fml::UniqueObject<EGLImageWithDisplay, EGLImageWithDisplayTraits>;
42+
43+
// Simple holder of an EGLImageKHR and the owning EGLDisplay.
44+
struct EGLImageKHRWithDisplay {
45+
EGLImageKHR image = EGL_NO_IMAGE_KHR;
46+
EGLDisplay display = EGL_NO_DISPLAY;
47+
48+
constexpr bool operator==(const EGLImageKHRWithDisplay& other) const {
49+
return image == other.image && display == other.display;
50+
}
51+
52+
constexpr bool operator!=(const EGLImageKHRWithDisplay& other) const {
53+
return !(*this == other);
54+
}
55+
};
56+
57+
struct EGLImageKHRWithDisplayTraits {
58+
static EGLImageKHRWithDisplay InvalidValue() {
59+
return {EGL_NO_IMAGE_KHR, EGL_NO_DISPLAY};
60+
}
61+
62+
static bool IsValid(const EGLImageKHRWithDisplay& value) {
63+
return value != InvalidValue();
64+
}
65+
66+
static void Free(EGLImageKHRWithDisplay image) {
67+
eglDestroyImageKHR(image.display, image.image);
68+
}
69+
};
70+
71+
using UniqueEGLImageKHR =
72+
fml::UniqueObject<EGLImageKHRWithDisplay, EGLImageKHRWithDisplayTraits>;
73+
74+
} // namespace impeller

impeller/toolkit/gles/BUILD.gn

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
import("../../tools/impeller.gni")
6+
7+
impeller_component("gles") {
8+
sources = [
9+
"gles.h",
10+
"texture.cc",
11+
"texture.h",
12+
]
13+
14+
deps = [
15+
"../../base",
16+
"//flutter/fml",
17+
]
18+
19+
libs = []
20+
}

impeller/toolkit/gles/gles.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
#pragma once
6+
7+
#include "GLES3/gl3.h"
8+
#define GL_GLEXT_PROTOTYPES
9+
#include "GLES2/gl2ext.h"

impeller/toolkit/gles/texture.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "flutter/impeller/toolkit/gles/texture.h"
2+
3+
namespace impeller {}

impeller/toolkit/gles/texture.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
#pragma once
6+
7+
#include "flutter/fml/unique_object.h"
8+
#include "flutter/impeller/toolkit/gles/gles.h"
9+
10+
namespace impeller {
11+
12+
// Simple holder of an GLTexture and the owning EGLDisplay.
13+
struct GLTexture {
14+
GLuint texture_name;
15+
16+
constexpr bool operator==(const GLTexture& other) const {
17+
return texture_name == other.texture_name;
18+
}
19+
20+
constexpr bool operator!=(const GLTexture& other) const {
21+
return !(*this == other);
22+
}
23+
};
24+
25+
struct GLTextureTraits {
26+
static GLTexture InvalidValue() { return {0}; }
27+
28+
static bool IsValid(const GLTexture& value) {
29+
return value != InvalidValue();
30+
}
31+
32+
static void Free(GLTexture image) {
33+
glDeleteTextures(1, &image.texture_name);
34+
}
35+
};
36+
37+
using UniqueGLTexture = fml::UniqueObject<GLTexture, GLTextureTraits>;
38+
39+
} // namespace impeller

shell/platform/android/BUILD.gn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ source_set("flutter_shell_native_src") {
9898
"apk_asset_provider.h",
9999
"flutter_main.cc",
100100
"flutter_main.h",
101+
"hardware_buffer_external_texture_gl.cc",
102+
"hardware_buffer_external_texture_gl.h",
101103
"library_loader.cc",
104+
"ndk_helpers.cc",
105+
"ndk_helpers.h",
102106
"platform_message_handler_android.cc",
103107
"platform_message_handler_android.h",
104108
"platform_message_response_android.cc",
@@ -122,6 +126,7 @@ source_set("flutter_shell_native_src") {
122126
"//flutter/fml",
123127
"//flutter/impeller",
124128
"//flutter/impeller/toolkit/egl",
129+
"//flutter/impeller/toolkit/gles",
125130
"//flutter/lib/ui",
126131
"//flutter/runtime",
127132
"//flutter/runtime:libdart",
@@ -287,6 +292,7 @@ android_java_sources = [
287292
"io/flutter/plugin/localization/LocalizationPlugin.java",
288293
"io/flutter/plugin/mouse/MouseCursorPlugin.java",
289294
"io/flutter/plugin/platform/AccessibilityEventsDelegate.java",
295+
"io/flutter/plugin/platform/ImageReaderPlatformViewRenderTarget.java",
290296
"io/flutter/plugin/platform/PlatformOverlayView.java",
291297
"io/flutter/plugin/platform/PlatformPlugin.java",
292298
"io/flutter/plugin/platform/PlatformView.java",

0 commit comments

Comments
 (0)