From 41331e0315cce86bd6457bf06585a55fca6a4096 Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Fri, 11 Aug 2023 13:28:03 -0700 Subject: [PATCH] Rename impeller::TextureIntent to impeller::TextureCoordinateSystem (flutter/engine#44628) --- engine/src/flutter/impeller/core/formats.h | 8 +++++++- engine/src/flutter/impeller/core/texture.cc | 12 ++++++------ engine/src/flutter/impeller/core/texture.h | 7 ++++--- .../impeller/renderer/backend/gles/texture_gles.cc | 6 +++--- .../android/hardware_buffer_external_texture_gl.cc | 3 ++- .../graphics/FlutterDarwinExternalTextureMetal.mm | 6 +++--- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/engine/src/flutter/impeller/core/formats.h b/engine/src/flutter/impeller/core/formats.h index 45ad71101e..ca92991b16 100644 --- a/engine/src/flutter/impeller/core/formats.h +++ b/engine/src/flutter/impeller/core/formats.h @@ -297,8 +297,14 @@ constexpr const char* TextureUsageToString(TextureUsage usage) { std::string TextureUsageMaskToString(TextureUsageMask mask); -enum class TextureIntent { +// Texture coordinate system. +enum class TextureCoordinateSystem { + // Alternative coordinate system used when uploading texture data from the + // host. + // (0, 0) is the bottom-left of the image with +Y going up. kUploadFromHost, + // Default coordinate system. + // (0, 0) is the top-left of the image with +Y going down. kRenderToTexture, }; diff --git a/engine/src/flutter/impeller/core/texture.cc b/engine/src/flutter/impeller/core/texture.cc index 89f067cd69..bb2f125aea 100644 --- a/engine/src/flutter/impeller/core/texture.cc +++ b/engine/src/flutter/impeller/core/texture.cc @@ -23,7 +23,7 @@ bool Texture::SetContents(const uint8_t* contents, if (!OnSetContents(contents, length, slice)) { return false; } - intent_ = TextureIntent::kUploadFromHost; + coordinate_system_ = TextureCoordinateSystem::kUploadFromHost; is_opaque_ = is_opaque; return true; } @@ -41,7 +41,7 @@ bool Texture::SetContents(std::shared_ptr mapping, if (!OnSetContents(std::move(mapping), slice)) { return false; } - intent_ = TextureIntent::kUploadFromHost; + coordinate_system_ = TextureCoordinateSystem::kUploadFromHost; is_opaque_ = is_opaque; return true; } @@ -70,12 +70,12 @@ bool Texture::IsSliceValid(size_t slice) const { FML_UNREACHABLE(); } -void Texture::SetIntent(TextureIntent intent) { - intent_ = intent; +void Texture::SetCoordinateSystem(TextureCoordinateSystem coordinate_system) { + coordinate_system_ = coordinate_system; } -TextureIntent Texture::GetIntent() const { - return intent_; +TextureCoordinateSystem Texture::GetCoordinateSystem() const { + return coordinate_system_; } Scalar Texture::GetYCoordScale() const { diff --git a/engine/src/flutter/impeller/core/texture.h b/engine/src/flutter/impeller/core/texture.h index 462888b592..7da171f6c9 100644 --- a/engine/src/flutter/impeller/core/texture.h +++ b/engine/src/flutter/impeller/core/texture.h @@ -39,9 +39,9 @@ class Texture { const TextureDescriptor& GetTextureDescriptor() const; - void SetIntent(TextureIntent intent); + void SetCoordinateSystem(TextureCoordinateSystem coordinate_system); - TextureIntent GetIntent() const; + TextureCoordinateSystem GetCoordinateSystem() const; virtual Scalar GetYCoordScale() const; @@ -61,7 +61,8 @@ class Texture { bool mipmap_generated_ = false; private: - TextureIntent intent_ = TextureIntent::kRenderToTexture; + TextureCoordinateSystem coordinate_system_ = + TextureCoordinateSystem::kRenderToTexture; const TextureDescriptor desc_; bool is_opaque_ = false; diff --git a/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc b/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc index 2fb2299b94..ee0d2a9c12 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc +++ b/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc @@ -512,10 +512,10 @@ bool TextureGLES::SetAsFramebufferAttachment(GLenum target, // |Texture| Scalar TextureGLES::GetYCoordScale() const { - switch (GetIntent()) { - case TextureIntent::kUploadFromHost: + switch (GetCoordinateSystem()) { + case TextureCoordinateSystem::kUploadFromHost: return 1.0; - case TextureIntent::kRenderToTexture: + case TextureCoordinateSystem::kRenderToTexture: return -1.0; } FML_UNREACHABLE(); diff --git a/engine/src/flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc b/engine/src/flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc index ffdfbe947b..58e2e9faba 100644 --- a/engine/src/flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc +++ b/engine/src/flutter/shell/platform/android/hardware_buffer_external_texture_gl.cc @@ -153,7 +153,8 @@ void HardwareBufferExternalTextureImpellerGL::ProcessFrame( auto texture = std::make_shared( impeller_context_->GetReactor(), desc, impeller::TextureGLES::IsWrapped::kWrapped); - texture->SetIntent(impeller::TextureIntent::kUploadFromHost); + texture->SetCoordinateSystem( + impeller::TextureCoordinateSystem::kUploadFromHost); if (!texture->Bind()) { FML_LOG(ERROR) << "Could not bind texture."; NDKHelpers::AHardwareBuffer_release(latest_hardware_buffer); diff --git a/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm b/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm index 3e2a8c2eb6..9c0190e827 100644 --- a/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm +++ b/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm @@ -196,7 +196,7 @@ FLUTTER_ASSERT_ARC yDesc.size = {textureSize.width(), textureSize.height()}; yDesc.mip_count = 1; auto yTexture = impeller::TextureMTL::Wrapper(yDesc, yTex); - yTexture->SetIntent(impeller::TextureIntent::kUploadFromHost); + yTexture->SetCoordinateSystem(impeller::TextureCoordinateSystem::kUploadFromHost); impeller::TextureDescriptor uvDesc; uvDesc.storage_mode = impeller::StorageMode::kHostVisible; @@ -204,7 +204,7 @@ FLUTTER_ASSERT_ARC uvDesc.size = {textureSize.width() / 2, textureSize.height() / 2}; uvDesc.mip_count = 1; auto uvTexture = impeller::TextureMTL::Wrapper(uvDesc, uvTex); - uvTexture->SetIntent(impeller::TextureIntent::kUploadFromHost); + uvTexture->SetCoordinateSystem(impeller::TextureCoordinateSystem::kUploadFromHost); impeller::YUVColorSpace yuvColorSpace = _pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange @@ -263,7 +263,7 @@ FLUTTER_ASSERT_ARC desc.size = {textureSize.width(), textureSize.height()}; desc.mip_count = 1; auto texture = impeller::TextureMTL::Wrapper(desc, rgbaTex); - texture->SetIntent(impeller::TextureIntent::kUploadFromHost); + texture->SetCoordinateSystem(impeller::TextureCoordinateSystem::kUploadFromHost); return impeller::DlImageImpeller::Make(texture); }