Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SkPictureShader::CachedImageInfo Struct Reference

#include <SkPictureShader.h>

Public Member Functions

sk_sp< SkImagemakeImage (sk_sp< SkSurface > surf, const SkPicture *pict) const
 

Static Public Member Functions

static CachedImageInfo Make (const SkRect &bounds, const SkMatrix &totalM, SkColorType dstColorType, SkColorSpace *dstColorSpace, const int maxTextureSize, const SkSurfaceProps &propsIn)
 

Public Attributes

bool success
 
SkSize tileScale
 
SkMatrix matrixForDraw
 
SkImageInfo imageInfo
 
SkSurfaceProps props
 

Detailed Description

Definition at line 55 of file SkPictureShader.h.

Member Function Documentation

◆ Make()

SkPictureShader::CachedImageInfo SkPictureShader::CachedImageInfo::Make ( const SkRect bounds,
const SkMatrix totalM,
SkColorType  dstColorType,
SkColorSpace dstColorSpace,
const int  maxTextureSize,
const SkSurfaceProps propsIn 
)
static

Definition at line 180 of file SkPictureShader.cpp.

186 {
188
189 const SkSize scaledSize = [&]() {
190 SkSize size;
191 // Use a rotation-invariant scale
192 if (!totalM.decomposeScale(&size, nullptr)) {
193 SkPoint center = {bounds.centerX(), bounds.centerY()};
195 if (!SkIsFinite(area) || SkScalarNearlyZero(area)) {
196 size = {1, 1}; // ill-conditioned matrix
197 } else {
198 size.fWidth = size.fHeight = SkScalarSqrt(area);
199 }
200 }
201 size.fWidth *= bounds.width();
202 size.fHeight *= bounds.height();
203
204 // Clamp the tile size to about 4M pixels
205 static const SkScalar kMaxTileArea = 2048 * 2048;
206 SkScalar tileArea = size.width() * size.height();
207 if (tileArea > kMaxTileArea) {
208 SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea);
209 size.set(size.width() * clampScale, size.height() * clampScale);
210 }
211
212 // Scale down the tile size if larger than maxTextureSize for GPU path
213 // or it should fail on create texture
214 if (maxTextureSize) {
215 if (size.width() > maxTextureSize || size.height() > maxTextureSize) {
216 SkScalar downScale = maxTextureSize / std::max(size.width(), size.height());
217 size.set(SkScalarFloorToScalar(size.width() * downScale),
218 SkScalarFloorToScalar(size.height() * downScale));
219 }
220 }
221 return size;
222 }();
223
224 const SkISize tileSize = scaledSize.toCeil();
225 if (tileSize.isEmpty()) {
226 return {false, {}, {}, {}, {}};
227 }
228
229 const SkSize tileScale = {tileSize.width() / bounds.width(),
230 tileSize.height() / bounds.height()};
231 auto imgCS = ref_or_srgb(dstColorSpace);
232 const SkColorType imgCT = SkColorTypeMaxBitsPerChannel(dstColorType) <= 8
235
236 return {true,
237 tileScale,
238 SkMatrix::RectToRect(bounds, SkRect::MakeIWH(tileSize.width(), tileSize.height())),
239 SkImageInfo::Make(tileSize, imgCT, kPremul_SkAlphaType, imgCS),
240 props};
241}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Definition: SkColorType.h:19
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition: SkColorType.h:36
static bool SkIsFinite(T x, Pack... values)
static int SkColorTypeMaxBitsPerChannel(SkColorType ct)
static sk_sp< SkColorSpace > ref_or_srgb(SkColorSpace *cs)
#define SkScalarFloorToScalar(x)
Definition: SkScalar.h:30
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:101
#define SkScalarSqrt(x)
Definition: SkScalar.h:42
@ kUnknown_SkPixelGeometry
static SkScalar center(float pos0, float pos1)
static SkScalar DifferentialAreaScale(const SkMatrix &m, const SkPoint &p)
Definition: SkMatrix.cpp:1786
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition: SkMatrix.h:157
bool decomposeScale(SkSize *scale, SkMatrix *remaining=nullptr) const
Definition: SkMatrix.cpp:1559
SkSurfaceProps cloneWithPixelGeometry(SkPixelGeometry newPixelGeometry) const
float SkScalar
Definition: extension.cpp:12
static float max(float r, float g, float b)
Definition: hsl.cpp:49
Optional< SkRect > bounds
Definition: SkRecords.h:189
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
Definition: SkSize.h:16
bool isEmpty() const
Definition: SkSize.h:31
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect MakeIWH(int w, int h)
Definition: SkRect.h:623
Definition: SkSize.h:52
SkISize toCeil() const
Definition: SkSize.h:83

◆ makeImage()

sk_sp< SkImage > SkPictureShader::CachedImageInfo::makeImage ( sk_sp< SkSurface surf,
const SkPicture pict 
) const

Definition at line 243 of file SkPictureShader.cpp.

244 {
245 if (!surf) {
246 return nullptr;
247 }
248 auto canvas = surf->getCanvas();
249 canvas->concat(matrixForDraw);
250 canvas->drawPicture(pict);
251 return surf->makeImageSnapshot();
252}
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
sk_sp< SkImage > makeImageSnapshot()
Definition: SkSurface.cpp:90

Member Data Documentation

◆ imageInfo

SkImageInfo SkPictureShader::CachedImageInfo::imageInfo

Definition at line 59 of file SkPictureShader.h.

◆ matrixForDraw

SkMatrix SkPictureShader::CachedImageInfo::matrixForDraw

Definition at line 58 of file SkPictureShader.h.

◆ props

SkSurfaceProps SkPictureShader::CachedImageInfo::props

Definition at line 60 of file SkPictureShader.h.

◆ success

bool SkPictureShader::CachedImageInfo::success

Definition at line 56 of file SkPictureShader.h.

◆ tileScale

SkSize SkPictureShader::CachedImageInfo::tileScale

Definition at line 57 of file SkPictureShader.h.


The documentation for this struct was generated from the following files: