36 SkASSERT(
s.fInvMatrix.isScaleTranslate());
39 const unsigned maxX =
s.fPixmap.width() - 1;
44 const unsigned maxY =
s.fPixmap.height() - 1;
45 dstY = SkTPin<int>(mapper.
intY(), 0, maxY);
49 const SkPMColor* src =
s.fPixmap.addr32(0, dstY);
57 int count4 =
count >> 2;
58 for (
int i = 0; i < count4; ++i) {
69 for (
int i = (count4 << 2); i <
count; ++i) {
76 for (
int i = 0; i <
count; ++i) {
86 SkASSERT(
s.fInvMatrix.isScaleTranslate());
88 SkASSERT(4 ==
s.fPixmap.info().bytesPerPixel());
95 auto row = (
const SkPMColor*)( (
const char*)
s.fPixmap.addr() +
y *
s.fPixmap.rowBytes() );
97 if (1 ==
s.fPixmap.width()) {
104 uint32_t x01 = *xy++,
121 auto x = (
const uint16_t*)xy;
122 while (
count --> 0) {
131 SkASSERT(4 ==
s.fPixmap.info().bytesPerPixel());
134 auto src = (
const char*)
s.fPixmap.addr();
135 size_t rb =
s.fPixmap.rowBytes();
137 while (
count --> 0) {
186 return (dimension & ~0x3FFF) == 0;
192 SkASSERT(SkOpts::S32_alpha_D32_filter_DXDY ||
inv.isScaleTranslate());
212 if (!integral_translate_only) {
261bool SkBitmapProcState::chooseProcs() {
277 fMatrixProc = this->chooseMatrixProc(translate_only);
296 fShaderProc32 = this->chooseShaderProc32();
311 const int maxX =
s.fPixmap.width() - 1;
312 const int maxY =
s.fPixmap.height() - 1;
313 int ix =
s.fFilterOneX +
x;
314 int iy =
SkTPin(
s.fFilterOneY +
y, 0, maxY);
315 const SkPMColor* row =
s.fPixmap.addr32(0, iy);
319 int n = std::min(-ix,
count);
331 int n = std::min(maxX - ix + 1,
count);
332 memcpy(colors, row + ix, n *
sizeof(
SkPMColor));
346 if ((
unsigned)
x >= (
unsigned)n) {
373 const int stopX =
s.fPixmap.width();
374 const int stopY =
s.fPixmap.height();
375 int ix =
s.fFilterOneX +
x;
377 const SkPMColor* row =
s.fPixmap.addr32(0, iy);
381 int n = std::min(stopX - ix,
count);
382 memcpy(colors, row + ix, n *
sizeof(
SkPMColor));
396 unsigned alphaScale) {
400 const uint32_t mask = 0xFF00FF;
402 int scale = 256 - 16*t;
403 uint32_t lo = (color0 & mask) *
scale;
404 uint32_t hi = ((color0 >> 8) & mask) *
scale;
407 lo += (color1 & mask) *
scale;
408 hi += ((color1 >> 8) & mask) *
scale;
411 lo = ((lo >> 8) & mask) * alphaScale;
412 hi = ((hi >> 8) & mask) * alphaScale;
414 *dstColor = ((lo >> 8) & mask) | (hi & ~mask);
422 SkASSERT(
s.fInvMatrix.isScaleTranslate());
434 mproc(
s, xy, 1,
x,
y);
437 iY1 = xy[0] & 0x3FFF;
438 iSubY = (xy[0] >> 14) & 0xF;
442 if (
s.fInvMatrix.isTranslate()) {
443 yTemp =
s.fFilterOneY +
y;
454 yTemp = mapper.
intY();
458 const int stopY =
s.fPixmap.height();
459 switch (
s.fTileModeY) {
461 iY0 =
SkTPin(yTemp, 0, stopY-1);
477 if (!
s.fInvMatrix.isTranslate() &&
484 switch (
s.fTileModeY) {
486 iY2 =
SkTPin(iY2, 0, stopY-1);
502 const SkPMColor* row0 =
s.fPixmap.addr32(0, iY0);
506 const SkPMColor* row1 =
s.fPixmap.addr32(0, iY1);
509 if (
s.fAlphaScale < 256) {
525bool SkBitmapProcState::setupForTranslate() {
575 if (this->setupForTranslate()) {
581 if (this->setupForTranslate()) {
591static void check_scale_nofilter(uint32_t bitmapXY[],
int count,
592 unsigned mx,
unsigned my) {
593 unsigned y = *bitmapXY++;
596 const uint16_t* xptr =
reinterpret_cast<const uint16_t*
>(bitmapXY);
597 for (
int i = 0; i <
count; ++i) {
602static void check_scale_filter(uint32_t bitmapXY[],
int count,
603 unsigned mx,
unsigned my) {
604 uint32_t YY = *bitmapXY++;
605 unsigned y0 = YY >> 18;
606 unsigned y1 = YY & 0x3FFF;
610 for (
int i = 0; i <
count; ++i) {
611 uint32_t
XX = bitmapXY[i];
612 unsigned x0 =
XX >> 18;
613 unsigned x1 =
XX & 0x3FFF;
619static void check_affine_nofilter(uint32_t bitmapXY[],
int count,
unsigned mx,
unsigned my) {
620 for (
int i = 0; i <
count; ++i) {
621 uint32_t XY = bitmapXY[i];
622 unsigned x = XY & 0xFFFF;
623 unsigned y = XY >> 16;
629static void check_affine_filter(uint32_t bitmapXY[],
int count,
unsigned mx,
unsigned my) {
630 for (
int i = 0; i <
count; ++i) {
631 uint32_t YY = *bitmapXY++;
632 unsigned y0 = YY >> 18;
633 unsigned y1 = YY & 0x3FFF;
637 uint32_t
XX = *bitmapXY++;
638 unsigned x0 =
XX >> 18;
639 unsigned x1 =
XX & 0x3FFF;
646 uint32_t bitmapXY[],
int count,
653 void (*proc)(uint32_t bitmapXY[],
int count,
unsigned mx,
unsigned my);
655 if (
state.fInvMatrix.isScaleTranslate()) {
656 proc =
state.fBilerp ? check_scale_filter : check_scale_nofilter;
658 proc =
state.fBilerp ? check_affine_filter : check_affine_nofilter;
665 return DebugMatrixProc;
680 int32_t size =
static_cast<int32_t
>(bufferSize);
static SkM44 inv(const SkM44 &m)
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static void filter_32_alpha(unsigned t, SkPMColor color0, SkPMColor color1, SkPMColor *dstColor, unsigned alphaScale)
static void Repeat_S32_D32_nofilter_trans_shaderproc(const void *sIn, int x, int y, SkPMColor *colors, int count)
static void DoNothing_shaderproc(const void *, int x, int y, SkPMColor *colors, int count)
static int sk_int_mirror(int x, int n)
static void Clamp_S32_D32_nofilter_trans_shaderproc(const void *sIn, int x, int y, SkPMColor *colors, int count)
static void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void *sIn, int x, int y, SkPMColor *dst, int count)
static bool matrix_only_scale_translate(const SkMatrix &m)
static void S32_D32_constX_shaderproc(const void *sIn, int x, int y, SkPMColor *colors, int count)
static bool just_trans_general(const SkMatrix &matrix)
static bool valid_for_filtering(unsigned dimension)
static void S32_alpha_D32_nofilter_DXDY(const SkBitmapProcState &s, const uint32_t *xy, int count, SkPMColor *colors)
static int sk_int_mod(int x, int n)
static bool just_trans_integral(const SkMatrix &m)
static void S32_alpha_D32_nofilter_DX(const SkBitmapProcState &s, const uint32_t *xy, int count, SkPMColor *colors)
#define UNPACK_PRIMARY_SHORT(packed)
#define UNPACK_SECONDARY_SHORT(packed)
#define SkScalarToFractionalInt(x)
SkFixed3232 SkFractionalInt
#define SkFractionalIntToInt(x)
static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale)
static unsigned SkAlpha255To256(U8CPU alpha)
#define SK_INIT_TO_AVOID_WARNING
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
#define SkScalarRoundToScalar(x)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
#define XX(width, name,...)
SkFractionalInt fractionalIntY() const
SkFractionalInt fractionalIntX() const
static MapXYProc GetMapXYProc(const SkMatrix &matrix)
static bool PostIDiv(SkMatrix *matrix, int divx, int divy)
static constexpr int kMScaleX
horizontal scale factor
SkScalar getSkewY() const
SkScalar getTranslateY() const
SkMatrix & setTranslate(SkScalar dx, SkScalar dy)
bool invert(SkMatrix *inverse) const
SkScalar getScaleX() const
SkMatrix & preConcat(const SkMatrix &other)
bool isScaleTranslate() const
bool hasPerspective() const
static constexpr int kMScaleY
vertical scale factor
SkScalar getTranslateX() const
@ kTranslate_Mask
translation SkMatrix
@ kScale_Mask
scale SkMatrix
static SkMipmapAccessor * Make(SkArenaAlloc *, const SkImage *, const SkMatrix &inv, SkMipmapMode)
SkColorType colorType() const
const void * addr() const
SkAlphaType alphaType() const
void(* memset32)(uint32_t[], uint32_t, int)
SkSamplingOptions sampling
void(* ShaderProc32)(const void *ctx, int x, int y, SkPMColor[], int count)
SkBitmapProcState(const SkImage_Base *image, SkTileMode tmx, SkTileMode tmy)
SkFractionalInt fInvSxFractionalInt
void(* MatrixProc)(const SkBitmapProcState &, uint32_t bitmapXY[], int count, int x, int y)
SkMatrixPriv::MapXYProc fInvProc
int maxCountForBufferSize(size_t bufferSize) const
const SkImage_Base * fImage
MatrixProc getMatrixProc() const
SkFractionalInt fInvKyFractionalInt
const SkFilterMode filter
const SkMipmapMode mipmap