47#ifdef SK_BUILD_FOR_WIN
171 return surf->makeImageSnapshot();
186 std::unique_ptr<
char[]>* mem) {
189 int numMipLevels = withMips ? 6 : 1;
203 mem->reset(
new char[
size]);
204 char*
addr = mem->get();
245 if (
pos ==
nullptr) {
258 Rec* rec = (Rec*)ctx;
261 tmp.postTranslate(rec->fPos->fX, rec->fPos->fY);
262 rec->fDst->addPath(*src, tmp);
274 for (
int i = 1;
i < numPts; ++
i) {
275 int idx =
i *
step % numPts;
288 unsigned char r =
static_cast<unsigned char>((0.5f * norm.
fX + 0.5f) * 255);
289 unsigned char g =
static_cast<unsigned char>((-0.5f * norm.
fY + 0.5f) * 255);
290 unsigned char b =
static_cast<unsigned char>((0.5f * norm.
fZ + 0.5f) * 255);
301 for (
int y =
dst.fTop;
y <
dst.fBottom; ++
y) {
302 for (
int x =
dst.fLeft;
x <
dst.fRight; ++
x) {
308 norm.
set(0.0f, 0.0f, 1.0f);
310 norm.
fZ = sqrtf(1.0f - tmp);
331 for (
int y =
dst.fTop;
y <
dst.fBottom; ++
y) {
332 for (
int x =
dst.fLeft;
x <
dst.fRight; ++
x) {
334 norm.
set(0.0f, 0.0f, 1.0f);
341 norm = locX >= locY ?
right : down;
343 norm = locX > -locY ?
right : up;
347 norm = -locX > locY ?
left : down;
349 norm = locX > locY ? up :
left;
363 static const SkScalar k1OverRoot3 = 0.5773502692f;
370 for (
int y =
dst.fTop;
y <
dst.fBottom; ++
y) {
371 for (
int x =
dst.fLeft;
x <
dst.fRight; ++
x) {
377 norm = locX >= locY ? rightUp : down;
383 norm = -locX > locY ? leftUp : down;
396 if (!
src.peekPixels(&srcPM)) {
402 if (!tmpDst.
setInfo(dstInfo)) {
428 dst->allocPixels(grayInfo);
429 uint8_t* dst8 = (uint8_t*)
dst->getPixels();
430 const uint32_t* src32 = (
const uint32_t*)
src.getPixels();
432 const int w =
src.width();
433 const int h =
src.height();
435 for (
int y = 0;
y <
h; ++
y) {
438 for (
int x = 0;
x <
w; ++
x) {
439 uint32_t
s = src32[
x];
444 for (
int x = 0;
x <
w; ++
x) {
445 uint32_t
s = src32[
x];
449 src32 = (
const uint32_t*)((
const char*)src32 +
src.rowBytes());
450 dst8 +=
dst->rowBytes();
457 if (
a.width() !=
b.width() ||
a.height() !=
b.height()) {
458 SkDebugf(
"[ToolUtils::equal_pixels] Dimensions do not match (%d x %d) != (%d x %d)\n",
459 a.width(),
a.height(),
b.width(),
b.height());
463 if (
a.colorType() !=
b.colorType()) {
464 SkDebugf(
"[ToolUtils::equal_pixels] colorType does not match %d != %d\n",
465 (
int)
a.colorType(), (
int)
b.colorType());
469 for (
int y = 0;
y <
a.height(); ++
y) {
470 const char* aptr = (
const char*)
a.addr(0,
y);
471 const char* bptr = (
const char*)
b.addr(0,
y);
472 if (0 != memcmp(aptr, bptr,
a.width() *
a.info().bytesPerPixel())) {
473 SkDebugf(
"[ToolUtils::equal_pixels] row %d does not match byte for byte\n",
y);
483 SkDebugf(
"Could not read pixels from A\n");
487 SkDebugf(
"Could not read pixels from B\n");
497 auto imga =
a->makeRasterImage();
498 auto imgb =
b->makeRasterImage();
501 if (!imga->peekPixels(&pm0)) {
502 SkDebugf(
"Could not read pixels from A\n");
505 if (!imgb->peekPixels(&pm1)) {
506 SkDebugf(
"Could not read pixels from B\n");
533 std::unique_ptr<SkFontParameters::Variation::Axis[]> copiedAxes =
534 std::make_unique<SkFontParameters::Variation::Axis[]>(numAxes);
541 auto argVariationPositionOrDefault = [&variationPosition](
SkFourByteTag tag,
551 fAxisSliders.resize(numAxes);
552 fCoords = std::make_unique<SkFontArguments::VariationPosition::Coordinate[]>(numAxes);
553 for (
int i = 0;
i < numAxes; ++
i) {
554 fAxisSliders[
i].axis = copiedAxes[
i];
555 fAxisSliders[
i].current =
556 argVariationPositionOrDefault(copiedAxes[
i].tag, copiedAxes[
i].def);
557 fAxisSliders[
i].name = tagToString(fAxisSliders[
i].axis.tag);
558 fCoords[
i] = { fAxisSliders[
i].axis.tag, fAxisSliders[
i].current };
566 tagAsString[0] = (char)(uint8_t)(tag >> 24);
567 tagAsString[1] = (char)(uint8_t)(tag >> 16);
568 tagAsString[2] = (char)(uint8_t)(tag >> 8);
569 tagAsString[3] = (char)(uint8_t)(tag >> 0);
574 for (
size_t i = 0;
i < fAxisSliders.size(); ++
i) {
577 axisVars[0] = fAxisSliders[
i].current;
578 axisVars[1] = fAxisSliders[
i].axis.min;
579 axisVars[2] = fAxisSliders[
i].axis.max;
580 controls->
setScalars(fAxisSliders[
i].
name.c_str(), kAxisVarsSize, axisVars);
585void VariationSliders::readControls(
const SkMetaData& controls,
bool* changed) {
586 for (
size_t i = 0;
i < fAxisSliders.size(); ++
i) {
587 SkScalar axisVars[kAxisVarsSize] = {0};
588 int resultAxisVarsSize = 0;
590 tagToString(fAxisSliders[
i].axis.tag).c_str(), &resultAxisVarsSize, axisVars));
593 *changed |= fAxisSliders[
i].current != axisVars[0];
595 fAxisSliders[
i].current = axisVars[0];
596 fCoords[
i] = { fAxisSliders[
i].axis.tag, fAxisSliders[
i].current };
602 fAxisSliders.
size()};
606HilbertGenerator::HilbertGenerator(
float desiredSize,
float desiredLineWidth,
int desiredDepth)
607 : fDesiredSize(desiredSize)
608 , fDesiredDepth(desiredDepth)
609 , fSegmentLength(fDesiredSize / ((0x1 << fDesiredDepth) - 1.0f))
610 , fDesiredLineWidth(desiredLineWidth)
611 , fActualBounds(
SkRect::MakeEmpty())
614 , fExpectedLen(fSegmentLength * ((0x1 << (2*fDesiredDepth)) - 1.0f))
619 this->recursiveDraw(canvas, 0,
true);
626void HilbertGenerator::turn90(
bool turnLeft) {
627 fCurDir += turnLeft ? 90 : -90;
628 if (fCurDir >= 360) {
630 }
else if (fCurDir < 0) {
634 SkASSERT(fCurDir == 0 || fCurDir == 90 || fCurDir == 180 || fCurDir == 270);
637void HilbertGenerator::line(
SkCanvas* canvas) {
645 r.
fTop = fCurPos.
fY - fDesiredLineWidth / 2.0f;
646 r.
fRight = fCurPos.
fX + fSegmentLength;
647 r.
fBottom = fCurPos.
fY + fDesiredLineWidth / 2.0f;
648 fCurPos.
fX += fSegmentLength;
651 r.
fLeft = fCurPos.
fX - fDesiredLineWidth / 2.0f;
652 r.
fTop = fCurPos.
fY - fSegmentLength;
653 r.
fRight = fCurPos.
fX + fDesiredLineWidth / 2.0f;
655 fCurPos.
fY -= fSegmentLength;
658 r.
fLeft = fCurPos.
fX - fSegmentLength;
659 r.
fTop = fCurPos.
fY - fDesiredLineWidth / 2.0f;
661 r.
fBottom = fCurPos.
fY + fDesiredLineWidth / 2.0f;
662 fCurPos.
fX -= fSegmentLength;
665 r.
fLeft = fCurPos.
fX - fDesiredLineWidth / 2.0f;
667 r.
fRight = fCurPos.
fX + fDesiredLineWidth / 2.0f;
669 fCurPos.
fY += fSegmentLength;
675 SkPoint pts[2] = { before, fCurPos };
678 this->getColor(fCurLen),
679 this->getColor(fCurLen + fSegmentLength),
682 fCurLen += fSegmentLength;
686 fActualBounds.
join(r);
695void HilbertGenerator::recursiveDraw(
SkCanvas* canvas,
int curDepth,
bool turnLeft) {
696 if (curDepth >= fDesiredDepth) {
700 this->turn90(turnLeft);
701 this->recursiveDraw(canvas, curDepth + 1, !turnLeft);
703 this->turn90(!turnLeft);
704 this->recursiveDraw(canvas, curDepth + 1, turnLeft);
706 this->recursiveDraw(canvas, curDepth + 1, turnLeft);
707 this->turn90(!turnLeft);
709 this->recursiveDraw(canvas, curDepth + 1, !turnLeft);
710 this->turn90(turnLeft);
713SkColor4f HilbertGenerator::getColor(
float curLen) {
724 static const float kStops[] = {
735 float t = curLen / fExpectedLen;
738 }
else if (t >= 1.0f) {
760 SkDebugf(
"ExtractPaths: invalid input file at \"%s\"\n", filepath);
764 class PathSniffer :
public SkCanvas {
766 PathSniffer(std::function<PathSniffCallback>
callback)
771 fPathSniffCallback(this->getTotalMatrix(),
path,
paint);
773 std::function<PathSniffCallback> fPathSniffCallback;
778 SkDebugf(
"ExtractPaths: couldn't load skp at \"%s\"\n", filepath);
782 skp->playback(&pathSniffer);
static int step(int x, SkScalar min, SkScalar max)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kUnknown_SkAlphaType
uninitialized
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkASSERT_RELEASE(cond)
static U8CPU SkComputeLuminance(U8CPU r, U8CPU g, U8CPU b)
static U16CPU SkPixel32ToPixel16(SkPMColor c)
static SkColor SkPixel16ToColor(U16CPU src)
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
@ kSRGBA_8888_SkColorType
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
@ kA16_float_SkColorType
pixel with a half float for alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
@ kUnknown_SkColorType
uninitialized
@ kR16G16_float_SkColorType
pixel with a half float for red and green
#define SkColorGetR(color)
#define SkColorGetG(color)
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
#define SkColorGetB(color)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
#define SkScalarSin(radians)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
#define SkScalarCos(radians)
#define SK_ScalarRoot2Over2
static SkScalar center(float pos0, float pos1)
const uint16_t * glyphs() const
void allocPixels(const SkImageInfo &info, size_t rowBytes)
void eraseArea(const SkIRect &area, SkColor c) const
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
bool peekPixels(SkPixmap *pixmap) const
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
uint32_t * getAddr32(int x, int y) const
bool tryAllocPixels(const SkImageInfo &info, size_t rowBytes)
void eraseColor(SkColor4f) const
void drawRect(const SkRect &rect, const SkPaint &paint)
sk_sp< SkSurface > makeSurface(const SkImageInfo &info, const SkSurfaceProps *props=nullptr)
void drawPaint(const SkPaint &paint)
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
static sk_sp< SkPicture > MakeFromStream(SkStream *stream, const SkDeserialProcs *procs=nullptr)
bool erase(SkColor color, const SkIRect &subset) const
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes) const
const SkImageInfo & info() const
constexpr size_t size() const
int getVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const
void reset(size_t count=0)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
constexpr SkColor4f kGreen
constexpr SkColor4f kWhite
constexpr SkColor4f kCyan
constexpr SkColor4f kBlack
constexpr SkColor4f kBlue
constexpr SkColor4f kYellow
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
Optional< SkRect > bounds
PODArray< SkColor > colors
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library name
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
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
font
Font Metadata and Metrics.
SkSamplingOptions(SkFilterMode::kLinear))
const Coordinate * coordinates
void inset(int32_t dx, int32_t dy)
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
bool contains(int32_t x, int32_t y) const
static SkImageInfo MakeN32Premul(int width, int height)
size_t minRowBytes() const
static SkImageInfo MakeS32(int width, int height, SkAlphaType at)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkImageInfo makeColorType(SkColorType newColorType) const
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
void set(SkScalar x, SkScalar y, SkScalar z)
static constexpr SkPoint Make(float x, float y)
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
constexpr float height() const
constexpr float width() const
void join(const SkRect &r)
SkScalar fTop
smaller y-axis bounds