Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1a99edb

Browse files
johnmccutchanharryterkelsen
authored andcommitted
Rename HardwareBufferExternalTexture* to ImageExternalTexture* (#46786)
Image is the more accurate name and we will eventually have a HardwareBufferExternalTexture in the future (see https://developer.android.com/reference/android/graphics/HardwareBufferRenderer available on Android >= 34).
1 parent 265d2e2 commit 1a99edb

10 files changed

+98
-102
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,10 +3008,12 @@ ORIGIN: ../../../flutter/shell/platform/android/external_view_embedder/surface_p
30083008
ORIGIN: ../../../flutter/shell/platform/android/external_view_embedder/surface_pool.h + ../../../flutter/LICENSE
30093009
ORIGIN: ../../../flutter/shell/platform/android/flutter_main.cc + ../../../flutter/LICENSE
30103010
ORIGIN: ../../../flutter/shell/platform/android/flutter_main.h + ../../../flutter/LICENSE
3011-
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture.h + ../../../flutter/LICENSE
3012-
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc + ../../../flutter/LICENSE
3013-
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.h + ../../../flutter/LICENSE
3014-
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_vk.h + ../../../flutter/LICENSE
3011+
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture.h + ../../../flutter/LICENSE
3012+
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture.cc + ../../../flutter/LICENSE
3013+
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_gl.cc + ../../../flutter/LICENSE
3014+
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_gl.h + ../../../flutter/LICENSE
3015+
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_vk.h + ../../../flutter/LICENSE
3016+
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_vk.cc + ../../../flutter/LICENSE
30153017
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/FlutterInjector.java + ../../../flutter/LICENSE
30163018
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/Log.java + ../../../flutter/LICENSE
30173019
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/app/FlutterActivity.java + ../../../flutter/LICENSE

shell/platform/android/BUILD.gn

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ source_set("flutter_shell_native_src") {
9696
"apk_asset_provider.h",
9797
"flutter_main.cc",
9898
"flutter_main.h",
99-
"hardware_buffer_external_texture.cc",
100-
"hardware_buffer_external_texture.h",
101-
"hardware_buffer_external_texture_gl.cc",
102-
"hardware_buffer_external_texture_gl.h",
103-
"hardware_buffer_external_texture_vk.cc",
104-
"hardware_buffer_external_texture_vk.h",
99+
"image_external_texture.cc",
100+
"image_external_texture.h",
101+
"image_external_texture_gl.cc",
102+
"image_external_texture_gl.h",
103+
"image_external_texture_vk.cc",
104+
"image_external_texture_vk.h",
105105
"library_loader.cc",
106106
"ndk_helpers.cc",
107107
"ndk_helpers.h",

shell/platform/android/hardware_buffer_external_texture.cc renamed to shell/platform/android/image_external_texture.cc

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#include "flutter/shell/platform/android/hardware_buffer_external_texture.h"
2+
#include "flutter/shell/platform/android/image_external_texture.h"
33

44
#include <android/hardware_buffer_jni.h>
55
#include <android/sensor.h>
@@ -9,7 +9,7 @@
99

1010
namespace flutter {
1111

12-
HardwareBufferExternalTexture::HardwareBufferExternalTexture(
12+
ImageExternalTexture::ImageExternalTexture(
1313
int64_t id,
1414
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
1515
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
@@ -18,10 +18,10 @@ HardwareBufferExternalTexture::HardwareBufferExternalTexture(
1818
jni_facade_(jni_facade) {}
1919

2020
// Implementing flutter::Texture.
21-
void HardwareBufferExternalTexture::Paint(PaintContext& context,
22-
const SkRect& bounds,
23-
bool freeze,
24-
const DlImageSampling sampling) {
21+
void ImageExternalTexture::Paint(PaintContext& context,
22+
const SkRect& bounds,
23+
bool freeze,
24+
const DlImageSampling sampling) {
2525
if (state_ == AttachmentState::kDetached) {
2626
return;
2727
}
@@ -42,34 +42,33 @@ void HardwareBufferExternalTexture::Paint(PaintContext& context,
4242
flutter::DlCanvas::SrcRectConstraint::kStrict // enforce edges
4343
);
4444
} else {
45-
FML_LOG(ERROR)
46-
<< "No DlImage available for HardwareBufferExternalTexture to paint.";
45+
FML_LOG(ERROR) << "No DlImage available for ImageExternalTexture to paint.";
4746
}
4847
}
4948

5049
// Implementing flutter::Texture.
51-
void HardwareBufferExternalTexture::MarkNewFrameAvailable() {
50+
void ImageExternalTexture::MarkNewFrameAvailable() {
5251
new_frame_ready_ = true;
5352
}
5453

5554
// Implementing flutter::Texture.
56-
void HardwareBufferExternalTexture::OnTextureUnregistered() {}
55+
void ImageExternalTexture::OnTextureUnregistered() {}
5756

5857
// Implementing flutter::ContextListener.
59-
void HardwareBufferExternalTexture::OnGrContextCreated() {
58+
void ImageExternalTexture::OnGrContextCreated() {
6059
state_ = AttachmentState::kUninitialized;
6160
}
6261

6362
// Implementing flutter::ContextListener.
64-
void HardwareBufferExternalTexture::OnGrContextDestroyed() {
63+
void ImageExternalTexture::OnGrContextDestroyed() {
6564
if (state_ == AttachmentState::kAttached) {
6665
dl_image_.reset();
6766
Detach();
6867
}
6968
state_ = AttachmentState::kDetached;
7069
}
7170

72-
JavaLocalRef HardwareBufferExternalTexture::AcquireLatestImage() {
71+
JavaLocalRef ImageExternalTexture::AcquireLatestImage() {
7372
JNIEnv* env = fml::jni::AttachCurrentThread();
7473
FML_CHECK(env != nullptr);
7574

@@ -79,23 +78,22 @@ JavaLocalRef HardwareBufferExternalTexture::AcquireLatestImage() {
7978
return image_java;
8079
}
8180

82-
void HardwareBufferExternalTexture::CloseImage(
83-
const fml::jni::JavaRef<jobject>& image) {
81+
void ImageExternalTexture::CloseImage(const fml::jni::JavaRef<jobject>& image) {
8482
if (image.obj() == nullptr) {
8583
return;
8684
}
8785
jni_facade_->ImageClose(JavaLocalRef(image));
8886
}
8987

90-
void HardwareBufferExternalTexture::CloseHardwareBuffer(
88+
void ImageExternalTexture::CloseHardwareBuffer(
9189
const fml::jni::JavaRef<jobject>& hardware_buffer) {
9290
if (hardware_buffer.obj() == nullptr) {
9391
return;
9492
}
9593
jni_facade_->HardwareBufferClose(JavaLocalRef(hardware_buffer));
9694
}
9795

98-
JavaLocalRef HardwareBufferExternalTexture::HardwareBufferFor(
96+
JavaLocalRef ImageExternalTexture::HardwareBufferFor(
9997
const fml::jni::JavaRef<jobject>& image) {
10098
if (image.obj() == nullptr) {
10199
return JavaLocalRef();
@@ -104,7 +102,7 @@ JavaLocalRef HardwareBufferExternalTexture::HardwareBufferFor(
104102
return jni_facade_->ImageGetHardwareBuffer(JavaLocalRef(image));
105103
}
106104

107-
AHardwareBuffer* HardwareBufferExternalTexture::AHardwareBufferFor(
105+
AHardwareBuffer* ImageExternalTexture::AHardwareBufferFor(
108106
const fml::jni::JavaRef<jobject>& hardware_buffer) {
109107
JNIEnv* env = fml::jni::AttachCurrentThread();
110108
FML_CHECK(env != nullptr);

shell/platform/android/hardware_buffer_external_texture.h renamed to shell/platform/android/image_external_texture.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_HARDWARE_BUFFER_EXTERNAL_TEXTURE_H_
6-
#define FLUTTER_SHELL_PLATFORM_ANDROID_HARDWARE_BUFFER_EXTERNAL_TEXTURE_H_
5+
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_
6+
#define FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_
77

88
#include "flutter/common/graphics/texture.h"
99
#include "flutter/fml/logging.h"
@@ -17,14 +17,14 @@ namespace flutter {
1717

1818
// External texture peered to a sequence of android.hardware.HardwareBuffers.
1919
//
20-
class HardwareBufferExternalTexture : public flutter::Texture {
20+
class ImageExternalTexture : public flutter::Texture {
2121
public:
22-
explicit HardwareBufferExternalTexture(
22+
explicit ImageExternalTexture(
2323
int64_t id,
2424
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
2525
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade);
2626

27-
virtual ~HardwareBufferExternalTexture() = default;
27+
virtual ~ImageExternalTexture() = default;
2828

2929
// |flutter::Texture|.
3030
void Paint(PaintContext& context,
@@ -65,9 +65,9 @@ class HardwareBufferExternalTexture : public flutter::Texture {
6565

6666
sk_sp<flutter::DlImage> dl_image_;
6767

68-
FML_DISALLOW_COPY_AND_ASSIGN(HardwareBufferExternalTexture);
68+
FML_DISALLOW_COPY_AND_ASSIGN(ImageExternalTexture);
6969
};
7070

7171
} // namespace flutter
7272

73-
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_HARDWARE_BUFFER_EXTERNAL_TEXTURE_H_
73+
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_

shell/platform/android/hardware_buffer_external_texture_gl.cc renamed to shell/platform/android/image_external_texture_gl.cc

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "flutter/shell/platform/android/hardware_buffer_external_texture_gl.h"
5+
#include "flutter/shell/platform/android/image_external_texture_gl.h"
66

77
#include <android/hardware_buffer_jni.h>
88
#include <android/sensor.h>
@@ -28,13 +28,13 @@
2828

2929
namespace flutter {
3030

31-
HardwareBufferExternalTextureGL::HardwareBufferExternalTextureGL(
31+
ImageExternalTextureGL::ImageExternalTextureGL(
3232
int64_t id,
3333
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
3434
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
35-
: HardwareBufferExternalTexture(id, image_texture_entry, jni_facade) {}
35+
: ImageExternalTexture(id, image_texture_entry, jni_facade) {}
3636

37-
void HardwareBufferExternalTextureGL::Attach(PaintContext& context) {
37+
void ImageExternalTextureGL::Attach(PaintContext& context) {
3838
if (state_ == AttachmentState::kUninitialized) {
3939
if (!android_image_.is_null()) {
4040
JavaLocalRef hardware_buffer = HardwareBufferFor(android_image_);
@@ -47,11 +47,11 @@ void HardwareBufferExternalTextureGL::Attach(PaintContext& context) {
4747
}
4848
}
4949

50-
void HardwareBufferExternalTextureGL::Detach() {
50+
void ImageExternalTextureGL::Detach() {
5151
egl_image_.reset();
5252
}
5353

54-
bool HardwareBufferExternalTextureGL::MaybeSwapImages() {
54+
bool ImageExternalTextureGL::MaybeSwapImages() {
5555
JavaLocalRef image = AcquireLatestImage();
5656
if (image.is_null()) {
5757
return false;
@@ -72,7 +72,7 @@ bool HardwareBufferExternalTextureGL::MaybeSwapImages() {
7272
return true;
7373
}
7474

75-
impeller::UniqueEGLImageKHR HardwareBufferExternalTextureGL::CreateEGLImage(
75+
impeller::UniqueEGLImageKHR ImageExternalTextureGL::CreateEGLImage(
7676
AHardwareBuffer* hardware_buffer) {
7777
if (hardware_buffer == nullptr) {
7878
return impeller::UniqueEGLImageKHR();
@@ -98,31 +98,31 @@ impeller::UniqueEGLImageKHR HardwareBufferExternalTextureGL::CreateEGLImage(
9898
return impeller::UniqueEGLImageKHR(maybe_image);
9999
}
100100

101-
HardwareBufferExternalTextureGLSkia::HardwareBufferExternalTextureGLSkia(
101+
ImageExternalTextureGLSkia::ImageExternalTextureGLSkia(
102102
const std::shared_ptr<AndroidContextGLSkia>& context,
103103
int64_t id,
104104
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
105105
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
106-
: HardwareBufferExternalTextureGL(id, image_texture_entry, jni_facade) {}
106+
: ImageExternalTextureGL(id, image_texture_entry, jni_facade) {}
107107

108-
void HardwareBufferExternalTextureGLSkia::Attach(PaintContext& context) {
108+
void ImageExternalTextureGLSkia::Attach(PaintContext& context) {
109109
if (state_ == AttachmentState::kUninitialized) {
110110
// After this call state_ will be AttachmentState::kAttached and egl_image_
111111
// will have been created if we still have an Image associated with us.
112-
HardwareBufferExternalTextureGL::Attach(context);
112+
ImageExternalTextureGL::Attach(context);
113113
GLuint texture_name;
114114
glGenTextures(1, &texture_name);
115115
texture_.reset(impeller::GLTexture{texture_name});
116116
}
117117
}
118118

119-
void HardwareBufferExternalTextureGLSkia::Detach() {
120-
HardwareBufferExternalTextureGL::Detach();
119+
void ImageExternalTextureGLSkia::Detach() {
120+
ImageExternalTextureGL::Detach();
121121
texture_.reset();
122122
}
123123

124-
void HardwareBufferExternalTextureGLSkia::ProcessFrame(PaintContext& context,
125-
const SkRect& bounds) {
124+
void ImageExternalTextureGLSkia::ProcessFrame(PaintContext& context,
125+
const SkRect& bounds) {
126126
const bool swapped = MaybeSwapImages();
127127
if (!swapped && !egl_image_.is_valid()) {
128128
// Nothing to do.
@@ -132,7 +132,7 @@ void HardwareBufferExternalTextureGLSkia::ProcessFrame(PaintContext& context,
132132
dl_image_ = CreateDlImage(context, bounds);
133133
}
134134

135-
void HardwareBufferExternalTextureGLSkia::BindImageToTexture(
135+
void ImageExternalTextureGLSkia::BindImageToTexture(
136136
const impeller::UniqueEGLImageKHR& image,
137137
GLuint tex) {
138138
if (!image.is_valid() || tex == 0) {
@@ -143,7 +143,7 @@ void HardwareBufferExternalTextureGLSkia::BindImageToTexture(
143143
(GLeglImageOES)image.get().image);
144144
}
145145

146-
sk_sp<flutter::DlImage> HardwareBufferExternalTextureGLSkia::CreateDlImage(
146+
sk_sp<flutter::DlImage> ImageExternalTextureGLSkia::CreateDlImage(
147147
PaintContext& context,
148148
const SkRect& bounds) {
149149
GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES,
@@ -155,26 +155,24 @@ sk_sp<flutter::DlImage> HardwareBufferExternalTextureGLSkia::CreateDlImage(
155155
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr));
156156
}
157157

158-
HardwareBufferExternalTextureGLImpeller::
159-
HardwareBufferExternalTextureGLImpeller(
160-
const std::shared_ptr<impeller::ContextGLES>& context,
161-
int64_t id,
162-
const fml::jni::ScopedJavaGlobalRef<jobject>& image_textury_entry,
163-
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
164-
: HardwareBufferExternalTextureGL(id, image_textury_entry, jni_facade),
158+
ImageExternalTextureGLImpeller::ImageExternalTextureGLImpeller(
159+
const std::shared_ptr<impeller::ContextGLES>& context,
160+
int64_t id,
161+
const fml::jni::ScopedJavaGlobalRef<jobject>& image_textury_entry,
162+
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
163+
: ImageExternalTextureGL(id, image_textury_entry, jni_facade),
165164
impeller_context_(context) {}
166165

167-
void HardwareBufferExternalTextureGLImpeller::Detach() {}
166+
void ImageExternalTextureGLImpeller::Detach() {}
168167

169-
void HardwareBufferExternalTextureGLImpeller::Attach(PaintContext& context) {
168+
void ImageExternalTextureGLImpeller::Attach(PaintContext& context) {
170169
if (state_ == AttachmentState::kUninitialized) {
171-
HardwareBufferExternalTextureGL::Attach(context);
170+
ImageExternalTextureGL::Attach(context);
172171
}
173172
}
174173

175-
void HardwareBufferExternalTextureGLImpeller::ProcessFrame(
176-
PaintContext& context,
177-
const SkRect& bounds) {
174+
void ImageExternalTextureGLImpeller::ProcessFrame(PaintContext& context,
175+
const SkRect& bounds) {
178176
const bool swapped = MaybeSwapImages();
179177
if (!swapped && !egl_image_.is_valid()) {
180178
// Nothing to do.
@@ -183,7 +181,7 @@ void HardwareBufferExternalTextureGLImpeller::ProcessFrame(
183181
dl_image_ = CreateDlImage(context, bounds);
184182
}
185183

186-
sk_sp<flutter::DlImage> HardwareBufferExternalTextureGLImpeller::CreateDlImage(
184+
sk_sp<flutter::DlImage> ImageExternalTextureGLImpeller::CreateDlImage(
187185
PaintContext& context,
188186
const SkRect& bounds) {
189187
impeller::TextureDescriptor desc;

0 commit comments

Comments
 (0)