Flutter Engine
The Flutter Engine
SkSamplingPriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkSamplingPriv_DEFINED
9#define SkSamplingPriv_DEFINED
10
12
13class SkReadBuffer;
14class SkWriteBuffer;
15
16// Given a src rect in texels to be filtered, this number of surrounding texels are needed by
17// the kernel in x and y.
18static constexpr int kBicubicFilterTexelPad = 2;
19
20// Private copy of SkFilterQuality, just for legacy deserialization
21// Matches values in SkFilterQuality
23 kNone_SkLegacyFQ = 0, //!< nearest-neighbor; fastest but lowest quality
24 kLow_SkLegacyFQ = 1, //!< bilerp
25 kMedium_SkLegacyFQ = 2, //!< bilerp + mipmaps; good for down-scaling
26 kHigh_SkLegacyFQ = 3, //!< bicubic resampling; slowest but good quality
27
29};
30
31// Matches values in SkSamplingOptions::MediumBehavior
35};
36
38public:
39 static size_t FlatSize(const SkSamplingOptions& options) {
40 size_t size = sizeof(uint32_t); // maxAniso
41 if (!options.isAniso()) {
42 size += 3 * sizeof(uint32_t); // bool32 + [2 floats | 2 ints]
43 }
44 return size;
45 }
46
47 // Returns true if the sampling can be ignored when the CTM is identity.
49 // If B == 0, the cubic resampler should have no effect for identity matrices
50 // https://entropymine.com/imageworsener/bicubic/
51 // We assume aniso has no effect with an identity transform.
52 return !sampling.useCubic || sampling.cubic.B == 0;
53 }
54
55 // Makes a fallback SkSamplingOptions for cases where anisotropic filtering is not allowed.
56 // anisotropic filtering can access mip levels if present, but we don't add mipmaps to non-
57 // mipmapped images when the user requests anisotropic. So we shouldn't fall back to a
58 // sampling that would trigger mip map creation.
59 static SkSamplingOptions AnisoFallback(bool imageIsMipped) {
60 auto mm = imageIsMipped ? SkMipmapMode::kLinear : SkMipmapMode::kNone;
62 }
63
65 switch (fq) {
67 return SkSamplingOptions(SkCubicResampler{1/3.0f, 1/3.0f});
72 case kLow_SkLegacyFQ:
75 break;
76 }
78 }
79};
80
81#endif
const char * options
static constexpr int kBicubicFilterTexelPad
SkMediumAs
@ kNearest_SkMediumAs
@ kLinear_SkMediumAs
SkLegacyFQ
@ kHigh_SkLegacyFQ
bicubic resampling; slowest but good quality
@ kLow_SkLegacyFQ
bilerp
@ kLast_SkLegacyFQ
@ kMedium_SkLegacyFQ
bilerp + mipmaps; good for down-scaling
@ kNone_SkLegacyFQ
nearest-neighbor; fastest but lowest quality
static size_t FlatSize(const SkSamplingOptions &options)
static SkSamplingOptions FromFQ(SkLegacyFQ fq, SkMediumAs behavior=kNearest_SkMediumAs)
static bool NoChangeWithIdentityMatrix(const SkSamplingOptions &sampling)
static SkSamplingOptions AnisoFallback(bool imageIsMipped)
SkSamplingOptions sampling
Definition: SkRecords.h:337
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SkSamplingOptions(SkFilterMode::kLinear))
const SkCubicResampler cubic