[Impeller] Remove Skia dependency from the impeller/image interface (flutter/engine#40403)

* [Impeller] Remove Skia dependency from the impeller/image interface

* Separate Skia backend target
This commit is contained in:
Brandon DeRosier
2023-03-17 22:36:14 -07:00
committed by GitHub
parent d56b53d0c6
commit 8d2fc17c58
9 changed files with 32 additions and 20 deletions

View File

@@ -54,7 +54,7 @@ group("impeller") {
"aiks",
"display_list",
"entity",
"image",
"image:image_skia_backend",
"renderer",
"renderer/backend",
"typographer",

View File

@@ -217,7 +217,7 @@ impeller_component("entity") {
":framebuffer_blend_entity_shaders",
":modern_entity_shaders",
"../archivist",
"../image",
"../image:image_skia_backend",
"../renderer",
"../scene",
"../typographer",

View File

@@ -11,8 +11,6 @@ impeller_component("image") {
]
sources = [
"backends/skia/compressed_image_skia.cc",
"backends/skia/compressed_image_skia.h",
"compressed_image.cc",
"decompressed_image.cc",
]
@@ -22,6 +20,20 @@ impeller_component("image") {
"../geometry",
]
deps = [ "//flutter/fml" ]
}
impeller_component("image_skia_backend") {
public = [ "backends/skia/compressed_image_skia.h" ]
sources = [ "backends/skia/compressed_image_skia.cc" ]
public_deps = [
":image",
"../base",
"../geometry",
]
deps = [
"//flutter/fml",
"//third_party/skia",
@@ -32,7 +44,7 @@ impeller_component("image_unittests") {
testonly = true
sources = []
deps = [
":image",
":image_skia_backend",
"//flutter/testing",
]
}

View File

@@ -14,6 +14,15 @@
namespace impeller {
std::shared_ptr<CompressedImage> CompressedImageSkia::Create(
std::shared_ptr<const fml::Mapping> allocation) {
// There is only one backend today.
if (!allocation) {
return nullptr;
}
return std::make_shared<CompressedImageSkia>(std::move(allocation));
}
CompressedImageSkia::CompressedImageSkia(
std::shared_ptr<const fml::Mapping> allocation)
: CompressedImage(std::move(allocation)) {}

View File

@@ -11,6 +11,9 @@ namespace impeller {
class CompressedImageSkia final : public CompressedImage {
public:
static std::shared_ptr<CompressedImage> Create(
std::shared_ptr<const fml::Mapping> allocation);
CompressedImageSkia(std::shared_ptr<const fml::Mapping> allocation);
~CompressedImageSkia() override;

View File

@@ -4,19 +4,8 @@
#include "impeller/image/compressed_image.h"
#include "impeller/image/backends/skia/compressed_image_skia.h"
namespace impeller {
std::shared_ptr<CompressedImage> CompressedImage::Create(
std::shared_ptr<const fml::Mapping> allocation) {
// There is only one backend today.
if (!allocation) {
return nullptr;
}
return std::make_shared<CompressedImageSkia>(std::move(allocation));
}
CompressedImage::CompressedImage(std::shared_ptr<const fml::Mapping> allocation)
: source_(std::move(allocation)) {}

View File

@@ -17,9 +17,6 @@ class ImageSource;
class CompressedImage {
public:
static std::shared_ptr<CompressedImage> Create(
std::shared_ptr<const fml::Mapping> allocation);
virtual ~CompressedImage();
[[nodiscard]] virtual DecompressedImage Decode() const = 0;

View File

@@ -45,6 +45,7 @@ impeller_component("playground") {
"../entity:framebuffer_blend_entity_shaders",
"../entity:modern_entity_shaders",
"../fixtures:shader_fixtures",
"../image:image_skia_backend",
"../renderer",
"../scene/shaders",
"imgui:imgui_impeller_backend",

View File

@@ -8,6 +8,7 @@
#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/renderer/command_buffer.h"
#include "impeller/runtime_stage/runtime_stage.h"
@@ -340,7 +341,7 @@ bool Playground::OpenPlaygroundHere(SinglePassCallback pass_callback) {
std::shared_ptr<CompressedImage> Playground::LoadFixtureImageCompressed(
std::shared_ptr<fml::Mapping> mapping) const {
auto compressed_image = CompressedImage::Create(std::move(mapping));
auto compressed_image = CompressedImageSkia::Create(std::move(mapping));
if (!compressed_image) {
VALIDATION_LOG << "Could not create compressed image.";
return nullptr;