Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
skif Namespace Reference

Classes

class  Backend
 
class  Context
 
class  DeviceSpace
 
class  FilterResult
 
struct  IVector
 
class  LayerSpace
 
class  LayerSpace< IVector >
 
class  LayerSpace< SkIPoint >
 
class  LayerSpace< SkIRect >
 
class  LayerSpace< SkISize >
 
class  LayerSpace< SkMatrix >
 
class  LayerSpace< SkPoint >
 
class  LayerSpace< SkRect >
 
class  LayerSpace< SkSize >
 
class  LayerSpace< Vector >
 
class  LayerSpace< ZValue >
 
class  Mapping
 
class  ParameterSpace
 
struct  Stats
 
struct  Vector
 

Typedefs

template<typename T >
using PixelSpace = LayerSpace< T >
 

Enumerations

enum class  MatrixCapability { kTranslate , kScaleTranslate , kComplex }
 

Functions

sk_sp< BackendMakeRasterBackend (const SkSurfaceProps &surfaceProps, SkColorType colorType)
 
SkIRect RoundOut (SkRect r)
 
SkIRect RoundIn (SkRect r)
 
static bool compatible_sampling (const SkSamplingOptions &currentSampling, bool currentXformWontAffectNearest, SkSamplingOptions *nextSampling, bool nextXformWontAffectNearest)
 
static int downscale_step_count (float netScaleFactor)
 
sk_sp< BackendMakeGaneshBackend (sk_sp< GrRecordingContext > context, GrSurfaceOrigin origin, const SkSurfaceProps &surfaceProps, SkColorType colorType)
 

Typedef Documentation

◆ PixelSpace

template<typename T >
using skif::PixelSpace = typedef LayerSpace<T>

Definition at line 1471 of file SkImageFilterTypes.cpp.

Enumeration Type Documentation

◆ MatrixCapability

enum class skif::MatrixCapability
strong

Most ImageFilters can natively handle scaling and translate components in the CTM. Only some of them can handle affine (or more complex) matrices. Some may only handle translation.

Enumerator
kTranslate 
kScaleTranslate 
kComplex 

Definition at line 545 of file SkImageFilterTypes.h.

545 {
546 kTranslate,
548 kComplex,
549};

Function Documentation

◆ compatible_sampling()

static bool skif::compatible_sampling ( const SkSamplingOptions currentSampling,
bool  currentXformWontAffectNearest,
SkSamplingOptions nextSampling,
bool  nextXformWontAffectNearest 
)
static

Definition at line 987 of file SkImageFilterTypes.cpp.

990 {
991 // Both transforms could perform non-trivial sampling, but if they are similar enough we
992 // assume performing one non-trivial sampling operation with the concatenated transform will
993 // not be visually distinguishable from sampling twice.
994 // TODO(michaelludwig): For now ignore mipmap policy, SkSpecialImages are not supposed to be
995 // drawn with mipmapping, and the majority of filter steps produce images that are at the
996 // proper scale and do not define mip levels. The main exception is the ::Image() filter
997 // leaf but that doesn't use this system yet.
998 if (currentSampling.isAniso() && nextSampling->isAniso()) {
999 // Assume we can get away with one sampling at the highest anisotropy level
1000 *nextSampling = SkSamplingOptions::Aniso(std::max(currentSampling.maxAniso,
1001 nextSampling->maxAniso));
1002 return true;
1003 } else if (currentSampling.isAniso() && nextSampling->filter == SkFilterMode::kLinear) {
1004 // Assume we can get away with the current anisotropic filter since the next is linear
1005 *nextSampling = currentSampling;
1006 return true;
1007 } else if (nextSampling->isAniso() && currentSampling.filter == SkFilterMode::kLinear) {
1008 // Mirror of the above, assume we can just get away with next's anisotropic filter
1009 return true;
1010 } else if (currentSampling.useCubic && (nextSampling->filter == SkFilterMode::kLinear ||
1011 (nextSampling->useCubic &&
1012 currentSampling.cubic.B == nextSampling->cubic.B &&
1013 currentSampling.cubic.C == nextSampling->cubic.C))) {
1014 // Assume we can get away with the current bicubic filter, since the next is the same
1015 // or a bilerp that can be upgraded.
1016 *nextSampling = currentSampling;
1017 return true;
1018 } else if (nextSampling->useCubic && currentSampling.filter == SkFilterMode::kLinear) {
1019 // Mirror of the above, assume we can just get away with next's cubic resampler
1020 return true;
1021 } else if (currentSampling.filter == SkFilterMode::kLinear &&
1022 nextSampling->filter == SkFilterMode::kLinear) {
1023 // Assume we can get away with a single bilerp vs. the two
1024 return true;
1025 } else if (nextSampling->filter == SkFilterMode::kNearest && currentXformWontAffectNearest) {
1026 // The next transform and nearest-neighbor filtering isn't impacted by the current transform
1027 SkASSERT(currentSampling.filter == SkFilterMode::kLinear);
1028 return true;
1029 } else if (currentSampling.filter == SkFilterMode::kNearest && nextXformWontAffectNearest) {
1030 // The next transform doesn't change the nearest-neighbor filtering of the current transform
1031 SkASSERT(nextSampling->filter == SkFilterMode::kLinear);
1032 *nextSampling = currentSampling;
1033 return true;
1034 } else {
1035 // The current or next sampling is nearest neighbor, and will produce visible texels
1036 // oriented with the current transform; assume this is a desired effect and preserve it.
1037 return false;
1038 }
1039}
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr SkSamplingOptions Aniso(int maxAniso)
const SkCubicResampler cubic
const SkFilterMode filter

◆ downscale_step_count()

static int skif::downscale_step_count ( float  netScaleFactor)
static

Definition at line 1445 of file SkImageFilterTypes.cpp.

1445 {
1446 int steps = SkNextLog2(sk_float_ceil2int(1.f / netScaleFactor));
1447 // There are (steps-1) 1/2x steps and then one step that will be between 1/2-1x. If the
1448 // final step is practically the identity scale, we can save a render pass and not incur too
1449 // much sampling error by reducing the step count and using a final scale that's slightly less
1450 // than 1/2.
1451 if (steps > 0) {
1452 // For a multipass rescale, we allow for a lot of tolerance when deciding to collapse the
1453 // final step. If there's only a single pass, we require the scale factor to be very close
1454 // to the identity since it causes the step count to go to 0.
1455 static constexpr float kMultiPassLimit = 0.8f;
1456 static constexpr float kNearIdentityLimit = 1.f - kRoundEpsilon; // 1px error in 1000px img
1457
1458 float finalStepScale = netScaleFactor * (1 << (steps - 1));
1459 float limit = steps == 1 ? kNearIdentityLimit : kMultiPassLimit;
1460 if (finalStepScale >= limit) {
1461 steps--;
1462 }
1463 }
1464
1465 return steps;
1466}
#define sk_float_ceil2int(x)
static int SkNextLog2(uint32_t value)
Definition SkMathPriv.h:238

◆ MakeGaneshBackend()

sk_sp< Backend > skif::MakeGaneshBackend ( sk_sp< GrRecordingContext context,
GrSurfaceOrigin  origin,
const SkSurfaceProps surfaceProps,
SkColorType  colorType 
)

Definition at line 853 of file GrImageUtils.cpp.

856 {
857 SkASSERT(context);
858 return sk_make_sp<GaneshBackend>(std::move(context), origin, surfaceProps, colorType);
859}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ MakeRasterBackend()

sk_sp< Backend > skif::MakeRasterBackend ( const SkSurfaceProps surfaceProps,
SkColorType  colorType 
)

Definition at line 218 of file SkImageFilterTypes.cpp.

218 {
219 // TODO (skbug:14286): Remove this forcing to 8888. Many legacy image filters only support
220 // N32 on CPU, but once they are implemented in terms of draws and SkSL they will support
221 // all color types, like the GPU backends.
222 colorType = kN32_SkColorType;
223
224 return sk_make_sp<RasterBackend>(surfaceProps, colorType);
225}

◆ RoundIn()

SkIRect skif::RoundIn ( SkRect  r)

Definition at line 255 of file SkImageFilterTypes.cpp.

255{ return r.makeOutset(kRoundEpsilon, kRoundEpsilon).roundIn(); }
void roundIn(SkIRect *dst) const
Definition SkRect.h:1266
SkRect makeOutset(float dx, float dy) const
Definition SkRect.h:1002

◆ RoundOut()

SkIRect skif::RoundOut ( SkRect  r)

Definition at line 253 of file SkImageFilterTypes.cpp.

253{ return r.makeInset(kRoundEpsilon, kRoundEpsilon).roundOut(); }
SkRect makeInset(float dx, float dy) const
Definition SkRect.h:987
void roundOut(SkIRect *dst) const
Definition SkRect.h:1241