Flutter Engine
The Flutter Engine
Static Public Member Functions | List of all members
FilterResultTestAccess Class Reference

Static Public Member Functions

static void Draw (const skif::Context &ctx, SkDevice *device, const skif::FilterResult &image, bool preserveDeviceState)
 
static sk_sp< SkShaderAsShader (const skif::Context &ctx, const skif::FilterResult &image, const skif::LayerSpace< SkIRect > &sampleBounds)
 
static sk_sp< SkShaderStrictShader (const skif::Context &ctx, const skif::FilterResult &image)
 
static skif::FilterResult Rescale (const skif::Context &ctx, const skif::FilterResult &image, const skif::LayerSpace< SkSize > scale)
 
static void TrackStats (skif::Context *ctx, skif::Stats *stats)
 
static bool IsIntegerTransform (const skif::FilterResult &image)
 
static std::optional< std::pair< float, float > > DeferredScaleFactors (const skif::FilterResult &image)
 
static bool IsShaderTilingExpected (const skif::Context &ctx, const skif::FilterResult &image)
 
static bool IsShaderClampingExpected (const skif::Context &ctx, const skif::FilterResult &image)
 

Detailed Description

Definition at line 78 of file FilterResultTest.cpp.

Member Function Documentation

◆ AsShader()

static sk_sp< SkShader > FilterResultTestAccess::AsShader ( const skif::Context ctx,
const skif::FilterResult image,
const skif::LayerSpace< SkIRect > &  sampleBounds 
)
inlinestatic

Definition at line 88 of file FilterResultTest.cpp.

90 {
91 return image.asShader(ctx, FilterResult::kDefaultSampling,
93 }
sk_sp< const SkImage > image
Definition: SkRecords.h:269
@ kNone
Definition: layer.h:53

◆ DeferredScaleFactors()

static std::optional< std::pair< float, float > > FilterResultTestAccess::DeferredScaleFactors ( const skif::FilterResult image)
inlinestatic

Definition at line 130 of file FilterResultTest.cpp.

131 {
132 float scaleFactors[2];
133 if (SkMatrix(image.fTransform).getMinMaxScales(scaleFactors)) {
134 return {{scaleFactors[0], scaleFactors[1]}};
135 } else {
136 return {};
137 }
138 }
bool getMinMaxScales(SkScalar scaleFactors[2]) const
Definition: SkMatrix.cpp:1540

◆ Draw()

static void FilterResultTestAccess::Draw ( const skif::Context ctx,
SkDevice device,
const skif::FilterResult image,
bool  preserveDeviceState 
)
inlinestatic

Definition at line 81 of file FilterResultTest.cpp.

84 {
85 image.draw(ctx, device, preserveDeviceState, /*blender=*/nullptr);
86 }
VkDevice device
Definition: main.cc:53

◆ IsIntegerTransform()

static bool FilterResultTestAccess::IsIntegerTransform ( const skif::FilterResult image)
inlinestatic

Definition at line 123 of file FilterResultTest.cpp.

123 {
124 SkMatrix m = SkMatrix(image.fTransform);
125 return m.isTranslate() &&
126 SkScalarIsInt(m.getTranslateX()) &&
127 SkScalarIsInt(m.getTranslateY());
128 }
static bool SkScalarIsInt(SkScalar x)
Definition: SkScalar.h:80

◆ IsShaderClampingExpected()

static bool FilterResultTestAccess::IsShaderClampingExpected ( const skif::Context ctx,
const skif::FilterResult image 
)
inlinestatic

Definition at line 161 of file FilterResultTest.cpp.

162 {
163 auto analysis = image.analyzeBounds(ctx.desiredOutput());
164 if (analysis & BoundsAnalysis::kHasLayerFillingEffect) {
165 // The image won't be drawn directly so some form of shader is needed. The faster clamp
166 // can be used when clamping explicitly or decal-with-transparent-padding.
167 if (image.tileMode() == SkTileMode::kClamp ||
168 (image.tileMode() == SkTileMode::kDecal &&
170 return true;
171 } else {
172 // These cases should be covered by the more expensive shader tiling.
174 return false;
175 }
176 }
177 // If we got here, it will be drawn directly but a clamp can be needed if the data outside
178 // the image is unknown and sampling might pull those values in accidentally.
180 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool IsShaderTilingExpected(const skif::Context &ctx, const skif::FilterResult &image)
const LayerSpace< SkIRect > & desiredOutput() const
constexpr SkColor4f kTransparent
Definition: SkColor.h:434

◆ IsShaderTilingExpected()

static bool FilterResultTestAccess::IsShaderTilingExpected ( const skif::Context ctx,
const skif::FilterResult image 
)
inlinestatic

Definition at line 140 of file FilterResultTest.cpp.

141 {
142 if (image.tileMode() == SkTileMode::kClamp) {
143 return false;
144 }
145 if (image.tileMode() == SkTileMode::kDecal &&
147 return false;
148 }
149 auto analysis = image.analyzeBounds(ctx.desiredOutput());
150 if (!(analysis & BoundsAnalysis::kHasLayerFillingEffect)) {
151 return false;
152 }
153
154 // If we got here, it's either a mirror/repeat tile mode that's visible so a shader has to
155 // be used if the image isn't HW tileable; OR it's a decal tile mode without transparent
156 // padding that can't be drawn directly (in this case hasLayerFillingEffect implies a
157 // color filter that has to evaluate the decal'ed sampling).
158 return true;
159 }

◆ Rescale()

static skif::FilterResult FilterResultTestAccess::Rescale ( const skif::Context ctx,
const skif::FilterResult image,
const skif::LayerSpace< SkSize scale 
)
inlinestatic

Definition at line 113 of file FilterResultTest.cpp.

115 {
116 return image.rescale(ctx, scale, /*enforceDecal=*/false);
117 }
const Scalar scale

◆ StrictShader()

static sk_sp< SkShader > FilterResultTestAccess::StrictShader ( const skif::Context ctx,
const skif::FilterResult image 
)
inlinestatic

Definition at line 95 of file FilterResultTest.cpp.

96 {
97 auto analysis = image.analyzeBounds(ctx.desiredOutput());
98 if (analysis & FilterResult::BoundsAnalysis::kRequiresLayerCrop) {
99 // getAnalyzedShaderView() doesn't include the layer crop, this will be handled by
100 // the FilterResultImageResolver.
101 return nullptr;
102 } else {
103 // Add flags to ensure no deferred effects or clamping logic are optimized away.
104 analysis |= BoundsAnalysis::kDstBoundsNotCovered;
105 analysis |= BoundsAnalysis::kRequiresShaderTiling;
106 if (image.tileMode() == SkTileMode::kDecal) {
107 analysis |= BoundsAnalysis::kRequiresDecalInLayerSpace;
108 }
109 return image.getAnalyzedShaderView(ctx, image.sampling(), analysis);
110 }
111 }

◆ TrackStats()

static void FilterResultTestAccess::TrackStats ( skif::Context ctx,
skif::Stats stats 
)
inlinestatic

Definition at line 119 of file FilterResultTest.cpp.

119 {
120 ctx->fStats = stats;
121 }
dictionary stats
Definition: malisc.py:20

The documentation for this class was generated from the following file: