Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,8 @@ FILE: ../../../flutter/impeller/entity/contents/filters/morphology_filter_conten
FILE: ../../../flutter/impeller/entity/contents/filters/morphology_filter_contents.h
FILE: ../../../flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc
FILE: ../../../flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.h
FILE: ../../../flutter/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc
FILE: ../../../flutter/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.h
FILE: ../../../flutter/impeller/entity/contents/gradient_generator.cc
FILE: ../../../flutter/impeller/entity/contents/gradient_generator.h
FILE: ../../../flutter/impeller/entity/contents/linear_gradient_contents.cc
Expand Down Expand Up @@ -1301,6 +1303,8 @@ FILE: ../../../flutter/impeller/entity/shaders/texture_fill.vert
FILE: ../../../flutter/impeller/entity/shaders/tiled_texture_fill.frag
FILE: ../../../flutter/impeller/entity/shaders/tiled_texture_fill.vert
FILE: ../../../flutter/impeller/entity/shaders/vertices.frag
FILE: ../../../flutter/impeller/entity/shaders/yuv_to_rgb_filter.frag
FILE: ../../../flutter/impeller/entity/shaders/yuv_to_rgb_filter.vert
FILE: ../../../flutter/impeller/geometry/color.cc
FILE: ../../../flutter/impeller/geometry/color.h
FILE: ../../../flutter/impeller/geometry/constants.cc
Expand Down
5 changes: 5 additions & 0 deletions common/graphics/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

class GrDirectContext;

namespace impeller {
class AiksContext;
};

namespace flutter {

class ContextListener {
Expand All @@ -39,6 +43,7 @@ class Texture : public ContextListener {
SkCanvas* canvas = nullptr;
DisplayListBuilder* builder = nullptr;
GrDirectContext* gr_context = nullptr;
impeller::AiksContext* aiks_context = nullptr;
const SkPaint* sk_paint = nullptr;
const DlPaint* dl_paint = nullptr;
};
Expand Down
9 changes: 6 additions & 3 deletions flow/compositor_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ std::unique_ptr<CompositorContext::ScopedFrame> CompositorContext::AcquireFrame(
bool surface_supports_readback,
fml::RefPtr<fml::RasterThreadMerger>
raster_thread_merger, // NOLINT(performance-unnecessary-value-param)
DisplayListBuilder* display_list_builder) {
DisplayListBuilder* display_list_builder,
impeller::AiksContext* aiks_context) {
return std::make_unique<ScopedFrame>(
*this, gr_context, canvas, view_embedder, root_surface_transformation,
instrumentation_enabled, surface_supports_readback, raster_thread_merger,
display_list_builder);
display_list_builder, aiks_context);
}

CompositorContext::ScopedFrame::ScopedFrame(
Expand All @@ -99,11 +100,13 @@ CompositorContext::ScopedFrame::ScopedFrame(
bool instrumentation_enabled,
bool surface_supports_readback,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger,
DisplayListBuilder* display_list_builder)
DisplayListBuilder* display_list_builder,
impeller::AiksContext* aiks_context)
: context_(context),
gr_context_(gr_context),
canvas_(canvas),
display_list_builder_(display_list_builder),
aiks_context_(aiks_context),
view_embedder_(view_embedder),
root_surface_transformation_(root_surface_transformation),
instrumentation_enabled_(instrumentation_enabled),
Expand Down
9 changes: 7 additions & 2 deletions flow/compositor_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class CompositorContext {
bool instrumentation_enabled,
bool surface_supports_readback,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger,
DisplayListBuilder* display_list_builder);
DisplayListBuilder* display_list_builder,
impeller::AiksContext* aiks_context);

virtual ~ScopedFrame();

Expand All @@ -136,6 +137,8 @@ class CompositorContext {

GrDirectContext* gr_context() const { return gr_context_; }

impeller::AiksContext* aiks_context() const { return aiks_context_; }

virtual RasterStatus Raster(LayerTree& layer_tree,
bool ignore_raster_cache,
FrameDamage* frame_damage);
Expand All @@ -145,6 +148,7 @@ class CompositorContext {
GrDirectContext* gr_context_;
SkCanvas* canvas_;
DisplayListBuilder* display_list_builder_;
impeller::AiksContext* aiks_context_;
ExternalViewEmbedder* view_embedder_;
const SkMatrix& root_surface_transformation_;
const bool instrumentation_enabled_;
Expand All @@ -168,7 +172,8 @@ class CompositorContext {
bool instrumentation_enabled,
bool surface_supports_readback,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger,
DisplayListBuilder* display_list_builder);
DisplayListBuilder* display_list_builder,
impeller::AiksContext* aiks_context);

void OnGrContextCreated();

Expand Down
1 change: 1 addition & 0 deletions flow/layers/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ struct PaintContext {
SkScalar inherited_opacity = SK_Scalar1;
DisplayListBuilder* leaf_nodes_builder = nullptr;
DisplayListBuilderMultiplexer* builder_multiplexer = nullptr;
impeller::AiksContext* aiks_context;
};

// Represents a single composited layer. Created on the UI thread but then
Expand Down
1 change: 1 addition & 0 deletions flow/layers/layer_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
.inherited_opacity = SK_Scalar1,
.leaf_nodes_builder = builder,
.builder_multiplexer = builder ? &builder_multiplexer : nullptr,
.aiks_context = frame.aiks_context(),
// clang-format on
};

Expand Down
1 change: 1 addition & 0 deletions flow/layers/layer_tree_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class LayerTreeTest : public CanvasTest {
false,
true,
nullptr,
nullptr,
nullptr)) {}

LayerTree& layer_tree() { return layer_tree_; }
Expand Down
1 change: 1 addition & 0 deletions flow/layers/texture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void TextureLayer::Paint(PaintContext& context) const {
.canvas = context.leaf_nodes_canvas,
.builder = context.leaf_nodes_builder,
.gr_context = context.gr_context,
.aiks_context = context.aiks_context,
.sk_paint = cache_paint.sk_paint(),
.dl_paint = cache_paint.dl_paint(),
};
Expand Down
4 changes: 4 additions & 0 deletions impeller/aiks/aiks_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ std::shared_ptr<Context> AiksContext::GetContext() const {
return context_;
}

const ContentContext& AiksContext::GetContentContext() const {
return *content_context_;
}

bool AiksContext::Render(const Picture& picture, RenderTarget& render_target) {
if (!IsValid()) {
return false;
Expand Down
2 changes: 2 additions & 0 deletions impeller/aiks/aiks_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class AiksContext {

std::shared_ptr<Context> GetContext() const;

const ContentContext& GetContentContext() const;

bool Render(const Picture& picture, RenderTarget& render_target);

private:
Expand Down
20 changes: 20 additions & 0 deletions impeller/display_list/display_list_image_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include "impeller/display_list/display_list_image_impeller.h"

#include "impeller/aiks/aiks_context.h"
#include "impeller/entity/contents/filters/filter_contents.h"

namespace impeller {

sk_sp<DlImageImpeller> DlImageImpeller::Make(std::shared_ptr<Texture> texture) {
Expand All @@ -13,6 +16,23 @@ sk_sp<DlImageImpeller> DlImageImpeller::Make(std::shared_ptr<Texture> texture) {
return sk_sp<DlImageImpeller>(new DlImageImpeller(std::move(texture)));
}

sk_sp<DlImageImpeller> DlImageImpeller::MakeFromYUVTextures(
AiksContext* aiks_context,
std::shared_ptr<Texture> y_texture,
std::shared_ptr<Texture> uv_texture,
YUVColorSpace yuv_color_space) {
if (!aiks_context || !y_texture || !uv_texture) {
return nullptr;
}
auto yuv_to_rgb_filter_contents = FilterContents::MakeYUVToRGBFilter(
std::move(y_texture), std::move(uv_texture), yuv_color_space);
impeller::Entity entity;
entity.SetBlendMode(impeller::BlendMode::kSource);
auto snapshot = yuv_to_rgb_filter_contents->RenderToSnapshot(
aiks_context->GetContentContext(), entity);
return impeller::DlImageImpeller::Make(snapshot->texture);
}

DlImageImpeller::DlImageImpeller(std::shared_ptr<Texture> texture)
: texture_(std::move(texture)) {}

Expand Down
8 changes: 8 additions & 0 deletions impeller/display_list/display_list_image_impeller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@

namespace impeller {

class AiksContext;

class DlImageImpeller final : public flutter::DlImage {
public:
static sk_sp<DlImageImpeller> Make(std::shared_ptr<Texture> texture);

static sk_sp<DlImageImpeller> MakeFromYUVTextures(
AiksContext* aiks_context,
std::shared_ptr<Texture> y_texture,
std::shared_ptr<Texture> uv_texture,
YUVColorSpace yuv_color_space);

// |DlImage|
~DlImageImpeller() override;

Expand Down
4 changes: 4 additions & 0 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ impeller_shaders("entity_shaders") {
"shaders/tiled_texture_fill.frag",
"shaders/tiled_texture_fill.vert",
"shaders/vertices.frag",
"shaders/yuv_to_rgb_filter.frag",
"shaders/yuv_to_rgb_filter.vert",
]
}

Expand Down Expand Up @@ -106,6 +108,8 @@ impeller_component("entity") {
"contents/filters/morphology_filter_contents.h",
"contents/filters/srgb_to_linear_filter_contents.cc",
"contents/filters/srgb_to_linear_filter_contents.h",
"contents/filters/yuv_to_rgb_filter_contents.cc",
"contents/filters/yuv_to_rgb_filter_contents.h",
"contents/gradient_generator.cc",
"contents/gradient_generator.h",
"contents/linear_gradient_contents.cc",
Expand Down
2 changes: 2 additions & 0 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
geometry_position_pipelines_[{}] =
CreateDefaultPipeline<GeometryPositionPipeline>(*context_);
atlas_pipelines_[{}] = CreateDefaultPipeline<AtlasPipeline>(*context_);
yuv_to_rgb_filter_pipelines_[{}] =
CreateDefaultPipeline<YUVToRGBFilterPipeline>(*context_);

// Pipelines that are variants of the base pipelines with custom descriptors.
// TODO(98684): Rework this API to allow fetching the descriptor without
Expand Down
10 changes: 10 additions & 0 deletions impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#include "impeller/entity/tiled_texture_fill.frag.h"
#include "impeller/entity/tiled_texture_fill.vert.h"
#include "impeller/entity/vertices.frag.h"
#include "impeller/entity/yuv_to_rgb_filter.frag.h"
#include "impeller/entity/yuv_to_rgb_filter.vert.h"
#include "impeller/renderer/formats.h"
#include "impeller/renderer/pipeline.h"

Expand Down Expand Up @@ -160,6 +162,8 @@ using GeometryPositionPipeline =
RenderPipelineT<PositionVertexShader, VerticesFragmentShader>;
using GeometryColorPipeline =
RenderPipelineT<PositionColorVertexShader, VerticesFragmentShader>;
using YUVToRGBFilterPipeline =
RenderPipelineT<YuvToRgbFilterVertexShader, YuvToRgbFilterFragmentShader>;

struct ContentContextOptions {
SampleCount sample_count = SampleCount::kCount1;
Expand Down Expand Up @@ -299,6 +303,11 @@ class ContentContext {
return GetPipeline(atlas_pipelines_, opts);
}

std::shared_ptr<Pipeline<PipelineDescriptor>> GetYUVToRGBFilterPipeline(
ContentContextOptions opts) const {
return GetPipeline(yuv_to_rgb_filter_pipelines_, opts);
}

// Advanced blends.

std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorPipeline(
Expand Down Expand Up @@ -422,6 +431,7 @@ class ContentContext {
mutable Variants<AtlasPipeline> atlas_pipelines_;
mutable Variants<GeometryPositionPipeline> geometry_position_pipelines_;
mutable Variants<GeometryColorPipeline> geometry_color_pipelines_;
mutable Variants<YUVToRGBFilterPipeline> yuv_to_rgb_filter_pipelines_;
// Advanced blends.
mutable Variants<BlendColorPipeline> blend_color_pipelines_;
mutable Variants<BlendColorBurnPipeline> blend_colorburn_pipelines_;
Expand Down
12 changes: 12 additions & 0 deletions impeller/entity/contents/filters/filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "impeller/entity/contents/filters/local_matrix_filter_contents.h"
#include "impeller/entity/contents/filters/matrix_filter_contents.h"
#include "impeller/entity/contents/filters/morphology_filter_contents.h"
#include "impeller/entity/contents/filters/yuv_to_rgb_filter_contents.h"
#include "impeller/entity/contents/texture_contents.h"
#include "impeller/entity/entity.h"
#include "impeller/geometry/path_builder.h"
Expand Down Expand Up @@ -129,6 +130,17 @@ std::shared_ptr<FilterContents> FilterContents::MakeLocalMatrixFilter(
return filter;
}

std::shared_ptr<FilterContents> FilterContents::MakeYUVToRGBFilter(
std::shared_ptr<Texture> y_texture,
std::shared_ptr<Texture> uv_texture,
YUVColorSpace yuv_color_space) {
auto filter = std::make_shared<impeller::YUVToRGBFilterContents>();
filter->SetInputs({impeller::FilterInput::Make(y_texture),
impeller::FilterInput::Make(uv_texture)});
filter->SetYUVColorSpace(yuv_color_space);
return filter;
}

FilterContents::FilterContents() = default;

FilterContents::~FilterContents() = default;
Expand Down
5 changes: 5 additions & 0 deletions impeller/entity/contents/filters/filter_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ class FilterContents : public Contents {
FilterInput::Ref input,
const Matrix& matrix);

static std::shared_ptr<FilterContents> MakeYUVToRGBFilter(
std::shared_ptr<Texture> y_texture,
std::shared_ptr<Texture> uv_texture,
YUVColorSpace yuv_color_space);

FilterContents();

~FilterContents() override;
Expand Down
Loading