Flutter Engine
The Flutter Engine
Enumerations | Functions
SkImagePriv.h File Reference
#include "include/core/SkImage.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTileMode.h"

Go to the source code of this file.

Enumerations

enum  SkCopyPixelsMode { kIfMutable_SkCopyPixelsMode , kAlways_SkCopyPixelsMode , kNever_SkCopyPixelsMode }
 

Functions

sk_sp< SkShaderSkMakeBitmapShaderForPaint (const SkPaint &paint, const SkBitmap &src, SkTileMode, SkTileMode, const SkSamplingOptions &, const SkMatrix *localMatrix, SkCopyPixelsMode)
 
SkRect SkModifyPaintAndDstForDrawImageRect (const SkImage *image, const SkSamplingOptions &, SkRect src, SkRect dst, bool strictSrcSubset, SkPaint *paint)
 
SK_SPI sk_sp< SkImageSkMakeImageFromRasterBitmap (const SkBitmap &, SkCopyPixelsMode)
 
const SkPixelRefSkBitmapImageGetPixelRef (const SkImage *rasterImage)
 

Enumeration Type Documentation

◆ SkCopyPixelsMode

Enumerator
kIfMutable_SkCopyPixelsMode 

only copy src pixels if they are marked mutable

kAlways_SkCopyPixelsMode 

always copy src pixels (even if they are marked immutable)

kNever_SkCopyPixelsMode 

never copy src pixels (even if they are marked mutable)

Definition at line 17 of file SkImagePriv.h.

17 {
18 kIfMutable_SkCopyPixelsMode, //!< only copy src pixels if they are marked mutable
19 kAlways_SkCopyPixelsMode, //!< always copy src pixels (even if they are marked immutable)
20 kNever_SkCopyPixelsMode, //!< never copy src pixels (even if they are marked mutable)
21};
@ kNever_SkCopyPixelsMode
never copy src pixels (even if they are marked mutable)
Definition: SkImagePriv.h:20
@ kIfMutable_SkCopyPixelsMode
only copy src pixels if they are marked mutable
Definition: SkImagePriv.h:18
@ kAlways_SkCopyPixelsMode
always copy src pixels (even if they are marked immutable)
Definition: SkImagePriv.h:19

Function Documentation

◆ SkBitmapImageGetPixelRef()

const SkPixelRef * SkBitmapImageGetPixelRef ( const SkImage rasterImage)

Definition at line 190 of file SkImage_Raster.cpp.

190 {
191 return ((const SkImage_Raster*)image)->getPixelRef();
192}
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ SkMakeBitmapShaderForPaint()

sk_sp< SkShader > SkMakeBitmapShaderForPaint ( const SkPaint paint,
const SkBitmap src,
SkTileMode  tmx,
SkTileMode  tmy,
const SkSamplingOptions sampling,
const SkMatrix localMatrix,
SkCopyPixelsMode  mode 
)

Definition at line 358 of file SkImageShader.cpp.

361 {
363 tmx, tmy, sampling, localMatrix);
364 if (!s) {
365 return nullptr;
366 }
367 if (SkColorTypeIsAlphaOnly(src.colorType()) && paint.getShader()) {
368 // Compose the image shader with the paint's shader. Alpha images+shaders should output the
369 // texture's alpha multiplied by the shader's color. DstIn (d*sa) will achieve this with
370 // the source image and dst shader (MakeBlend takes dst first, src second).
371 s = SkShaders::Blend(SkBlendMode::kDstIn, paint.refShader(), std::move(s));
372 }
373 return s;
374}
@ kDstIn
r = d * sa
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
SK_SPI sk_sp< SkImage > SkMakeImageFromRasterBitmap(const SkBitmap &, SkCopyPixelsMode)
static sk_sp< SkShader > Make(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
const Paint & paint
Definition: color_source.cc:38
struct MyStruct s
SkSamplingOptions sampling
Definition: SkRecords.h:337
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
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 mode
Definition: switches.h:228
SkTileMode tmy
SkTileMode tmx

◆ SkMakeImageFromRasterBitmap()

SK_SPI sk_sp< SkImage > SkMakeImageFromRasterBitmap ( const SkBitmap bm,
SkCopyPixelsMode  cpm 
)

Examines the bitmap to decide if it can share the existing pixelRef, or if it needs to make a deep-copy of the pixels.

The bitmap's pixelref will be shared if either the bitmap is marked as immutable, or CopyPixelsMode allows it. Shared pixel refs are also locked when kLocked_SharedPixelRefMode is specified.

Passing kLocked_SharedPixelRefMode allows the image's peekPixels() method to succeed, but it will force any lazy decodes/generators to execute if they exist on the pixelref.

It is illegal to call this with a texture-backed bitmap.

If the bitmap's colortype cannot be converted into a corresponding SkImageInfo, or the bitmap's pixels cannot be accessed, this will return nullptr.

Definition at line 182 of file SkImage_Raster.cpp.

182 {
183 if (!SkImageInfoIsValid(bm.info()) || bm.rowBytes() < bm.info().minRowBytes()) {
184 return nullptr;
185 }
186
188}
static bool SkImageInfoIsValid(const SkImageInfo &info)
@ kNeedNewImageUniqueID
Definition: SkImage_Base.h:33
sk_sp< SkImage > SkMakeImageFromRasterBitmapPriv(const SkBitmap &bm, SkCopyPixelsMode cpm, uint32_t idForCopy)
size_t rowBytes() const
Definition: SkBitmap.h:238
const SkImageInfo & info() const
Definition: SkBitmap.h:139
size_t minRowBytes() const
Definition: SkImageInfo.h:517

◆ SkModifyPaintAndDstForDrawImageRect()

SkRect SkModifyPaintAndDstForDrawImageRect ( const SkImage image,
const SkSamplingOptions sampling,
SkRect  src,
SkRect  dst,
bool  strictSrcSubset,
SkPaint paint 
)

Definition at line 376 of file SkImageShader.cpp.

381 {
382 // The paint should have already been cleaned for a regular drawImageRect, e.g. no path
383 // effect and is a fill.
385 SkASSERT(paint->getStyle() == SkPaint::kFill_Style && !paint->getPathEffect());
386
388 SkRect imgBounds = SkRect::Make(image->bounds());
389
390 SkASSERT(src.isFinite() && dst.isFinite() && dst.isSorted());
391 SkMatrix localMatrix = SkMatrix::RectToRect(src, dst);
392 if (!imgBounds.contains(src)) {
393 if (!src.intersect(imgBounds)) {
394 return SkRect::MakeEmpty(); // Nothing to draw for this entry
395 }
396 // Update dst to match smaller src
397 dst = localMatrix.mapRect(src);
398 }
399
400 bool imageIsAlphaOnly = SkColorTypeIsAlphaOnly(image->colorType());
401
402 sk_sp<SkShader> imgShader;
403 if (strictSrcSubset) {
406 sampling, &localMatrix);
407 } else {
409 sampling, &localMatrix);
410 }
411 if (!imgShader) {
412 return SkRect::MakeEmpty();
413 }
414 if (imageIsAlphaOnly && paint->getShader()) {
415 // Compose the image shader with the paint's shader. Alpha images+shaders should output the
416 // texture's alpha multiplied by the shader's color. DstIn (d*sa) will achieve this with
417 // the source image and dst shader (MakeBlend takes dst first, src second).
418 imgShader = SkShaders::Blend(SkBlendMode::kDstIn, paint->refShader(), std::move(imgShader));
419 }
420
421 paint->setShader(std::move(imgShader));
422 return dst;
423}
#define SkASSERT(cond)
Definition: SkAssert.h:116
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
static sk_sp< SkShader > MakeSubset(sk_sp< SkImage >, const SkRect &subset, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
SkColorType colorType() const
Definition: SkImage.cpp:152
SkIRect bounds() const
Definition: SkImage.h:303
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition: SkMatrix.h:157
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
dst
Definition: cp.py:12
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595
bool contains(SkScalar x, SkScalar y) const
Definition: extension.cpp:19