From 7da278b05b1cdb9569fa3d1752e488b9b1118384 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Fri, 15 Sep 2023 11:48:20 -0400 Subject: [PATCH] Migrate GrMipmapped->skgpu::Mipmapped (flutter/engine#45881) Skia's Graphite and Ganesh backend coalesced two enums regarding mipmaps into one and deprecated the public Ganesh version. This migrates Flutter to use the preferred type. No functional changes expected. See also https://skia-review.googlesource.com/c/skia/+/753567 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- engine/src/flutter/lib/web_ui/skwasm/image.cpp | 3 ++- engine/src/flutter/shell/common/rasterizer.cc | 3 ++- engine/src/flutter/shell/gpu/gpu_surface_metal_skia.mm | 3 ++- .../darwin/graphics/FlutterDarwinExternalTextureMetal.mm | 7 ++++--- engine/src/flutter/shell/platform/embedder/embedder.cc | 9 +++++---- .../platform/embedder/tests/embedder_metal_unittests.mm | 5 +++-- .../tests/embedder_test_backingstore_producer.cc | 3 ++- engine/src/flutter/testing/test_metal_surface_impl.mm | 5 +++-- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/engine/src/flutter/lib/web_ui/skwasm/image.cpp b/engine/src/flutter/lib/web_ui/skwasm/image.cpp index 74df647625..0e7665d072 100644 --- a/engine/src/flutter/lib/web_ui/skwasm/image.cpp +++ b/engine/src/flutter/lib/web_ui/skwasm/image.cpp @@ -12,6 +12,7 @@ #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkPicture.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/ganesh/GrExternalTextureGenerator.h" @@ -90,7 +91,7 @@ class TextureSourceImageGenerator : public GrExternalTextureGenerator { std::unique_ptr generateExternalTexture( GrRecordingContext* context, - GrMipMapped mipmapped) override { + skgpu::Mipmapped mipmapped) override { GrGLTextureInfo glInfo; glInfo.fID = skwasm_createGlTextureFromTextureSource( _textureSourceWrapper->getTextureSource(), fInfo.width(), diff --git a/engine/src/flutter/shell/common/rasterizer.cc b/engine/src/flutter/shell/common/rasterizer.cc index 4ed0b2fb4f..9a7e6e1655 100644 --- a/engine/src/flutter/shell/common/rasterizer.cc +++ b/engine/src/flutter/shell/common/rasterizer.cc @@ -27,6 +27,7 @@ #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/encode/SkPngEncoder.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/GrTypes.h" @@ -346,7 +347,7 @@ std::unique_ptr Rasterizer::MakeSkiaGpuImage( GrBackendTexture texture = context->createBackendTexture( image_info.width(), image_info.height(), image_info.colorType(), - GrMipmapped::kNo, GrRenderable::kYes); + skgpu::Mipmapped::kNo, GrRenderable::kYes); if (!texture.isValid()) { result = std::make_unique( GrBackendTexture(), nullptr, nullptr, diff --git a/engine/src/flutter/shell/gpu/gpu_surface_metal_skia.mm b/engine/src/flutter/shell/gpu/gpu_surface_metal_skia.mm index ed884151d0..652891c9ac 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_metal_skia.mm +++ b/engine/src/flutter/shell/gpu/gpu_surface_metal_skia.mm @@ -24,6 +24,7 @@ #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurfaceProps.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h" #include "third_party/skia/include/ports/SkCFObject.h" @@ -44,7 +45,7 @@ sk_sp CreateSurfaceFromMetalTexture(GrDirectContext* context, SkSurface::ReleaseContext release_context) { GrMtlTextureInfo info; info.fTexture.reset([texture retain]); - GrBackendTexture backend_texture(texture.width, texture.height, GrMipmapped::kNo, info); + GrBackendTexture backend_texture(texture.width, texture.height, skgpu::Mipmapped::kNo, info); return SkSurfaces::WrapBackendTexture( context, backend_texture, origin, static_cast(sample_cnt), color_type, std::move(color_space), props, release_proc, release_context); diff --git a/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm b/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm index 9c0190e827..55ca7cb906 100644 --- a/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm +++ b/engine/src/flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.mm @@ -10,6 +10,7 @@ #include "third_party/skia/include/core/SkColorSpace.h" #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkYUVAInfo.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/GrYUVABackendTextures.h" @@ -295,7 +296,7 @@ FLUTTER_ASSERT_ARC GrBackendTexture skiaBackendTextures[2]; skiaBackendTextures[0] = GrBackendTexture(/*width=*/width, /*height=*/height, - /*mipMapped=*/GrMipMapped::kNo, + /*mipMapped=*/skgpu::Mipmapped::kNo, /*textureInfo=*/ySkiaTextureInfo); GrMtlTextureInfo uvSkiaTextureInfo; @@ -303,7 +304,7 @@ FLUTTER_ASSERT_ARC skiaBackendTextures[1] = GrBackendTexture(/*width=*/width, /*height=*/height, - /*mipMapped=*/GrMipMapped::kNo, + /*mipMapped=*/skgpu::Mipmapped::kNo, /*textureInfo=*/uvSkiaTextureInfo); SkYUVAInfo yuvaInfo(skiaBackendTextures[0].dimensions(), SkYUVAInfo::PlaneConfig::kY_UV, SkYUVAInfo::Subsampling::k444, colorSpace); @@ -324,7 +325,7 @@ FLUTTER_ASSERT_ARC GrBackendTexture skiaBackendTexture(/*width=*/width, /*height=*/height, - /*mipMapped=*/GrMipMapped ::kNo, + /*mipMapped=*/skgpu::Mipmapped ::kNo, /*textureInfo=*/skiaTextureInfo); return SkImages::BorrowTextureFrom(grContext, skiaBackendTexture, kTopLeft_GrSurfaceOrigin, diff --git a/engine/src/flutter/shell/platform/embedder/embedder.cc b/engine/src/flutter/shell/platform/embedder/embedder.cc index af32d9ffa3..eb6b4edb85 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder.cc +++ b/engine/src/flutter/shell/platform/embedder/embedder.cc @@ -20,6 +20,7 @@ #include "third_party/dart/runtime/bin/elf_loader.h" #include "third_party/dart/runtime/include/dart_native_api.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h" @@ -924,10 +925,10 @@ static sk_sp MakeSkSurfaceFromBackingStore( sk_cfp mtl_texture; mtl_texture.retain(metal->texture.texture); texture_info.fTexture = mtl_texture; - GrBackendTexture backend_texture(config.size.width, // - config.size.height, // - GrMipMapped::kNo, // - texture_info // + GrBackendTexture backend_texture(config.size.width, // + config.size.height, // + skgpu::Mipmapped::kNo, // + texture_info // ); SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry); diff --git a/engine/src/flutter/shell/platform/embedder/tests/embedder_metal_unittests.mm b/engine/src/flutter/shell/platform/embedder/tests/embedder_metal_unittests.mm index f3666d9fee..c23a6553a5 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_metal_unittests.mm +++ b/engine/src/flutter/shell/platform/embedder/tests/embedder_metal_unittests.mm @@ -21,6 +21,7 @@ #include "flutter/testing/testing.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h" @@ -63,8 +64,8 @@ static sk_sp GetSurfaceFromTexture(const sk_sp& skia void* texture) { GrMtlTextureInfo info; info.fTexture.reset([(id)texture retain]); - GrBackendTexture backend_texture(texture_size.width(), texture_size.height(), GrMipmapped::kNo, - info); + GrBackendTexture backend_texture(texture_size.width(), texture_size.height(), + skgpu::Mipmapped::kNo, info); return SkSurfaces::WrapBackendTexture(skia_context.get(), backend_texture, kTopLeft_GrSurfaceOrigin, 1, kBGRA_8888_SkColorType, diff --git a/engine/src/flutter/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc b/engine/src/flutter/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc index eb74388dac..0c67e3dcce 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc +++ b/engine/src/flutter/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc @@ -11,6 +11,7 @@ #include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h" #include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h" @@ -281,7 +282,7 @@ bool EmbedderTestBackingStoreProducer::CreateMTLTexture( GrMtlTextureInfo skia_texture_info; skia_texture_info.fTexture.reset(SkCFSafeRetain(texture_info.texture)); GrBackendTexture backend_texture(surface_size.width(), surface_size.height(), - GrMipmapped::kNo, skia_texture_info); + skgpu::Mipmapped::kNo, skia_texture_info); sk_sp surface = SkSurfaces::WrapBackendTexture( context_.get(), backend_texture, kTopLeft_GrSurfaceOrigin, 1, diff --git a/engine/src/flutter/testing/test_metal_surface_impl.mm b/engine/src/flutter/testing/test_metal_surface_impl.mm index 34878a9613..cf2c6931f8 100644 --- a/engine/src/flutter/testing/test_metal_surface_impl.mm +++ b/engine/src/flutter/testing/test_metal_surface_impl.mm @@ -15,6 +15,7 @@ #include "third_party/skia/include/core/SkRefCnt.h" #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/gpu/GpuTypes.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h" @@ -26,8 +27,8 @@ void TestMetalSurfaceImpl::Init(const TestMetalContext::TextureInfo& texture_inf GrMtlTextureInfo skia_texture_info; skia_texture_info.fTexture.reset([texture retain]); - GrBackendTexture backend_texture(surface_size.width(), surface_size.height(), GrMipmapped::kNo, - skia_texture_info); + GrBackendTexture backend_texture(surface_size.width(), surface_size.height(), + skgpu::Mipmapped::kNo, skia_texture_info); sk_sp surface = SkSurfaces::WrapBackendTexture( test_metal_context_.GetSkiaContext().get(), backend_texture, kTopLeft_GrSurfaceOrigin, 1,