Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -3007,10 +3007,12 @@ ORIGIN: ../../../flutter/shell/platform/android/external_view_embedder/surface_p
ORIGIN: ../../../flutter/shell/platform/android/external_view_embedder/surface_pool.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/flutter_main.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/flutter_main.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_gl.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/hardware_buffer_external_texture_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_gl.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_gl.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/image_external_texture_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/FlutterInjector.java + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/Log.java + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/app/FlutterActivity.java + ../../../flutter/LICENSE
Expand Down
12 changes: 6 additions & 6 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ source_set("flutter_shell_native_src") {
"apk_asset_provider.h",
"flutter_main.cc",
"flutter_main.h",
"hardware_buffer_external_texture.cc",
"hardware_buffer_external_texture.h",
"hardware_buffer_external_texture_gl.cc",
"hardware_buffer_external_texture_gl.h",
"hardware_buffer_external_texture_vk.cc",
"hardware_buffer_external_texture_vk.h",
"image_external_texture.cc",
"image_external_texture.h",
"image_external_texture_gl.cc",
"image_external_texture_gl.h",
"image_external_texture_vk.cc",
"image_external_texture_vk.h",
"library_loader.cc",
"ndk_helpers.cc",
"ndk_helpers.h",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "flutter/shell/platform/android/hardware_buffer_external_texture.h"
#include "flutter/shell/platform/android/image_external_texture.h"

#include <android/hardware_buffer_jni.h>
#include <android/sensor.h>
Expand All @@ -9,7 +9,7 @@

namespace flutter {

HardwareBufferExternalTexture::HardwareBufferExternalTexture(
ImageExternalTexture::ImageExternalTexture(
int64_t id,
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
Expand All @@ -18,10 +18,10 @@ HardwareBufferExternalTexture::HardwareBufferExternalTexture(
jni_facade_(jni_facade) {}

// Implementing flutter::Texture.
void HardwareBufferExternalTexture::Paint(PaintContext& context,
const SkRect& bounds,
bool freeze,
const DlImageSampling sampling) {
void ImageExternalTexture::Paint(PaintContext& context,
const SkRect& bounds,
bool freeze,
const DlImageSampling sampling) {
if (state_ == AttachmentState::kDetached) {
return;
}
Expand All @@ -42,34 +42,33 @@ void HardwareBufferExternalTexture::Paint(PaintContext& context,
flutter::DlCanvas::SrcRectConstraint::kStrict // enforce edges
);
} else {
FML_LOG(ERROR)
<< "No DlImage available for HardwareBufferExternalTexture to paint.";
FML_LOG(ERROR) << "No DlImage available for ImageExternalTexture to paint.";
}
}

// Implementing flutter::Texture.
void HardwareBufferExternalTexture::MarkNewFrameAvailable() {
void ImageExternalTexture::MarkNewFrameAvailable() {
new_frame_ready_ = true;
}

// Implementing flutter::Texture.
void HardwareBufferExternalTexture::OnTextureUnregistered() {}
void ImageExternalTexture::OnTextureUnregistered() {}

// Implementing flutter::ContextListener.
void HardwareBufferExternalTexture::OnGrContextCreated() {
void ImageExternalTexture::OnGrContextCreated() {
state_ = AttachmentState::kUninitialized;
}

// Implementing flutter::ContextListener.
void HardwareBufferExternalTexture::OnGrContextDestroyed() {
void ImageExternalTexture::OnGrContextDestroyed() {
if (state_ == AttachmentState::kAttached) {
dl_image_.reset();
Detach();
}
state_ = AttachmentState::kDetached;
}

JavaLocalRef HardwareBufferExternalTexture::AcquireLatestImage() {
JavaLocalRef ImageExternalTexture::AcquireLatestImage() {
JNIEnv* env = fml::jni::AttachCurrentThread();
FML_CHECK(env != nullptr);

Expand All @@ -79,23 +78,22 @@ JavaLocalRef HardwareBufferExternalTexture::AcquireLatestImage() {
return image_java;
}

void HardwareBufferExternalTexture::CloseImage(
const fml::jni::JavaRef<jobject>& image) {
void ImageExternalTexture::CloseImage(const fml::jni::JavaRef<jobject>& image) {
if (image.obj() == nullptr) {
return;
}
jni_facade_->ImageClose(JavaLocalRef(image));
}

void HardwareBufferExternalTexture::CloseHardwareBuffer(
void ImageExternalTexture::CloseHardwareBuffer(
const fml::jni::JavaRef<jobject>& hardware_buffer) {
if (hardware_buffer.obj() == nullptr) {
return;
}
jni_facade_->HardwareBufferClose(JavaLocalRef(hardware_buffer));
}

JavaLocalRef HardwareBufferExternalTexture::HardwareBufferFor(
JavaLocalRef ImageExternalTexture::HardwareBufferFor(
const fml::jni::JavaRef<jobject>& image) {
if (image.obj() == nullptr) {
return JavaLocalRef();
Expand All @@ -104,7 +102,7 @@ JavaLocalRef HardwareBufferExternalTexture::HardwareBufferFor(
return jni_facade_->ImageGetHardwareBuffer(JavaLocalRef(image));
}

AHardwareBuffer* HardwareBufferExternalTexture::AHardwareBufferFor(
AHardwareBuffer* ImageExternalTexture::AHardwareBufferFor(
const fml::jni::JavaRef<jobject>& hardware_buffer) {
JNIEnv* env = fml::jni::AttachCurrentThread();
FML_CHECK(env != nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// 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_HARDWARE_BUFFER_EXTERNAL_TEXTURE_H_
#define FLUTTER_SHELL_PLATFORM_ANDROID_HARDWARE_BUFFER_EXTERNAL_TEXTURE_H_
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_
#define FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_

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

// External texture peered to a sequence of android.hardware.HardwareBuffers.
//
class HardwareBufferExternalTexture : public flutter::Texture {
class ImageExternalTexture : public flutter::Texture {
public:
explicit HardwareBufferExternalTexture(
explicit ImageExternalTexture(
int64_t id,
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade);

virtual ~HardwareBufferExternalTexture() = default;
virtual ~ImageExternalTexture() = default;

// |flutter::Texture|.
void Paint(PaintContext& context,
Expand Down Expand Up @@ -65,9 +65,9 @@ class HardwareBufferExternalTexture : public flutter::Texture {

sk_sp<flutter::DlImage> dl_image_;

FML_DISALLOW_COPY_AND_ASSIGN(HardwareBufferExternalTexture);
FML_DISALLOW_COPY_AND_ASSIGN(ImageExternalTexture);
};

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_ANDROID_HARDWARE_BUFFER_EXTERNAL_TEXTURE_H_
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_EXTERNAL_TEXTURE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/android/hardware_buffer_external_texture_gl.h"
#include "flutter/shell/platform/android/image_external_texture_gl.h"

#include <android/hardware_buffer_jni.h>
#include <android/sensor.h>
Expand All @@ -28,13 +28,13 @@

namespace flutter {

HardwareBufferExternalTextureGL::HardwareBufferExternalTextureGL(
ImageExternalTextureGL::ImageExternalTextureGL(
int64_t id,
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
: HardwareBufferExternalTexture(id, image_texture_entry, jni_facade) {}
: ImageExternalTexture(id, image_texture_entry, jni_facade) {}

void HardwareBufferExternalTextureGL::Attach(PaintContext& context) {
void ImageExternalTextureGL::Attach(PaintContext& context) {
if (state_ == AttachmentState::kUninitialized) {
if (!android_image_.is_null()) {
JavaLocalRef hardware_buffer = HardwareBufferFor(android_image_);
Expand All @@ -47,11 +47,11 @@ void HardwareBufferExternalTextureGL::Attach(PaintContext& context) {
}
}

void HardwareBufferExternalTextureGL::Detach() {
void ImageExternalTextureGL::Detach() {
egl_image_.reset();
}

bool HardwareBufferExternalTextureGL::MaybeSwapImages() {
bool ImageExternalTextureGL::MaybeSwapImages() {
JavaLocalRef image = AcquireLatestImage();
if (image.is_null()) {
return false;
Expand All @@ -72,7 +72,7 @@ bool HardwareBufferExternalTextureGL::MaybeSwapImages() {
return true;
}

impeller::UniqueEGLImageKHR HardwareBufferExternalTextureGL::CreateEGLImage(
impeller::UniqueEGLImageKHR ImageExternalTextureGL::CreateEGLImage(
AHardwareBuffer* hardware_buffer) {
if (hardware_buffer == nullptr) {
return impeller::UniqueEGLImageKHR();
Expand All @@ -98,31 +98,31 @@ impeller::UniqueEGLImageKHR HardwareBufferExternalTextureGL::CreateEGLImage(
return impeller::UniqueEGLImageKHR(maybe_image);
}

HardwareBufferExternalTextureGLSkia::HardwareBufferExternalTextureGLSkia(
ImageExternalTextureGLSkia::ImageExternalTextureGLSkia(
const std::shared_ptr<AndroidContextGLSkia>& context,
int64_t id,
const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
: HardwareBufferExternalTextureGL(id, image_texture_entry, jni_facade) {}
: ImageExternalTextureGL(id, image_texture_entry, jni_facade) {}

void HardwareBufferExternalTextureGLSkia::Attach(PaintContext& context) {
void ImageExternalTextureGLSkia::Attach(PaintContext& context) {
if (state_ == AttachmentState::kUninitialized) {
// After this call state_ will be AttachmentState::kAttached and egl_image_
// will have been created if we still have an Image associated with us.
HardwareBufferExternalTextureGL::Attach(context);
ImageExternalTextureGL::Attach(context);
GLuint texture_name;
glGenTextures(1, &texture_name);
texture_.reset(impeller::GLTexture{texture_name});
}
}

void HardwareBufferExternalTextureGLSkia::Detach() {
HardwareBufferExternalTextureGL::Detach();
void ImageExternalTextureGLSkia::Detach() {
ImageExternalTextureGL::Detach();
texture_.reset();
}

void HardwareBufferExternalTextureGLSkia::ProcessFrame(PaintContext& context,
const SkRect& bounds) {
void ImageExternalTextureGLSkia::ProcessFrame(PaintContext& context,
const SkRect& bounds) {
const bool swapped = MaybeSwapImages();
if (!swapped && !egl_image_.is_valid()) {
// Nothing to do.
Expand All @@ -132,7 +132,7 @@ void HardwareBufferExternalTextureGLSkia::ProcessFrame(PaintContext& context,
dl_image_ = CreateDlImage(context, bounds);
}

void HardwareBufferExternalTextureGLSkia::BindImageToTexture(
void ImageExternalTextureGLSkia::BindImageToTexture(
const impeller::UniqueEGLImageKHR& image,
GLuint tex) {
if (!image.is_valid() || tex == 0) {
Expand All @@ -143,7 +143,7 @@ void HardwareBufferExternalTextureGLSkia::BindImageToTexture(
(GLeglImageOES)image.get().image);
}

sk_sp<flutter::DlImage> HardwareBufferExternalTextureGLSkia::CreateDlImage(
sk_sp<flutter::DlImage> ImageExternalTextureGLSkia::CreateDlImage(
PaintContext& context,
const SkRect& bounds) {
GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES,
Expand All @@ -155,26 +155,24 @@ sk_sp<flutter::DlImage> HardwareBufferExternalTextureGLSkia::CreateDlImage(
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr));
}

HardwareBufferExternalTextureGLImpeller::
HardwareBufferExternalTextureGLImpeller(
const std::shared_ptr<impeller::ContextGLES>& context,
int64_t id,
const fml::jni::ScopedJavaGlobalRef<jobject>& image_textury_entry,
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
: HardwareBufferExternalTextureGL(id, image_textury_entry, jni_facade),
ImageExternalTextureGLImpeller::ImageExternalTextureGLImpeller(
const std::shared_ptr<impeller::ContextGLES>& context,
int64_t id,
const fml::jni::ScopedJavaGlobalRef<jobject>& image_textury_entry,
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
: ImageExternalTextureGL(id, image_textury_entry, jni_facade),
impeller_context_(context) {}

void HardwareBufferExternalTextureGLImpeller::Detach() {}
void ImageExternalTextureGLImpeller::Detach() {}

void HardwareBufferExternalTextureGLImpeller::Attach(PaintContext& context) {
void ImageExternalTextureGLImpeller::Attach(PaintContext& context) {
if (state_ == AttachmentState::kUninitialized) {
HardwareBufferExternalTextureGL::Attach(context);
ImageExternalTextureGL::Attach(context);
}
}

void HardwareBufferExternalTextureGLImpeller::ProcessFrame(
PaintContext& context,
const SkRect& bounds) {
void ImageExternalTextureGLImpeller::ProcessFrame(PaintContext& context,
const SkRect& bounds) {
const bool swapped = MaybeSwapImages();
if (!swapped && !egl_image_.is_valid()) {
// Nothing to do.
Expand All @@ -183,7 +181,7 @@ void HardwareBufferExternalTextureGLImpeller::ProcessFrame(
dl_image_ = CreateDlImage(context, bounds);
}

sk_sp<flutter::DlImage> HardwareBufferExternalTextureGLImpeller::CreateDlImage(
sk_sp<flutter::DlImage> ImageExternalTextureGLImpeller::CreateDlImage(
PaintContext& context,
const SkRect& bounds) {
impeller::TextureDescriptor desc;
Expand Down
Loading