Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 bool IsShaderTilingExpected (const skif::Context &ctx, const skif::FilterResult &image, bool rescaling)
 
static bool IsShaderClampingExpected (const skif::Context &ctx, const skif::FilterResult &image, bool rescaling)
 

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,
92 FilterResult::ShaderFlags::kNone, sampleBounds);
93 }
static constexpr SkSamplingOptions kDefaultSampling
sk_sp< SkImage > image
Definition examples.cpp:29

◆ 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,
bool  rescaling 
)
inlinestatic

Definition at line 156 of file FilterResultTest.cpp.

158 {
159 auto analysis = image.analyzeBounds(ctx.desiredOutput());
160 if (analysis & BoundsAnalysis::kHasLayerFillingEffect ||
161 (image.tileMode() == SkTileMode::kDecal && rescaling)) {
162 // The image won't be drawn directly so some form of shader is needed. The faster clamp
163 // can be used when clamping explicitly or decal-with-transparent-padding.
164 // TODO(b/323886180): Once rescaling can draw decals directly, decal-with-transparent
165 // padding should only need clamping when there's a layer-filling color filter as well.
166 if (image.tileMode() == SkTileMode::kClamp ||
167 (image.tileMode() == SkTileMode::kDecal &&
168 image.fBoundary == FilterResult::PixelBoundary::kTransparent)) {
169 return true;
170 } else {
171 // These cases should be covered by the more expensive shader tiling, but if we
172 // are rescaling with a deferrable tile mode, it can still be converted to a clamp.
173 SkASSERT(IsShaderTilingExpected(ctx, image, rescaling));
174 return rescaling;
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.
179 return image.fBoundary == FilterResult::PixelBoundary::kUnknown;
180 }
#define SkASSERT(cond)
Definition SkAssert.h:116
static bool IsShaderTilingExpected(const skif::Context &ctx, const skif::FilterResult &image, bool rescaling)
const LayerSpace< SkIRect > & desiredOutput() const

◆ IsShaderTilingExpected()

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

Definition at line 130 of file FilterResultTest.cpp.

132 {
133 if (image.tileMode() == SkTileMode::kClamp) {
134 return false;
135 }
136 if (image.tileMode() == SkTileMode::kDecal &&
137 image.fBoundary == FilterResult::PixelBoundary::kTransparent) {
138 return false;
139 }
140 auto analysis = image.analyzeBounds(ctx.desiredOutput());
141 if (!(analysis & BoundsAnalysis::kHasLayerFillingEffect) &&
142 (image.tileMode() == SkTileMode::kRepeat || image.tileMode() == SkTileMode::kMirror ||
143 (image.tileMode() == SkTileMode::kDecal && !rescaling))) {
144 return false;
145 }
146
147 // If we got here, it's either a mirror/repeat tile mode that's visible so a shader has to
148 // be used if the image isn't HW tileable; OR it's a decal tile mode without transparent
149 // padding that can't be drawn directly (in this case hasLayerFillingEffect implies a
150 // color filter that has to evaluate the decal'ed sampling).
151 // TODO(b/323886180): Rescaling with decal images does not draw directly but should, so it
152 // will eventually avoid the expensive decal shader.
153 return true;
154 }

◆ 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 }
dict stats
Definition malisc.py:20

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