Skip to content

Commit

Permalink
Migrate GrMipmapped->skgpu::Mipmapped (#45881)
Browse files Browse the repository at this point in the history
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].

<!-- Links -->
[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
  • Loading branch information
kjlubick committed Sep 15, 2023
1 parent bd765e9 commit 1c9e4f6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/web_ui/skwasm/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -90,7 +91,7 @@ class TextureSourceImageGenerator : public GrExternalTextureGenerator {

std::unique_ptr<GrExternalTexture> generateExternalTexture(
GrRecordingContext* context,
GrMipMapped mipmapped) override {
skgpu::Mipmapped mipmapped) override {
GrGLTextureInfo glInfo;
glInfo.fID = skwasm_createGlTextureFromTextureSource(
_textureSourceWrapper->getTextureSource(), fInfo.width(),
Expand Down
3 changes: 2 additions & 1 deletion shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -346,7 +347,7 @@ std::unique_ptr<Rasterizer::GpuImageResult> 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<SnapshotDelegate::GpuImageResult>(
GrBackendTexture(), nullptr, nullptr,
Expand Down
3 changes: 2 additions & 1 deletion shell/gpu/gpu_surface_metal_skia.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,7 +45,7 @@
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<int>(sample_cnt), color_type,
std::move(color_space), props, release_proc, release_context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -295,15 +296,15 @@ @implementation FlutterDarwinExternalTextureSkImageWrapper
GrBackendTexture skiaBackendTextures[2];
skiaBackendTextures[0] = GrBackendTexture(/*width=*/width,
/*height=*/height,
/*mipMapped=*/GrMipMapped::kNo,
/*mipMapped=*/skgpu::Mipmapped::kNo,
/*textureInfo=*/ySkiaTextureInfo);

GrMtlTextureInfo uvSkiaTextureInfo;
uvSkiaTextureInfo.fTexture = sk_cfp<const void*>{(__bridge_retained const void*)uvTex};

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);
Expand All @@ -324,7 +325,7 @@ GrYUVABackendTextures yuvaBackendTextures(yuvaInfo, skiaBackendTextures,

GrBackendTexture skiaBackendTexture(/*width=*/width,
/*height=*/height,
/*mipMapped=*/GrMipMapped ::kNo,
/*mipMapped=*/skgpu::Mipmapped ::kNo,
/*textureInfo=*/skiaTextureInfo);

return SkImages::BorrowTextureFrom(grContext, skiaBackendTexture, kTopLeft_GrSurfaceOrigin,
Expand Down
9 changes: 5 additions & 4 deletions shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -924,10 +925,10 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore(
sk_cfp<FlutterMetalTextureHandle> 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);
Expand Down
5 changes: 3 additions & 2 deletions shell/platform/embedder/tests/embedder_metal_unittests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -63,8 +64,8 @@
void* texture) {
GrMtlTextureInfo info;
info.fTexture.reset([(id<MTLTexture>)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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<SkSurface> surface = SkSurfaces::WrapBackendTexture(
context_.get(), backend_texture, kTopLeft_GrSurfaceOrigin, 1,
Expand Down
5 changes: 3 additions & 2 deletions testing/test_metal_surface_impl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -26,8 +27,8 @@

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<SkSurface> surface = SkSurfaces::WrapBackendTexture(
test_metal_context_.GetSkiaContext().get(), backend_texture, kTopLeft_GrSurfaceOrigin, 1,
Expand Down

0 comments on commit 1c9e4f6

Please sign in to comment.