[Impeller] Move impeller/image to impeller/playground/image (flutter/engine#50480)

Deletes usage in Scene of this code, which was the only non-test location that used it.

This code imports Skia based code to decompress PNG images, and it's not clear when we'd need it outside of tests at this point.

It is otherwise a pretty thin wrapper around a texture allocation.

Fixes https://github.com/flutter/flutter/issues/143194
This commit is contained in:
Dan Field
2024-02-08 16:42:24 -08:00
committed by GitHub
parent c095d66749
commit e10db251ff
19 changed files with 34 additions and 67 deletions

View File

@@ -165,7 +165,6 @@
../../../flutter/impeller/geometry/size_unittests.cc
../../../flutter/impeller/geometry/trig_unittests.cc
../../../flutter/impeller/golden_tests/README.md
../../../flutter/impeller/image/README.md
../../../flutter/impeller/playground
../../../flutter/impeller/renderer/backend/gles/test
../../../flutter/impeller/renderer/backend/metal/texture_mtl_unittests.mm

View File

@@ -5307,12 +5307,6 @@ ORIGIN: ../../../flutter/impeller/golden_tests/vulkan_screenshotter.h + ../../..
ORIGIN: ../../../flutter/impeller/golden_tests/vulkan_screenshotter.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/golden_tests/working_directory.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/golden_tests/working_directory.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/image/compressed_image.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/image/compressed_image.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/image/decompressed_image.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/image/decompressed_image.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/gles/allocator_gles.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/gles/allocator_gles.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/gles/blit_command_gles.cc + ../../../flutter/LICENSE
@@ -8147,12 +8141,6 @@ FILE: ../../../flutter/impeller/golden_tests/vulkan_screenshotter.h
FILE: ../../../flutter/impeller/golden_tests/vulkan_screenshotter.mm
FILE: ../../../flutter/impeller/golden_tests/working_directory.cc
FILE: ../../../flutter/impeller/golden_tests/working_directory.h
FILE: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.cc
FILE: ../../../flutter/impeller/image/backends/skia/compressed_image_skia.h
FILE: ../../../flutter/impeller/image/compressed_image.cc
FILE: ../../../flutter/impeller/image/compressed_image.h
FILE: ../../../flutter/impeller/image/decompressed_image.cc
FILE: ../../../flutter/impeller/image/decompressed_image.h
FILE: ../../../flutter/impeller/renderer/backend/gles/allocator_gles.cc
FILE: ../../../flutter/impeller/renderer/backend/gles/allocator_gles.h
FILE: ../../../flutter/impeller/renderer/backend/gles/blit_command_gles.cc

View File

@@ -66,7 +66,6 @@ group("impeller") {
"aiks",
"display_list",
"entity",
"image:image_skia_backend",
"renderer",
"renderer/backend",
"typographer/backends/skia:typographer_skia_backend",
@@ -99,7 +98,6 @@ impeller_component("impeller_unittests") {
"entity:entity_unittests",
"fixtures",
"geometry:geometry_unittests",
"image:image_unittests",
"playground",
"renderer:renderer_unittests",
"scene:scene_unittests",

View File

@@ -45,7 +45,6 @@ impeller_component("core") {
deps = [
"../base",
"../geometry",
"../image",
"//flutter/fml",
]
}

View File

@@ -233,7 +233,6 @@ impeller_component("entity") {
":entity_shaders",
":framebuffer_blend_entity_shaders",
":modern_entity_shaders",
"../image:image_skia_backend",
"../renderer",
"../typographer",
]

View File

@@ -6,6 +6,8 @@ import("//flutter/impeller/tools/impeller.gni")
import("//flutter/testing/testing.gni")
impeller_component("playground") {
testonly = true
sources = [
"playground.cc",
"playground.h",
@@ -46,9 +48,9 @@ impeller_component("playground") {
public_deps = [
"../fixtures:shader_fixtures",
"../image:image_skia_backend",
"../renderer",
"../scene/shaders",
"image:image_skia_backend",
"imgui:imgui_impeller_backend",
"//flutter/fml",
"//flutter/third_party/glfw",

View File

@@ -5,6 +5,7 @@
import("//flutter/impeller/tools/impeller.gni")
impeller_component("image") {
testonly = true
public = [
"compressed_image.h",
"decompressed_image.h",
@@ -16,22 +17,23 @@ impeller_component("image") {
]
public_deps = [
"../base",
"../geometry",
"../../base",
"../../geometry",
]
deps = [ "//flutter/fml" ]
}
impeller_component("image_skia_backend") {
testonly = true
public = [ "backends/skia/compressed_image_skia.h" ]
sources = [ "backends/skia/compressed_image_skia.cc" ]
public_deps = [
":image",
"../base",
"../geometry",
"../../base",
"../../geometry",
]
deps = [
@@ -39,12 +41,3 @@ impeller_component("image_skia_backend") {
"//flutter/skia",
]
}
impeller_component("image_unittests") {
testonly = true
sources = []
deps = [
":image_skia_backend",
"//flutter/testing",
]
}

View File

@@ -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 "impeller/image/backends/skia/compressed_image_skia.h"
#include "impeller/playground/image/backends/skia/compressed_image_skia.h"
#include <memory>

View File

@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_IMPELLER_IMAGE_BACKENDS_SKIA_COMPRESSED_IMAGE_SKIA_H_
#define FLUTTER_IMPELLER_IMAGE_BACKENDS_SKIA_COMPRESSED_IMAGE_SKIA_H_
#ifndef FLUTTER_IMPELLER_PLAYGROUND_IMAGE_BACKENDS_SKIA_COMPRESSED_IMAGE_SKIA_H_
#define FLUTTER_IMPELLER_PLAYGROUND_IMAGE_BACKENDS_SKIA_COMPRESSED_IMAGE_SKIA_H_
#include "flutter/fml/macros.h"
#include "impeller/image/compressed_image.h"
#include "impeller/playground/image/compressed_image.h"
namespace impeller {
@@ -30,4 +30,4 @@ class CompressedImageSkia final : public CompressedImage {
} // namespace impeller
#endif // FLUTTER_IMPELLER_IMAGE_BACKENDS_SKIA_COMPRESSED_IMAGE_SKIA_H_
#endif // FLUTTER_IMPELLER_PLAYGROUND_IMAGE_BACKENDS_SKIA_COMPRESSED_IMAGE_SKIA_H_

View File

@@ -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 "impeller/image/compressed_image.h"
#include "impeller/playground/image/compressed_image.h"
namespace impeller {

View File

@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_IMPELLER_IMAGE_COMPRESSED_IMAGE_H_
#define FLUTTER_IMPELLER_IMAGE_COMPRESSED_IMAGE_H_
#ifndef FLUTTER_IMPELLER_PLAYGROUND_IMAGE_COMPRESSED_IMAGE_H_
#define FLUTTER_IMPELLER_PLAYGROUND_IMAGE_COMPRESSED_IMAGE_H_
#include <memory>
#include "flutter/fml/macros.h"
#include "flutter/fml/mapping.h"
#include "impeller/geometry/size.h"
#include "impeller/image/decompressed_image.h"
#include "impeller/playground/image/decompressed_image.h"
namespace impeller {
@@ -32,4 +32,4 @@ class CompressedImage {
} // namespace impeller
#endif // FLUTTER_IMPELLER_IMAGE_COMPRESSED_IMAGE_H_
#endif // FLUTTER_IMPELLER_PLAYGROUND_IMAGE_COMPRESSED_IMAGE_H_

View File

@@ -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 "impeller/image/decompressed_image.h"
#include "impeller/playground/image/decompressed_image.h"
#include <limits>

View File

@@ -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_IMPELLER_IMAGE_DECOMPRESSED_IMAGE_H_
#define FLUTTER_IMPELLER_IMAGE_DECOMPRESSED_IMAGE_H_
#ifndef FLUTTER_IMPELLER_PLAYGROUND_IMAGE_DECOMPRESSED_IMAGE_H_
#define FLUTTER_IMPELLER_PLAYGROUND_IMAGE_DECOMPRESSED_IMAGE_H_
#include <memory>
#include <optional>
@@ -51,4 +51,4 @@ class DecompressedImage {
} // namespace impeller
#endif // FLUTTER_IMPELLER_IMAGE_DECOMPRESSED_IMAGE_H_
#endif // FLUTTER_IMPELLER_PLAYGROUND_IMAGE_DECOMPRESSED_IMAGE_H_

View File

@@ -8,8 +8,8 @@
#include <sstream>
#include "fml/time/time_point.h"
#include "impeller/image/backends/skia/compressed_image_skia.h"
#include "impeller/image/decompressed_image.h"
#include "impeller/playground/image/backends/skia/compressed_image_skia.h"
#include "impeller/playground/image/decompressed_image.h"
#include "impeller/renderer/command_buffer.h"
#include "impeller/runtime_stage/runtime_stage.h"
@@ -20,8 +20,8 @@
#include "impeller/base/validation.h"
#include "impeller/core/allocator.h"
#include "impeller/core/formats.h"
#include "impeller/image/compressed_image.h"
#include "impeller/playground/backend/vulkan/swiftshader_utilities.h"
#include "impeller/playground/image/compressed_image.h"
#include "impeller/playground/imgui/imgui_impl_impeller.h"
#include "impeller/playground/playground.h"
#include "impeller/playground/playground_impl.h"

View File

@@ -15,8 +15,8 @@
#include "impeller/core/runtime_types.h"
#include "impeller/core/texture.h"
#include "impeller/geometry/point.h"
#include "impeller/image/compressed_image.h"
#include "impeller/image/decompressed_image.h"
#include "impeller/playground/image/compressed_image.h"
#include "impeller/playground/image/decompressed_image.h"
#include "impeller/playground/switches.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/renderer.h"

View File

@@ -104,7 +104,6 @@ impeller_component("renderer") {
"../base",
"../core",
"../geometry",
"../image",
"../runtime_stage",
"../tessellator",
]

View File

@@ -14,7 +14,6 @@
#include "impeller/base/thread.h"
#include "impeller/base/validation.h"
#include "impeller/geometry/matrix.h"
#include "impeller/image/decompressed_image.h"
#include "impeller/scene/animation/animation_player.h"
#include "impeller/scene/importer/conversions.h"
#include "impeller/scene/importer/scene_flatbuffers.h"
@@ -80,17 +79,12 @@ static std::shared_ptr<Texture> UnpackTextureFromFlatbuffer(
return nullptr;
}
DecompressedImage::Format format;
switch (embedded->component_count()) {
case 1:
format = DecompressedImage::Format::kGrey;
break;
case 3:
format = DecompressedImage::Format::kRGB;
break;
case 4:
format = DecompressedImage::Format::kRGBA;
// RGBA.
break;
case 1:
case 3:
default:
FML_LOG(WARNING) << "Textures with " << embedded->component_count()
<< " components are not supported." << std::endl;
@@ -106,15 +100,11 @@ static std::shared_ptr<Texture> UnpackTextureFromFlatbuffer(
auto image_mapping = std::make_shared<fml::NonOwnedMapping>(
embedded->bytes()->Data(), embedded->bytes()->size());
auto decompressed_image =
DecompressedImage(ISize(embedded->width(), embedded->height()), format,
image_mapping)
.ConvertToRGBA();
auto texture_descriptor = TextureDescriptor{};
texture_descriptor.storage_mode = StorageMode::kHostVisible;
texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt;
texture_descriptor.size = decompressed_image.GetSize();
texture_descriptor.size = ISize(embedded->width(), embedded->height());
// TODO(bdero): Generate mipmaps for embedded textures.
texture_descriptor.mip_count = 1u;
@@ -124,7 +114,7 @@ static std::shared_ptr<Texture> UnpackTextureFromFlatbuffer(
return nullptr;
}
auto uploaded = texture->SetContents(decompressed_image.GetAllocation());
auto uploaded = texture->SetContents(image_mapping);
if (!uploaded) {
FML_LOG(ERROR) << "Could not upload texture to device memory.";
return nullptr;

View File

@@ -14,7 +14,7 @@
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/quaternion.h"
#include "impeller/geometry/vector.h"
#include "impeller/image/decompressed_image.h"
#include "impeller/playground/image/decompressed_image.h"
#include "impeller/playground/playground.h"
#include "impeller/playground/playground_test.h"
#include "impeller/scene/animation/animation_clip.h"