This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,23 @@ ScopedObject<ColorSource> ColorSource::MakeSweepGradient(
102
102
return Create<ColorSource>(std::move (dl_filter));
103
103
}
104
104
105
+ ScopedObject<ColorSource> ColorSource::MakeImage (
106
+ const Texture& image,
107
+ flutter::DlTileMode horizontal_tile_mode,
108
+ flutter::DlTileMode vertical_tile_mode,
109
+ flutter::DlImageSampling sampling,
110
+ const Matrix& transformation) {
111
+ const auto sk_transformation = ToSkMatrix (transformation);
112
+ auto dl_filter =
113
+ std::make_shared<flutter::DlImageColorSource>(image.MakeImage (), //
114
+ horizontal_tile_mode, //
115
+ vertical_tile_mode, //
116
+ sampling, //
117
+ &sk_transformation //
118
+ );
119
+ return Create<ColorSource>(std::move (dl_filter));
120
+ }
121
+
105
122
ColorSource::ColorSource (std::shared_ptr<flutter::DlColorSource> source)
106
123
: color_source_(std::move(source)) {}
107
124
Original file line number Diff line number Diff line change 14
14
#include " impeller/toolkit/interop/formats.h"
15
15
#include " impeller/toolkit/interop/impeller.h"
16
16
#include " impeller/toolkit/interop/object.h"
17
+ #include " impeller/toolkit/interop/texture.h"
17
18
18
19
namespace impeller ::interop {
19
20
@@ -56,6 +57,13 @@ class ColorSource final
56
57
flutter::DlTileMode tile_mode,
57
58
const Matrix& transformation);
58
59
60
+ static ScopedObject<ColorSource> MakeImage (
61
+ const Texture& image,
62
+ flutter::DlTileMode horizontal_tile_mode,
63
+ flutter::DlTileMode vertical_tile_mode,
64
+ flutter::DlImageSampling sampling,
65
+ const Matrix& transformation);
66
+
59
67
explicit ColorSource (std::shared_ptr<flutter::DlColorSource> source);
60
68
61
69
~ColorSource () override ;
Original file line number Diff line number Diff line change @@ -778,6 +778,24 @@ ImpellerColorSource ImpellerColorSourceCreateSweepGradientNew(
778
778
.Leak ();
779
779
}
780
780
781
+ IMPELLER_EXTERN_C
782
+ ImpellerColorSource ImpellerColorSourceCreateImageNew (
783
+ ImpellerTexture image,
784
+ ImpellerTileMode horizontal_tile_mode,
785
+ ImpellerTileMode vertical_tile_mode,
786
+ ImpellerTextureSampling sampling,
787
+ const ImpellerMatrix* transformation) {
788
+ return ColorSource::MakeImage (
789
+ *GetPeer (image), //
790
+ ToDisplayListType (horizontal_tile_mode), //
791
+ ToDisplayListType (vertical_tile_mode), //
792
+ ToDisplayListType (sampling), //
793
+ transformation == nullptr ? Matrix{}
794
+ : ToImpellerType (*transformation) //
795
+ )
796
+ .Leak ();
797
+ }
798
+
781
799
IMPELLER_EXTERN_C
782
800
void ImpellerColorFilterRetain (ImpellerColorFilter color_filter) {
783
801
ObjectBase::SafeRetain (color_filter);
Original file line number Diff line number Diff line change @@ -552,6 +552,14 @@ ImpellerColorSourceCreateSweepGradientNew(
552
552
ImpellerTileMode tile_mode ,
553
553
const ImpellerMatrix * IMPELLER_NULLABLE transformation );
554
554
555
+ IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerColorSource IMPELLER_NULLABLE
556
+ ImpellerColorSourceCreateImageNew (
557
+ ImpellerTexture IMPELLER_NONNULL image ,
558
+ ImpellerTileMode horizontal_tile_mode ,
559
+ ImpellerTileMode vertical_tile_mode ,
560
+ ImpellerTextureSampling sampling ,
561
+ const ImpellerMatrix * IMPELLER_NULLABLE transformation );
562
+
555
563
//------------------------------------------------------------------------------
556
564
// Color Filters
557
565
//------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments