using ShaderProc32 = void (*)(constvoid* ctx, int x, int y, SkPMColor[], int count);
using MatrixProc = void (*)(const SkBitmapProcState&,
uint32_t bitmapXY[], int count, int x, int y);
using SampleProc32 = void (*)(const SkBitmapProcState&, const uint32_t[], int count,
SkPMColor colors[]);
const SkImage_Base* fImage;
SkPixmap fPixmap;
SkMatrix fInvMatrix; // This changes based on tile mode.
SkAlpha fPaintAlpha;
SkTileMode fTileModeX;
SkTileMode fTileModeY; bool fBilerp;
SkFixed3232 fInvSx;
SkFixed3232 fInvKy;
SkFixed fFilterOneX;
SkFixed fFilterOneY;
uint16_t fAlphaScale; // chooseProcs
/** Given the byte size of the index buffer to be passed to the matrix proc, returnthemaximumnumberofresultingpixelsthatcanbecomputed (i.e.thenumberofSkPMColorvaluestobewrittenbythesampleproc). Thisroutinetakesintoaccountthatfilteringandscale-vs-affine affecttheamountofbufferspaceneeded.
OnlyvalidtocallafterchooseProcs(setContext)hasbeencalled.Itis safetocallthisinsidetheshader'sshadeSpan()method.
*/ int maxCountForBufferSize(size_t bufferSize) const;
// If a shader proc is present, then the corresponding matrix/sample procs // are ignored
ShaderProc32 getShaderProc32() const { return fShaderProc32; }
private: // found by inspection. If this is too small, we will allocate on the heap. static constexpr size_t kBMStateSize = 136;
SkSTArenaAlloc<kBMStateSize> fAlloc;
ShaderProc32 fShaderProc32; // chooseProcs // These are used if the shaderproc is nullptr
MatrixProc fMatrixProc; // chooseProcs
SampleProc32 fSampleProc32; // chooseProcs
// Helper class for mapping the middle of pixel (x, y) into SkFixed3232 bitmap space. // Discussion: // Overall, this code takes a point in destination space, and uses the center of the pixel // at (x, y) to determine the sample point in source space. It then adjusts the pixel by different // amounts based in filtering and tiling. // This code can be broken into two main cases based on filtering: // * no filtering (nearest neighbor) - when using nearest neighbor filtering all tile modes reduce // the sampled by one ulp. If a simple point pt lies precisely on XXX.1/2 then it forced down // when positive making 1/2 + 1/2 = .999999 instead of 1.0. // * filtering - in the filtering case, the code calculates the -1/2 shift for starting the // bilerp kernel. There is a twist; there is a big difference between clamp and the other tile // modes. In tile and repeat the matrix has been reduced by an additional 1/width and 1/height // factor. This maps from destination space to [0, 1) (instead of source space) to allow easy // modulo arithmetic. This means that the -1/2 needed by bilerp is actually 1/2 * 1/width for x // and 1/2 * 1/height for y. This is what happens when the poorly named fFilterOne{X|Y} is // divided by two. class SkBitmapProcStateAutoMapper {
public:
SkBitmapProcStateAutoMapper(const SkBitmapProcState& s, int x, int y,
SkPoint* scalarPoint = nullptr) {
SkPoint pt = s.fInvMatrix.mapPoint({
SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf,
});
SkFixed biasX = 0, biasY = 0; if (s.fBilerp) {
biasX = s.fFilterOneX >> 1;
biasY = s.fFilterOneY >> 1;
} else { // Our rasterizer biases upward. That is a rect from 0.5...1.5 fills pixel 1 and not // pixel 0. To make an image that is mapped 1:1 with device pixels but at a half pixel // offset select every pixel from the src image once we make exact integer pixel sample // values round down not up. Note that a mirror mapping will not have this property.
biasX = 1;
biasY = 1;
}
// punt to unsigned for defined underflow behavior
fX = (SkFixed3232)((uint64_t)SkScalarToFixed3232(pt.x()) -
(uint64_t)SkFixedToFixed3232(biasX));
fY = (SkFixed3232)((uint64_t)SkScalarToFixed3232(pt.y()) -
(uint64_t)SkFixedToFixed3232(biasY));
int intX() const { return SkFixed3232ToInt(fX); } int intY() const { return SkFixed3232ToInt(fY); }
private:
SkFixed3232 fX, fY;
};
namespace sktests { // f is the value to pack, max is the largest the value can be.
uint32_t pack_clamp(SkFixed f, unsigned max); // As above, but width is the width of the pretend bitmap.
uint32_t pack_repeat(SkFixed f, unsigned max, size_t width);
uint32_t pack_mirror(SkFixed f, unsigned max, size_t width);
}
namespace SkOpts { // SkBitmapProcState optimized Shader, Sample, or Matrix procs. externvoid (*S32_alpha_D32_filter_DX)(const SkBitmapProcState&, const uint32_t* xy, int count, SkPMColor*); externvoid (*S32_alpha_D32_filter_DXDY)(const SkBitmapProcState&, const uint32_t* xy, int count, SkPMColor*);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.