Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkRasterPipelineSpriteBlitter Class Reference
Inheritance diagram for SkRasterPipelineSpriteBlitter:
SkSpriteBlitter SkBlitter

Public Member Functions

 SkRasterPipelineSpriteBlitter (const SkPixmap &src, SkArenaAlloc *alloc, sk_sp< SkShader > clipShader)
 
bool setup (const SkPixmap &dst, int left, int top, const SkPaint &paint) override
 
void blitRect (int x, int y, int width, int height) override
 Blit a solid rectangle one or more pixels wide. More...
 
- Public Member Functions inherited from SkSpriteBlitter
 SkSpriteBlitter (const SkPixmap &source)
 
virtual bool setup (const SkPixmap &dst, int left, int top, const SkPaint &)
 
void blitH (int x, int y, int width) override
 Blit a horizontal run of one or more pixels. More...
 
void blitAntiH (int x, int y, const SkAlpha antialias[], const int16_t runs[]) override
 
void blitV (int x, int y, int height, SkAlpha alpha) override
 Blit a vertical run of pixels with a constant alpha value. More...
 
void blitMask (const SkMask &, const SkIRect &clip) override
 
void blitRect (int x, int y, int width, int height) override=0
 Blit a solid rectangle one or more pixels wide. More...
 
- Public Member Functions inherited from SkBlitter
virtual ~SkBlitter ()
 
virtual void blitH (int x, int y, int width)=0
 Blit a horizontal run of one or more pixels. More...
 
virtual void blitAntiH (int x, int y, const SkAlpha antialias[], const int16_t runs[])=0
 
virtual void blitV (int x, int y, int height, SkAlpha alpha)
 Blit a vertical run of pixels with a constant alpha value. More...
 
virtual void blitRect (int x, int y, int width, int height)
 Blit a solid rectangle one or more pixels wide. More...
 
virtual void blitAntiRect (int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha)
 
void blitFatAntiRect (const SkRect &rect)
 
virtual void blitMask (const SkMask &, const SkIRect &clip)
 
virtual void blitAntiH2 (int x, int y, U8CPU a0, U8CPU a1)
 
virtual void blitAntiV2 (int x, int y, U8CPU a0, U8CPU a1)
 
virtual bool isNullBlitter () const
 
virtual int requestRowsPreserved () const
 
virtual void * allocBlitMemory (size_t sz)
 
void blitRectRegion (const SkIRect &rect, const SkRegion &clip)
 
void blitRegion (const SkRegion &clip)
 

Additional Inherited Members

- Static Public Member Functions inherited from SkSpriteBlitter
static SkSpriteBlitterChooseL32 (const SkPixmap &source, const SkPaint &, SkArenaAlloc *)
 
- Static Public Member Functions inherited from SkBlitter
static bool UseLegacyBlitter (const SkPixmap &, const SkPaint &, const SkMatrix &)
 
static SkBlitterChoose (const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
 
static SkBlitterChooseSprite (const SkPixmap &dst, const SkPaint &, const SkPixmap &src, int left, int top, SkArenaAlloc *, sk_sp< SkShader > clipShader)
 
- Protected Attributes inherited from SkSpriteBlitter
SkPixmap fDst
 
const SkPixmap fSource
 
int fLeft
 
int fTop
 
const SkPaintfPaint
 
- Protected Attributes inherited from SkBlitter
SkAutoMalloc fBlitMemory
 

Detailed Description

Definition at line 122 of file SkBlitter_Sprite.cpp.

Constructor & Destructor Documentation

◆ SkRasterPipelineSpriteBlitter()

SkRasterPipelineSpriteBlitter::SkRasterPipelineSpriteBlitter ( const SkPixmap src,
SkArenaAlloc alloc,
sk_sp< SkShader clipShader 
)
inline

Definition at line 124 of file SkBlitter_Sprite.cpp.

126 : INHERITED(src)
127 , fAlloc(alloc)
128 , fBlitter(nullptr)
129 , fSrcPtr{nullptr, 0}
130 , fClipShader(std::move(clipShader))
131 {}

Member Function Documentation

◆ blitRect()

void SkRasterPipelineSpriteBlitter::blitRect ( int  x,
int  y,
int  width,
int  height 
)
inlineoverridevirtual

Blit a solid rectangle one or more pixels wide.

Implements SkSpriteBlitter.

Definition at line 169 of file SkBlitter_Sprite.cpp.

169 {
170 fSrcPtr.stride = fSource.rowBytesAsPixels();
171
172 // We really want fSrcPtr.pixels = fSource.addr(-fLeft, -fTop) here, but that asserts.
173 // Instead we ask for addr(-fLeft+x, -fTop+y), then back up (x,y) manually.
174 // Representing bpp as a size_t keeps all this math in size_t instead of int,
175 // which could wrap around with large enough fSrcPtr.stride and y.
176 size_t bpp = fSource.info().bytesPerPixel();
177 fSrcPtr.pixels = (char*)fSource.writable_addr(-fLeft+x, -fTop+y) - bpp * x
178 - bpp * y * fSrcPtr.stride;
179
180 fBlitter->blitRect(x,y,width,height);
181 }
virtual void blitRect(int x, int y, int width, int height)
Blit a solid rectangle one or more pixels wide.
Definition: SkBlitter.cpp:133
const SkImageInfo & info() const
Definition: SkPixmap.h:135
int rowBytesAsPixels() const
Definition: SkPixmap.h:214
void * writable_addr() const
Definition: SkPixmap.h:483
const SkPixmap fSource
double y
double x
int32_t height
int32_t width
int bytesPerPixel() const
Definition: SkImageInfo.h:492

◆ setup()

bool SkRasterPipelineSpriteBlitter::setup ( const SkPixmap dst,
int  left,
int  top,
const SkPaint paint 
)
inlineoverridevirtual

Reimplemented from SkSpriteBlitter.

Definition at line 133 of file SkBlitter_Sprite.cpp.

133 {
134 fDst = dst;
135 fLeft = left;
136 fTop = top;
137 fPaintColor = paint.getColor4f();
138
139 SkRasterPipeline p(fAlloc);
140 p.appendLoad(fSource.colorType(), &fSrcPtr);
141
143 // The color for A8 images comes from the (sRGB) paint color.
144 p.appendSetRGB(fAlloc, fPaintColor);
146 }
147 if (auto dstCS = fDst.colorSpace()) {
148 auto srcCS = fSource.colorSpace();
149 if (!srcCS || SkColorTypeIsAlphaOnly(fSource.colorType())) {
150 // We treat untagged images as sRGB.
151 // Alpha-only images get their r,g,b from the paint color, so they're also sRGB.
152 srcCS = sk_srgb_singleton();
153 }
154 auto srcAT = fSource.isOpaque() ? kOpaque_SkAlphaType
156 fAlloc->make<SkColorSpaceXformSteps>(srcCS, srcAT,
157 dstCS, kPremul_SkAlphaType)
158 ->apply(&p);
159 }
160 if (fPaintColor.fA != 1.0f) {
161 p.append(SkRasterPipelineOp::scale_1_float, &fPaintColor.fA);
162 }
163
164 bool is_opaque = fSource.isOpaque() && fPaintColor.fA == 1.0f;
165 fBlitter = SkCreateRasterPipelineBlitter(fDst, paint, p, is_opaque, fAlloc, fClipShader);
166 return fBlitter != nullptr;
167 }
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorSpace * sk_srgb_singleton()
SkBlitter * SkCreateRasterPipelineBlitter(const SkPixmap &, const SkPaint &, const SkMatrix &ctm, SkArenaAlloc *, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool apply(Pass *pass, SkRecord *record)
static uint32_t premul(uint32_t color)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
SkColorType colorType() const
Definition: SkPixmap.h:173
bool isOpaque() const
Definition: SkPixmap.h:201
SkColorSpace * colorSpace() const
Definition: SkPixmap.cpp:61
const Paint & paint
Definition: color_source.cc:38
dst
Definition: cp.py:12

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