72#include <emscripten.h>
73#include <emscripten/bind.h>
74#include <emscripten/html5.h>
76#if defined(CK_ENABLE_WEBGL) || defined(CK_ENABLE_WEBGPU)
102#include <GLES2/gl2.h>
105#ifdef CK_ENABLE_WEBGPU
106#include <emscripten/html5_webgpu.h>
107#include <webgpu/webgpu.h>
108#include <webgpu/webgpu_cpp.h>
117#ifdef CK_INCLUDE_PARAGRAPH
122#ifdef CK_INCLUDE_PATHOPS
126#if defined(CK_INCLUDE_RUNTIME_EFFECT)
134#if defined(CK_EMBED_FONT)
140#if defined(GR_TEST_UTILS)
141#error "This define should not be set, as it brings in test-only things and bloats codesize."
144#if defined(SK_CODEC_DECODES_BMP)
147#if defined(SK_CODEC_DECODES_GIF)
150#if defined(SK_CODEC_DECODES_ICO)
153#if defined(SK_CODEC_DECODES_JPEG)
156#if defined(SK_CODEC_DECODES_PNG)
159#if defined(SK_CODEC_DECODES_WBMP)
162#if defined(SK_CODEC_DECODES_WEBP)
168 if (
data ==
nullptr) {
172#if defined(SK_CODEC_DECODES_BMP)
177#if defined(SK_CODEC_DECODES_GIF)
182#if defined(SK_CODEC_DECODES_ICO)
187#if defined(SK_CODEC_DECODES_JPEG)
192#if defined(SK_CODEC_DECODES_PNG)
197#if defined(SK_CODEC_DECODES_WBMP)
202#if defined(SK_CODEC_DECODES_WEBP)
214 this->
set9(nineMatrixValues);
220 float* fourFloats =
reinterpret_cast<float*
>(cPtr);
222 memcpy(&
color, fourFloats, 4 *
sizeof(
float));
232 const SkVector* radiiValues =
reinterpret_cast<const SkVector*
>(twelveFloats + 4);
253#ifdef CK_ENABLE_WEBGL
257struct ColorSettings {
259 if (colorSpace ==
nullptr || colorSpace->
isSRGB()) {
284 glBindFramebuffer(GL_FRAMEBUFFER, 0);
285 glClearColor(0, 0, 0, 0);
287 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
298 const auto colorSettings = ColorSettings(colorSpace);
299 info.fFormat = colorSettings.pixFormat;
304 colorSettings.colorType,
313 glGetIntegerv(GL_SAMPLES, &sampleCnt);
316 glGetIntegerv(GL_STENCIL_BITS, &stencil);
318 return MakeOnScreenGLSurface(dContext,
width,
height, colorSpace, sampleCnt, stencil);
347#ifdef CK_ENABLE_WEBGPU
351 wgpu::Device
device = wgpu::Device::Acquire(emscripten_webgpu_get_device());
356 uint32_t textureHandle, uint32_t textureFormat,
362 wgpu::TextureFormat
format =
static_cast<wgpu::TextureFormat
>(textureFormat);
363 wgpu::Texture
texture(emscripten_webgpu_import_texture(textureHandle));
364 emscripten_webgpu_release_js_handle(textureHandle);
367 constexpr uint32_t mipLevelCount = 1;
368 constexpr uint32_t sampleCount = 1;
370 GrDawnTextureInfo
info;
373 info.fLevelCount = mipLevelCount;
386bool ReplaceBackendTexture(
SkSurface&
surface, uint32_t textureHandle, uint32_t textureFormat,
388 wgpu::TextureFormat
format =
static_cast<wgpu::TextureFormat
>(textureFormat);
389 wgpu::Texture
texture(emscripten_webgpu_import_texture(textureHandle));
390 emscripten_webgpu_release_js_handle(textureHandle);
392 GrDawnTextureInfo
info;
395 info.fLevelCount = 1;
430 skewY , scaleY, transY,
431 pers0 , pers1 , pers2);
438 p.arcTo(x1, y1, x2, y2, radius);
443 auto arcSize = useSmallArc ? SkPath::ArcSize::kSmall_ArcSize : SkPath::ArcSize::kLarge_ArcSize;
445 orig.
arcTo(rx, ry, xAxisRotate, arcSize, sweep,
x,
y);
450 auto arcSize = useSmallArc ? SkPath::ArcSize::kSmall_ArcSize : SkPath::ArcSize::kLarge_ArcSize;
452 orig.
rArcTo(rx, ry, xAxisRotate, arcSize, sweep,
dx, dy);
461 p.conicTo(x1, y1, x2, y2,
w);
466 p.rConicTo(dx1, dy1, dx2, dy2,
w);
471 p.cubicTo(x1, y1, x2, y2, x3, y3);
476 p.rCubicTo(dx1, dy1, dx2, dy2, dx3, dy3);
504 p.quadTo(x1, y1, x2, y2);
508 p.rQuadTo(dx1, dy1, dx2, dy2);
516 skewY , scaleY, transY,
517 pers0 , pers1 , pers2);
521#ifdef CK_INCLUDE_PATHOPS
527 return Op(pathOne, pathTwo, op, &pathOne);
532 if (
Op(pathOne, pathTwo, op, &
out)) {
533 return emscripten::val(
out);
535 return emscripten::val::null();
541 return emscripten::val(
out);
543 return emscripten::val::null();
554 return emscripten::val(
path);
556 return emscripten::val::null();
567 return emscripten::val(
out);
569 return emscripten::val::null();
593 std::vector<SkScalar> cmds;
597 cmds.insert(cmds.end(), {MOVE, pts[0].x(), pts[0].y()});
600 cmds.insert(cmds.end(), {LINE, pts[1].x(), pts[1].y()});
603 cmds.insert(cmds.end(), {QUAD, pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y()});
606 cmds.insert(cmds.end(), {CONIC,
607 pts[1].x(), pts[1].y(),
608 pts[2].x(), pts[2].y(), *w});
611 cmds.insert(cmds.end(), {CUBIC,
612 pts[1].x(), pts[1].y(),
613 pts[2].x(), pts[2].y(),
614 pts[3].x(), pts[3].y()});
617 cmds.push_back(
CLOSE);
625 const auto* cmds =
reinterpret_cast<const float*
>(cptr);
627 float x1, y1, x2, y2, x3, y3;
630 #define CHECK_NUM_ARGS(n) \
631 if ((i + n) > numCmds) { \
632 SkDebugf("Not enough args to match the verbs. Saw %d commands\n", numCmds); \
633 return emscripten::val::null(); \
636 for(
int i = 0;
i < numCmds;){
640 x1 = cmds[
i++]; y1 = cmds[
i++];
645 x1 = cmds[
i++]; y1 = cmds[
i++];
650 x1 = cmds[
i++]; y1 = cmds[
i++];
651 x2 = cmds[
i++]; y2 = cmds[
i++];
652 path.quadTo(x1, y1, x2, y2);
656 x1 = cmds[
i++]; y1 = cmds[
i++];
657 x2 = cmds[
i++]; y2 = cmds[
i++];
659 path.conicTo(x1, y1, x2, y2, x3);
663 x1 = cmds[
i++]; y1 = cmds[
i++];
664 x2 = cmds[
i++]; y2 = cmds[
i++];
665 x3 = cmds[
i++]; y3 = cmds[
i++];
666 path.cubicTo(x1, y1, x2, y2, x3, y3);
672 SkDebugf(
" path: UNKNOWN command %f, aborting dump...\n", cmds[
i-1]);
673 return emscripten::val::null();
677 #undef CHECK_NUM_ARGS
679 return emscripten::val(
path);
685 const uint8_t* verbs =
reinterpret_cast<const uint8_t*
>(verbsPtr);
686 const float* pts =
reinterpret_cast<const float*
>(ptsPtr);
687 const float* weights =
reinterpret_cast<const float*
>(wtsPtr);
689 #define CHECK_NUM_POINTS(n) \
690 if ((ptIdx + n) > numPts) { \
691 SkDebugf("Not enough points to match the verbs. Saw %d points\n", numPts); \
694 #define CHECK_NUM_WEIGHTS(n) \
695 if ((wtIdx + n) > numWts) { \
696 SkDebugf("Not enough weights to match the verbs. Saw %d weights\n", numWts); \
700 path.incReserve(numPts);
703 for (
int v = 0; v < numVerbs; ++v) {
707 path.moveTo(pts[ptIdx], pts[ptIdx+1]);
712 path.lineTo(pts[ptIdx], pts[ptIdx+1]);
717 path.quadTo(pts[ptIdx], pts[ptIdx+1], pts[ptIdx+2], pts[ptIdx+3]);
723 path.conicTo(pts[ptIdx], pts[ptIdx+1], pts[ptIdx+2], pts[ptIdx+3],
730 path.cubicTo(pts[ptIdx ], pts[ptIdx+1],
731 pts[ptIdx+2], pts[ptIdx+3],
732 pts[ptIdx+4], pts[ptIdx+5]);
740 #undef CHECK_NUM_POINTS
741 #undef CHECK_NUM_WEIGHTS
760 SkDebugf(
"Invalid args to dash()\n");
763 SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
764 if (pe->filterPath(&
path,
path, &rec,
nullptr)) {
767 SkDebugf(
"Could not make dashed path\n");
775 SkDebugf(
"Invalid args to trim(): startT and stopT must be in [0,1]\n");
778 SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
779 if (pe->filterPath(&
path,
path, &rec,
nullptr)) {
800 p.setStrokeCap(opts.
cap);
801 p.setStrokeJoin(opts.
join);
802 p.setStrokeWidth(opts.
width);
811 float* ambiFloats =
reinterpret_cast<float*
>(cPtrAmbi);
812 float* spotFloats =
reinterpret_cast<float*
>(cPtrSpot);
813 SkColor4f ambiColor = { ambiFloats[0], ambiFloats[1], ambiFloats[2], ambiFloats[3]};
814 SkColor4f spotColor = { spotFloats[0], spotFloats[1], spotFloats[2], spotFloats[3]};
817 SkColor resultAmbi, resultSpot;
819 ambiColor.toSkColor(), spotColor.toSkColor(),
820 &resultAmbi, &resultSpot);
823 const SkColor4f ambi4f = SkColor4f::FromColor(resultAmbi);
824 const SkColor4f spot4f = SkColor4f::FromColor(resultSpot);
827 memcpy(ambiFloats, ambi4f.vec(), 4 *
sizeof(
SkScalar));
828 memcpy(spotFloats, spot4f.vec(), 4 *
sizeof(
SkScalar));
831#ifdef CK_INCLUDE_RUNTIME_EFFECT
832struct RuntimeEffectUniform {
840 RuntimeEffectUniform su;
843 su.isInteger =
false;
846 case Type::kFloat:
break;
847 case Type::kFloat2: su.columns = 2;
break;
848 case Type::kFloat3: su.columns = 3;
break;
849 case Type::kFloat4: su.columns = 4;
break;
850 case Type::kFloat2x2: su.columns = 2; su.rows *= 2;
break;
851 case Type::kFloat3x3: su.columns = 3; su.rows *= 3;
break;
852 case Type::kFloat4x4: su.columns = 4; su.rows *= 4;
break;
853 case Type::kInt: su.isInteger =
true;
break;
854 case Type::kInt2: su.columns = 2; su.isInteger =
true;
break;
855 case Type::kInt3: su.columns = 3; su.isInteger =
true;
break;
856 case Type::kInt4: su.columns = 4; su.isInteger =
true;
break;
869 float* fltData =
reinterpret_cast<float*
>(
data);
870 for (
const auto& u : effect.
uniforms()) {
871 RuntimeEffectUniform reu = fromUniform(u);
874 for (
int i = 0;
i < reu.columns * reu.rows; ++
i) {
875 int numAsInt =
static_cast<int>(fltData[reu.slot +
i]);
891 template<
typename ClassType>
918 return emscripten::val(
920 typed_memory_view(
data->size(),
data->bytes())
924#ifdef CK_ENABLE_WEBGL
928JSObject textureCleanup = emscripten::val::null();
930struct TextureReleaseContext {
933 uint32_t webglHandle;
939 auto ctx =
reinterpret_cast<TextureReleaseContext*
>(
rc);
940 textureCleanup.call<
void>(
"deleteTexture", ctx->webglHandle, ctx->texHandle);
946 ExternalWebGLTexture(
GrBackendTexture backendTexture, uint32_t textureHandle, EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context) :
947 fBackendTexture(backendTexture), fWebglHandle(context), fTextureHandle(textureHandle) {}
950 return fBackendTexture;
954 textureCleanup.call<
void>(
"deleteTexture", fWebglHandle, fTextureHandle);
961 uint32_t fWebglHandle;
963 uint32_t fTextureHandle;
970 fCallback(callbackObj) {}
972 ~WebGLTextureImageGenerator()
override {
976 fCallback.call<
void>(
"freeSrc");
984 glInfo.
fID = fCallback.call<uint32_t>(
"makeTexture");
1000 return std::make_unique<ExternalWebGLTexture>(
1001 backendTexture, glInfo.
fID, emscripten_webgl_get_current_context());
1012 auto gen = std::make_unique<WebGLTextureImageGenerator>(
toSkImageInfo(ii), callbackObj);
1031 if (quality >= 100) {
1041 return emscripten::val::null();
1048 constant(
"gpu",
true);
1052#ifdef CK_ENABLE_WEBGL
1053 constant(
"webgl",
true);
1060#ifdef CK_ENABLE_WEBGPU
1061 constant(
"webgpu",
true);
1062 function(
"_MakeGPUTextureSurface", &MakeGPUTextureSurface);
1072 uint8_t* imgData =
reinterpret_cast<uint8_t*
>(iptr);
1075 if (codec ==
nullptr) {
1079 if (aCodec ==
nullptr) {
1084 }), allow_raw_pointers());
1087 uint8_t* imgData =
reinterpret_cast<uint8_t*
>(iptr);
1090 if (codec ==
nullptr) {
1094 }), allow_raw_pointers());
1100 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1105 }), allow_raw_pointers());
1107 function(
"_getShadowLocalBounds", optional_override([](
1112 const SkScalar* nineMatrixValues =
reinterpret_cast<const SkScalar*
>(ctmPtr);
1113 ctm.
set9(nineMatrixValues);
1116 SkRect* outputBounds =
reinterpret_cast<SkRect*
>(outPtr);
1118 flags, outputBounds);
1121#ifdef CK_SERIALIZE_SKP
1124 uint8_t*
d =
reinterpret_cast<uint8_t*
>(dPtr);
1139 if (codec ==
nullptr) {
1143 if (at.has_value()) {
1153 }), allow_raw_pointers());
1157 class_<GrDirectContext>(
"GrDirectContext")
1159 .
function(
"_getResourceCacheLimitBytes",
1161 int maxResources = 0;
1163 self.getResourceCacheLimits(&maxResources, &currMax);
1166 .function(
"_getResourceCacheUsageBytes",
1168 int usedResources = 0;
1169 size_t currUsage = 0;
1170 self.getResourceCacheUsage(&usedResources, &currUsage);
1173 .function(
"_releaseResourcesAndAbandonContext",
1175 .function(
"_setResourceCacheLimitBytes",
1177 int maxResources = 0;
1179 self.getResourceCacheLimits(&maxResources, &currMax);
1180 self.setResourceCacheLimits(maxResources, maxResourceBytes);
1183#ifdef CK_ENABLE_WEBGL
1186 function(
"_setTextureCleanup", optional_override([](
JSObject callbackObj)->
void {
1187 textureCleanup = callbackObj;
1191 class_<SkAnimatedImage>(
"AnimatedImage")
1207 class_<SkBlender>(
"Blender")
1211 class_<SkCanvas>(
"Canvas")
1213 .constructor<SkScalar,SkScalar>()
1223 self.clipRect(*
rect, op, doAntiAlias);
1227 const SkScalar* sixteenMatrixValues =
reinterpret_cast<const SkScalar*
>(mPtr);
1237 .function(
"_drawAtlasOptions", optional_override([](
SkCanvas&
self,
1243 const SkRect* srcRects =
reinterpret_cast<const SkRect*
>(rptr);
1251 }), allow_raw_pointers())
1257 const SkRect* srcRects =
reinterpret_cast<const SkRect*
>(rptr);
1265 }), allow_raw_pointers())
1280 .function(
"_drawGlyphs", optional_override([](
SkCanvas&
self,
1288 reinterpret_cast<const uint16_t*
>(
glyphs),
1289 reinterpret_cast<const SkPoint*
>(positions),
1296 }), allow_raw_pointers())
1302 }), allow_raw_pointers())
1308 }), allow_raw_pointers())
1317 }), allow_raw_pointers())
1327 }), allow_raw_pointers())
1336 }), allow_raw_pointers())
1345 }), allow_raw_pointers())
1353#ifdef CK_INCLUDE_PARAGRAPH
1357 }), allow_raw_pointers())
1360 .function(
"_drawPatch", optional_override([](
SkCanvas&
self,
1366 self.drawPatch(
reinterpret_cast<const SkPoint*
>(cubics),
1413 const char* str =
reinterpret_cast<const char*
>(sptr);
1426 self.getDeviceClipBounds(outputRect);
1433 if (!sixteenMatrixValues) {
1437 m.getRowMajor(sixteenMatrixValues);
1445 if (!nineMatrixValues) {
1449 m.get9(nineMatrixValues);
1453 }), allow_raw_pointers())
1457 size_t dstRowBytes,
int srcX,
int srcY) {
1458 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1461 return self.readPixels(dstInfo, pixels, dstRowBytes, srcX, srcY);
1462 }), allow_raw_pointers())
1471 }), allow_raw_pointers())
1480 size_t srcRowBytes,
int dstX,
int dstY) {
1481 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1484 return self.writePixels(dstInfo, pixels, srcRowBytes, dstX, dstY);
1487 class_<SkColorFilter>(
"ColorFilter")
1496 .class_function(
"_makeMatrix", optional_override([](
WASMPointerF32 fPtr) {
1497 float* twentyFloats =
reinterpret_cast<float*
>(fPtr);
1503 class_<SkContourMeasureIter>(
"ContourMeasureIter")
1507 class_<SkContourMeasure>(
"ContourMeasure")
1513 if (!
self.getPosTan(
distance, pointAndVector, pointAndVector + 1)) {
1514 SkDebugf(
"zero-length path in getPosTan\n");
1520 bool ok =
self.getSegment(startD, stopD, &
p, startWithMoveTo);
1530 class_<SkFont>(
"Font")
1543 self.getWidthsBounds(
glyphs, numGlyphs, outputWidths, outputRects,
paint);
1544 }), allow_raw_pointers())
1546 size_t strLen,
size_t expectedCodePoints,
1548 char* str =
reinterpret_cast<char*
>(sptr);
1552 glyphIDs, expectedCodePoints);
1553 return actualCodePoints;
1557 self.getMetrics(&fm);
1559 JSObject j = emscripten::val::object();
1564 const float rect[] = {
1571 .function(
"_getGlyphIntercepts", optional_override([](
SkFont&
self,
1577 if (
glyphs.size() > (
pos.size() >> 1)) {
1578 return emscripten::val(
"Not enough x,y position pairs for glyphs");
1583 }), allow_raw_pointers())
1600 class_<SkFontMgr>(
"FontMgr")
1602 .class_function(
"_fromData", optional_override([](
WASMPointerU32 dPtr,
1605 auto datas =
reinterpret_cast<const uint8_t**
>(dPtr);
1606 auto sizes =
reinterpret_cast<const size_t*
>(sPtr);
1608 std::unique_ptr<sk_sp<SkData>[]> skdatas(
new sk_sp<SkData>[numFonts]);
1609 for (
int i = 0;
i < numFonts; ++
i) {
1614 }), allow_raw_pointers())
1616 .function(
"getFamilyName", optional_override([](
SkFontMgr&
self,
int index)->JSString {
1617 if (index < 0 || index >=
self.countFamilies()) {
1618 return emscripten::val::null();
1621 self.getFamilyName(index, &
s);
1622 return emscripten::val(
s.c_str());
1624 .function(
"matchFamilyStyle", optional_override([](
SkFontMgr&
self, std::string
name, emscripten::val jsFontStyle)->sk_sp<
SkTypeface> {
1631 return self.matchFamilyStyle(
name.c_str(), style);
1632 }), allow_raw_pointers())
1635 int numFam =
self.countFamilies();
1636 SkDebugf(
"There are %d font families\n", numFam);
1637 for (
int i = 0 ;
i< numFam;
i++) {
1639 self.getFamilyName(
i, &
s);
1644 .function(
"_makeTypefaceFromData", optional_override([](
SkFontMgr&
self,
1647 uint8_t*
font =
reinterpret_cast<uint8_t*
>(fPtr);
1650 return self.makeFromData(fontData);
1651 }), allow_raw_pointers());
1654 class_<SkImage>(
"Image")
1656#ifdef CK_ENABLE_WEBGL
1657 .class_function(
"_makeFromGenerator", &MakeImageFromGenerator)
1661 return self->imageInfo().refColorSpace();
1662 }), allow_raw_pointers())
1679#if defined(ENABLE_GPU)
1685 }), allow_raw_pointers())
1688 return self->withDefaultMipmaps();
1697 }), allow_raw_pointers())
1703 return self->makeShader(tx, ty, {filter, mipmap}, mPtr ? &localMatrix :
nullptr);
1704 }), allow_raw_pointers())
1705#
if defined(ENABLE_GPU)
1708 size_t dstRowBytes,
int srcX,
int srcY,
1710 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1712 return self->readPixels(dContext, ii, pixels, dstRowBytes, srcX, srcY);
1713 }), allow_raw_pointers())
1717 size_t dstRowBytes,
int srcX,
int srcY)->bool {
1718 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1720 return self->readPixels(
nullptr, ii, pixels, dstRowBytes, srcX, srcY);
1721 }), allow_raw_pointers())
1724 class_<SkImageFilter>(
"ImageFilter")
1736 .class_function(
"MakeBlur", optional_override([](
SkScalar sigmaX,
SkScalar sigmaY,
1745 .class_function(
"MakeDilate", optional_override([](
SkScalar radiusX,
SkScalar radiusY,
1749 .class_function(
"MakeDisplacementMap", optional_override([](
SkColorChannel xChannelSelector,
1765 .class_function(
"_MakeDropShadowOnly", optional_override([](
SkScalar dx,
SkScalar dy,
1771 .class_function(
"MakeErode", optional_override([](
SkScalar radiusX,
SkScalar radiusY,
1800 .class_function(
"_MakeMatrixTransformCubic",
1806 .class_function(
"_MakeMatrixTransformOptions",
1817 class_<SkMaskFilter>(
"MaskFilter")
1822 }), allow_raw_pointers());
1824 class_<SkPaint>(
"Paint")
1833 float* fourFloats =
reinterpret_cast<float*
>(cPtr);
1834 memcpy(fourFloats, c.vec(), 4 *
sizeof(
SkScalar));
1849 self.setColor(SkColor4f::FromColor(
color),
nullptr);
1853 self.setColor(SkColor4f::FromColor(
color), colorSpace.
get());
1867 class_<SkColorSpace>(
"ColorSpace")
1875 .class_function(
"_MakeDisplayP3", optional_override([]()->sk_sp<
SkColorSpace> {
1878 .class_function(
"_MakeAdobeRGB", optional_override([]()->sk_sp<
SkColorSpace> {
1882 class_<SkPathEffect>(
"PathEffect")
1887 const float* intervals =
reinterpret_cast<const float*
>(cptr);
1889 }), allow_raw_pointers())
1891 .class_function(
"_MakeLine2D", optional_override([](
SkScalar width,
1894 const SkScalar* nineMatrixValues =
reinterpret_cast<const SkScalar*
>(mPtr);
1895 matrix.set9(nineMatrixValues);
1897 }), allow_raw_pointers())
1899 .class_function(
"_MakePath2D", optional_override([](
WASMPointerF32 mPtr,
1902 const SkScalar* nineMatrixValues =
reinterpret_cast<const SkScalar*
>(mPtr);
1903 matrix.set9(nineMatrixValues);
1905 }), allow_raw_pointers());
1908 class_<SkPath>(
"Path")
1910#ifdef CK_INCLUDE_PATHOPS
1911 .class_function(
"MakeFromOp", &MakePathFromOp)
1918 .function(
"_addArc", optional_override([](
SkPath&
self,
1924 .function(
"_addOval", optional_override([](
SkPath&
self,
1926 bool ccw,
unsigned start)->void {
1930 .function(
"_addCircle", optional_override([](
SkPath&
self,
1939 .function(
"_addPoly", optional_override([](
SkPath&
self,
1941 int count,
bool close)->void {
1945 .function(
"_addRect", optional_override([](
SkPath&
self,
1951 .function(
"_addRRect", optional_override([](
SkPath&
self,
1957 .function(
"_arcToOval", optional_override([](
SkPath&
self,
1970 .function(
"_getPoint", optional_override([](
SkPath&
self,
int index,
1989 .function(
"_transform", select_overload<
void(
SkPath&,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar)>(&
ApplyTransform))
1996#ifdef CK_INCLUDE_PATHOPS
2000 .function(
"makeAsWinding", &MakeAsWinding)
2004 .function(
"toCmds", &
ToCmds)
2008 .function(
"_getBounds", optional_override([](
SkPath&
self,
2013 .function(
"_computeTightBounds", optional_override([](
SkPath&
self,
2018 .function(
"equals", &
Equals)
2021 .function(
"dump", select_overload<
void()
const>(&
SkPath::dump))
2027 class_<SkPictureRecorder>(
"PictureRecorder")
2034 }), allow_raw_pointers())
2037 return self.finishRecordingAsPicture();
2038 }), allow_raw_pointers());
2040 class_<SkPicture>(
"Picture")
2047 return self.makeShader(
tmx,
tmy,
mode, mPtr ? &localMatrix :
nullptr, tileRect);
2048 }), allow_raw_pointers())
2055#ifdef CK_SERIALIZE_SKP
2073 return emscripten::val::null();
2076 }), allow_raw_pointers())
2080 class_<SkShader>(
"Shader")
2083 .class_function(
"_MakeColor",
2088 .class_function(
"MakeFractalNoise", optional_override([](
2091 int tileW,
int tileH)->sk_sp<
SkShader> {
2099 .class_function(
"_MakeLinearGradient", optional_override([](
2114 mPtr ? &localMatrix :
nullptr);
2119 mPtr ? &localMatrix :
nullptr);
2123 }), allow_raw_pointers())
2124 .class_function(
"_MakeRadialGradient", optional_override([](
2137 mPtr ? &localMatrix :
nullptr);
2142 mPtr ? &localMatrix :
nullptr);
2146 }), allow_raw_pointers())
2147 .class_function(
"_MakeSweepGradient", optional_override([](
SkScalar cx,
SkScalar cy,
2161 mPtr ? &localMatrix :
nullptr);
2166 mPtr ? &localMatrix :
nullptr);
2170 }), allow_raw_pointers())
2171 .class_function(
"MakeTurbulence", optional_override([](
2174 int tileW,
int tileH)->sk_sp<
SkShader> {
2179 .class_function(
"_MakeTwoPointConicalGradient", optional_override([](
2187 const SkPoint* startAndEnd =
reinterpret_cast<const SkPoint*
>(fourFloatsPtr);
2194 startAndEnd[1], endRadius,
2197 mPtr ? &localMatrix :
nullptr);
2209 mPtr ? &localMatrix :
nullptr);
2213 }), allow_raw_pointers());
2215#ifdef CK_INCLUDE_RUNTIME_EFFECT
2216 class_<SkSL::DebugTrace>(
"DebugTrace")
2220 self.writeTrace(&wstream);
2222 return std::string(
reinterpret_cast<const char*
>(trace->
bytes()), trace->
size());
2225 value_object<SkRuntimeEffect::TracedShader>(
"TracedShader")
2229 class_<SkRuntimeEffect>(
"RuntimeEffect")
2231 .class_function(
"_Make", optional_override([](std::string sksl,
2232 emscripten::val errHandler
2234 SkString s(sksl.c_str(), sksl.length());
2237 errHandler.call<
void>(
"onError", val(errorText.c_str()));
2242 .class_function(
"_MakeForBlender", optional_override([](std::string sksl,
2243 emscripten::val errHandler
2245 SkString s(sksl.c_str(), sksl.length());
2248 errHandler.call<
void>(
"onError", val(errorText.c_str()));
2253 .class_function(
"MakeTraced", optional_override([](
2262 bool shouldOwnUniforms,
2264 void* uniformData =
reinterpret_cast<void*
>(fPtr);
2265 castUniforms(uniformData, fLen,
self);
2267 if (shouldOwnUniforms) {
2274 return self.makeShader(uniforms,
nullptr, 0, mPtr ? &localMatrix :
nullptr);
2279 bool shouldOwnUniforms,
2283 void* uniformData =
reinterpret_cast<void*
>(fPtr);
2284 castUniforms(uniformData, fLen,
self);
2286 if (shouldOwnUniforms) {
2294 for (
size_t i = 0;
i < cLen;
i++) {
2297 children[
i] = sk_ref_sp<SkShader>(childrenPtrs[
i]);
2300 auto s =
self.makeShader(uniforms, children, cLen, mPtr ? &localMatrix :
nullptr);
2307 bool shouldOwnUniforms)->sk_sp<
SkBlender> {
2308 void* uniformData =
reinterpret_cast<void*
>(fPtr);
2309 castUniforms(uniformData, fLen,
self);
2311 if (shouldOwnUniforms) {
2317 return self.makeBlender(uniforms, {});
2320 return self.uniforms().size();
2323 return self.uniformSize() /
sizeof(
float);
2326 auto it =
self.uniforms().begin() +
i;
2327 return emscripten::val(std::string(it->name).c_str());
2329 .function(
"getUniform", optional_override([](
SkRuntimeEffect&
self,
int i)->RuntimeEffectUniform {
2330 auto it =
self.uniforms().begin() +
i;
2331 RuntimeEffectUniform su = fromUniform(*it);
2335 value_object<RuntimeEffectUniform>(
"RuntimeEffectUniform")
2336 .field(
"columns", &RuntimeEffectUniform::columns)
2337 .field(
"rows", &RuntimeEffectUniform::rows)
2338 .field(
"slot", &RuntimeEffectUniform::slot)
2339 .field(
"isInteger", &RuntimeEffectUniform::isInteger);
2341 constant(
"rt_effect",
true);
2344 class_<SkSurface>(
"Surface")
2346 .class_function(
"_makeRasterDirect", optional_override([](
const SimpleImageInfo ii,
2349 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
2352 }), allow_raw_pointers())
2354#ifdef CK_ENABLE_WEBGL
2360 const auto& ii =
self.imageInfo();
2364#ifdef CK_ENABLE_WEBGL
2365 .function(
"_makeImageFromTexture", optional_override([](
SkSurface&
self,
2366 uint32_t webglHandle, uint32_t texHandle,
2368 auto releaseCtx =
new TextureReleaseContext{webglHandle, texHandle};
2384#ifdef CK_ENABLE_WEBGPU
2385 .function(
"_replaceBackendTexture", optional_override([](
SkSurface&
self,
2386 uint32_t texHandle, uint32_t texFormat,
2388 return ReplaceBackendTexture(
self, texHandle, texFormat,
width,
height);
2394 return self.makeImageSnapshot();
2400 }), allow_raw_pointers())
2403 return self.getCanvas()->recordingContext() !=
nullptr;
2405 .function(
"sampleCnt", optional_override([](
SkSurface&
self)->int {
2408 return (backendRT.isValid()) ? backendRT.sampleCnt() : 0;
2410 .function(
"_resetContext",optional_override([](
SkSurface&
self)->void {
2414 .function(
"reportBackendTypeIsGPU", optional_override([](
SkSurface&
self) ->
bool {
2421 class_<SkTextBlob>(
"TextBlob")
2423 .class_function(
"_MakeFromRSXform", optional_override([](
WASMPointerU8 sptr,
2427 const char* str =
reinterpret_cast<const char*
>(sptr);
2431 }), allow_raw_pointers())
2432 .class_function(
"_MakeFromRSXformGlyphs", optional_override([](
WASMPointerU16 gPtr,
2440 }), allow_raw_pointers())
2441 .class_function(
"_MakeFromText", optional_override([](
WASMPointerU8 sptr,
2443 const char* str =
reinterpret_cast<const char*
>(sptr);
2445 }), allow_raw_pointers())
2446 .class_function(
"_MakeFromGlyphs", optional_override([](
WASMPointerU16 gPtr,
2450 }), allow_raw_pointers());
2452 class_<SkTypeface>(
"Typeface")
2455#if defined(CK_EMBED_FONT)
2456 if (SK_EMBEDDED_FONTS.
count == 0) {
2463 auto stream = std::make_unique<SkMemoryStream>(fontEntry.
data, fontEntry.
size,
false);
2466 return default_face;
2470 }), allow_raw_pointers())
2471 .class_function(
"_MakeTypefaceFromData", optional_override([](
2473 uint8_t*
font =
reinterpret_cast<uint8_t*
>(fPtr);
2477 }), allow_raw_pointers())
2479 size_t strLen,
size_t expectedCodePoints,
2481 char* str =
reinterpret_cast<char*
>(sptr);
2485 glyphIDs, expectedCodePoints);
2486 return actualCodePoints;
2490 class_<SkVertices>(
"Vertices")
2500 class_<SkVertices::Builder>(
"_VerticesBuilder")
2520 enum_<SkAlphaType>(
"AlphaType")
2525 enum_<SkBlendMode>(
"BlendMode")
2556 enum_<SkBlurStyle>(
"BlurStyle")
2562 enum_<SkClipOp>(
"ClipOp")
2566 enum_<SkColorChannel>(
"ColorChannel")
2572 enum_<SkColorType>(
"ColorType")
2583 enum_<SkPathFillType>(
"FillType")
2587 enum_<SkFilterMode>(
"FilterMode")
2593 enum_<SkEncodedImageFormat>(
"ImageFormat")
2598 enum_<SkMipmapMode>(
"MipmapMode")
2603 enum_<SkPaint::Style>(
"PaintStyle")
2604 .value(
"Fill", SkPaint::Style::kFill_Style)
2605 .value(
"Stroke", SkPaint::Style::kStroke_Style);
2607 enum_<SkPath1DPathEffect::Style>(
"Path1DEffect")
2608 .value(
"Translate", SkPath1DPathEffect::Style::kTranslate_Style)
2609 .value(
"Rotate", SkPath1DPathEffect::Style::kRotate_Style)
2610 .value(
"Morph", SkPath1DPathEffect::Style::kMorph_Style);
2612#ifdef CK_INCLUDE_PATHOPS
2613 enum_<SkPathOp>(
"PathOp")
2621 enum_<SkCanvas::PointMode>(
"PointMode")
2622 .value(
"Points", SkCanvas::PointMode::kPoints_PointMode)
2623 .value(
"Lines", SkCanvas::PointMode::kLines_PointMode)
2624 .value(
"Polygon", SkCanvas::PointMode::kPolygon_PointMode);
2626 enum_<SkPaint::Cap>(
"StrokeCap")
2627 .value(
"Butt", SkPaint::Cap::kButt_Cap)
2628 .value(
"Round", SkPaint::Cap::kRound_Cap)
2629 .value(
"Square", SkPaint::Cap::kSquare_Cap);
2631 enum_<SkPaint::Join>(
"StrokeJoin")
2632 .value(
"Miter", SkPaint::Join::kMiter_Join)
2633 .value(
"Round", SkPaint::Join::kRound_Join)
2634 .value(
"Bevel", SkPaint::Join::kBevel_Join);
2637 enum_<SkFontHinting>(
"FontHinting")
2643 enum_<SkFont::Edging>(
"FontEdging")
2644#ifndef CK_NO_ALIAS_FONT
2651 enum_<SkTileMode>(
"TileMode")
2657 enum_<SkVertices::VertexMode>(
"VertexMode")
2658 .value(
"Triangles", SkVertices::VertexMode::kTriangles_VertexMode)
2659 .value(
"TrianglesStrip", SkVertices::VertexMode::kTriangleStrip_VertexMode)
2660 .value(
"TriangleFan", SkVertices::VertexMode::kTriangleFan_VertexMode);
2666 value_object<SimpleImageInfo>(
"ImageInfo")
2673 value_object<StrokeOpts>(
"StrokeOpts")
2680 constant(
"MOVE_VERB",
MOVE);
2681 constant(
"LINE_VERB",
LINE);
2682 constant(
"QUAD_VERB",
QUAD);
2683 constant(
"CONIC_VERB",
CONIC);
2684 constant(
"CUBIC_VERB",
CUBIC);
2685 constant(
"CLOSE_VERB",
CLOSE);
2687 constant(
"SaveLayerInitWithPrevious", (
int)SkCanvas::SaveLayerFlagsSet::kInitWithPrevious_SaveLayerFlag);
2688 constant(
"SaveLayerF16ColorType", (
int)SkCanvas::SaveLayerFlagsSet::kF16ColorType);
2694#ifdef CK_INCLUDE_PARAGRAPH
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
@ kTextureBinding_GrGLBackendState
@ kRenderTarget_GrGLBackendState
static const int points[]
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kOuter_SkBlurStyle
nothing inside, fuzzy outside
@ kSolid_SkBlurStyle
solid inside, fuzzy outside
@ kInner_SkBlurStyle
fuzzy inside, nothing outside
@ kNormal_SkBlurStyle
fuzzy inside and outside
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ 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
@ 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
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ 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
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static float SkBits2Float(uint32_t bits)
#define sk_float_floor2int(x)
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Data(SkSpan< sk_sp< SkData > >)
@ kNormal
glyph outlines modified to improve constrast
@ kNone
glyph outlines unchanged
@ kSlight
minimal modification to improve constrast
@ kFull
modifies glyph outlines for maximum constrast
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kGlyphID
uses two byte words to represent glyph indices
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool ok(int result)
bool SK_API AsWinding(const SkPath &path, SkPath *result)
@ kReverseDifference_SkPathOp
subtract the first path from the op path
@ kDifference_SkPathOp
subtract the op path from the first path
@ kIntersect_SkPathOp
intersect the two paths
@ kUnion_SkPathOp
union (inclusive-or) the two paths
@ kXOR_SkPathOp
exclusive-or the two paths
bool SK_API Simplify(const SkPath &path, SkPath *result)
@ kClose
SkPath::RawIter returns 0 points.
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
@ kQuad
SkPath::RawIter returns 3 points.
@ kMove
SkPath::RawIter returns 1 point.
@ kLine
SkPath::RawIter returns 2 points.
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
#define SkScalarFloorToInt(x)
@ kDirectionalLight_ShadowFlag
@ kGeometricOnly_ShadowFlag
@ kTransparentOccluder_ShadowFlag
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
constexpr int SkToInt(S x)
static SkScalar center(float pos0, float pos1)
emscripten::val SkPathOrNull
TypedArray MakeTypedArray(int count, const T src[])
emscripten::val Float32Array
emscripten::val Uint8Array
SkColor4f ptrToSkColor4f(WASMPointerF32 cPtr)
void ApplyReset(SkPath &p)
void ApplyTransform(SkPath &orig, SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
bool ApplyStroke(SkPath &path, StrokeOpts opts)
SkImageInfo toSkImageInfo(const SimpleImageInfo &sii)
void ApplyRMoveTo(SkPath &p, SkScalar dx, SkScalar dy)
void ApplyRQuadTo(SkPath &p, SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2)
void PathAddVerbsPointsWeights(SkPath &path, WASMPointerU8 verbsPtr, int numVerbs, WASMPointerF32 ptsPtr, int numPts, WASMPointerF32 wtsPtr, int numWts)
void ApplyClose(SkPath &p)
void ApplyRewind(SkPath &p)
SkPathOrNull MakePathFromCmds(WASMPointerF32 cptr, int numCmds)
#define CHECK_NUM_WEIGHTS(n)
void ApplyRCubicTo(SkPath &p, SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, SkScalar dx3, SkScalar dy3)
void ApplyRArcToArcSize(SkPath &orig, SkScalar rx, SkScalar ry, SkScalar xAxisRotate, bool useSmallArc, bool ccw, SkScalar dx, SkScalar dy)
void ApplyRConicTo(SkPath &p, SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, SkScalar w)
sk_sp< SkData > alwaysSaveTypefaceBytes(SkTypeface *face, void *)
void ApplyCubicTo(SkPath &p, SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
void ApplyArcToTangent(SkPath &p, SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius)
void ApplyMoveTo(SkPath &p, SkScalar x, SkScalar y)
SkPathOrNull MakePathFromSVGString(std::string str)
void ApplyConicTo(SkPath &p, SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
void ApplyAddPath(SkPath &orig, const SkPath &newPath, SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2, bool extendPath)
void ApplyArcToArcSize(SkPath &orig, SkScalar rx, SkScalar ry, SkScalar xAxisRotate, bool useSmallArc, bool ccw, SkScalar x, SkScalar y)
SkRRect ptrToSkRRect(WASMPointerF32 fPtr)
SkPathOrNull MakePathFromInterpolation(const SkPath &path1, const SkPath &path2, SkScalar weight)
EMSCRIPTEN_BINDINGS(Skia)
bool ApplyDash(SkPath &path, SkScalar on, SkScalar off, SkScalar phase)
Uint8Array toBytes(sk_sp< SkData > data)
JSString ToSVGString(const SkPath &path)
#define CHECK_NUM_POINTS(n)
static Uint8Array encodeImage(GrDirectContext *dContext, sk_sp< SkImage > img, SkEncodedImageFormat fmt, int quality)
Float32Array ToCmds(const SkPath &path)
#define CHECK_NUM_ARGS(n)
SkPath MakePathFromVerbsPointsWeights(WASMPointerU8 verbsPtr, int numVerbs, WASMPointerF32 ptsPtr, int numPts, WASMPointerF32 wtsPtr, int numWts)
void ApplyQuadTo(SkPath &p, SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
void ApplyRLineTo(SkPath &p, SkScalar dx, SkScalar dy)
bool Equals(const SkPath &a, const SkPath &b)
bool CanInterpolate(const SkPath &path1, const SkPath &path2)
bool ApplyTrim(SkPath &path, SkScalar startT, SkScalar stopT, bool isComplement)
void computeTonalColors(WASMPointerF32 cPtrAmbi, WASMPointerF32 cPtrSpot)
std::unique_ptr< SkCodec > DecodeImageData(sk_sp< SkData > data)
SkPath CopyPath(const SkPath &a)
void ApplyLineTo(SkPath &p, SkScalar x, SkScalar y)
void resetContext(uint32_t state=kAll_GrBackendState)
void releaseResourcesAndAbandonContext()
virtual std::unique_ptr< GrExternalTexture > generateExternalTexture(GrRecordingContext *, skgpu::Mipmapped)=0
virtual GrBackendTexture getBackendTexture()=0
static std::unique_ptr< SkAndroidCodec > MakeFromCodec(std::unique_ptr< SkCodec >)
static sk_sp< SkAnimatedImage > Make(std::unique_ptr< SkAndroidCodec >, const SkImageInfo &info, SkIRect cropRect, sk_sp< SkPicture > postProcess)
int getFrameCount() const
int currentFrameDuration()
sk_sp< SkImage > getCurrentFrame()
int getRepetitionCount() const
static sk_sp< SkBlender > Mode(SkBlendMode mode)
void translate(SkScalar dx, SkScalar dy)
void drawPaint(const SkPaint &paint)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
void rotate(SkScalar degrees)
void restoreToCount(int saveCount)
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
void drawPicture(const SkPicture *picture)
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
void skew(SkScalar sx, SkScalar sy)
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
static sk_sp< SkColorFilter > Compose(const sk_sp< SkColorFilter > &outer, sk_sp< SkColorFilter > inner)
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkColorFilter > SRGBToLinearGamma()
static sk_sp< SkColorFilter > Lerp(float t, sk_sp< SkColorFilter > dst, sk_sp< SkColorFilter > src)
static sk_sp< SkColorFilter > LinearToSRGBGamma()
static bool Equals(const SkColorSpace *, const SkColorSpace *)
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
sk_sp< SkContourMeasure > next()
static sk_sp< SkPathEffect > Make(SkScalar radius)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
const uint8_t * bytes() const
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
static sk_sp< SkPathEffect > Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist=0)
sk_sp< SkData > detachAsData()
int countFamilies() const
void setSubpixel(bool subpixel)
void setScaleX(SkScalar scaleX)
void setLinearMetrics(bool linearMetrics)
SkTypeface * getTypeface() const
void setTypeface(sk_sp< SkTypeface > tf)
void setEdging(Edging edging)
void setSize(SkScalar textSize)
SkScalar getScaleX() const
SkScalar getSkewX() const
void setSkewX(SkScalar skewX)
void setHinting(SkFontHinting hintingLevel)
@ kAntiAlias
may have transparent pixels on glyph edges
@ kAlias
no transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
void setEmbolden(bool embolden)
void setEmbeddedBitmaps(bool embeddedBitmaps)
static sk_sp< SkShader > MakeTwoPointConical(const SkPoint &start, SkScalar startRadius, const SkPoint &end, SkScalar endRadius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkShader > MakeSweep(SkScalar cx, SkScalar cy, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, SkScalar startAngle, SkScalar endAngle, uint32_t flags, const SkMatrix *localMatrix)
static sk_sp< SkShader > MakeRadial(const SkPoint ¢er, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
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 sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DropShadow(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DropShadowOnly(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DisplacementMap(SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale, sk_sp< SkImageFilter > displacement, sk_sp< SkImageFilter > color, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Compose(sk_sp< SkImageFilter > outer, sk_sp< SkImageFilter > inner)
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
static sk_sp< SkImageFilter > Blend(SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Shader(sk_sp< SkShader > shader, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkPathEffect > Make(SkScalar width, const SkMatrix &matrix)
static SkM44 RowMajor(const SkScalar r[16])
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
SkMatrix & set9(const SkScalar buffer[9])
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
SkScalar getStrokeMiter() const
void setStyle(Style style)
void setStrokeMiter(SkScalar miter)
void setAntiAlias(bool aa)
void setDither(bool dither)
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
void setStrokeCap(Cap cap)
@ kStroke_Style
set to stroke geometry
void setStrokeJoin(Join join)
void setMaskFilter(sk_sp< SkMaskFilter > maskFilter)
void setShader(sk_sp< SkShader > shader)
void setPathEffect(sk_sp< SkPathEffect > pathEffect)
SkScalar getStrokeWidth() const
void setBlendMode(SkBlendMode mode)
void setColorFilter(sk_sp< SkColorFilter > colorFilter)
void setBlender(sk_sp< SkBlender > blender)
Join getStrokeJoin() const
void setStrokeWidth(SkScalar width)
static SkString ToSVGString(const SkPath &, PathEncoding=PathEncoding::Absolute)
static bool FromSVGString(const char str[], SkPath *)
static sk_sp< SkPathEffect > Make(const SkPath &path, SkScalar advance, SkScalar phase, Style)
static sk_sp< SkPathEffect > Make(const SkMatrix &matrix, const SkPath &path)
SkPath & rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, SkScalar dx, SkScalar dy)
SkPath & arcTo(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
SkPathFillType getFillType() const
void setFillType(SkPathFillType ft)
SkPath & addPath(const SkPath &src, SkScalar dx, SkScalar dy, AddPathMode mode=kAppend_AddPathMode)
bool isInterpolatable(const SkPath &compare) const
bool interpolate(const SkPath &ending, SkScalar weight, SkPath *out) const
SkPath & setIsVolatile(bool isVolatile)
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
bool contains(SkScalar x, SkScalar y) const
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
virtual size_t approximateBytesUsed() const =0
void setRectRadii(const SkRect &rect, const SkVector radii[4])
static size_t GetTotalBytesUsed()
static size_t GetTotalByteLimit()
static size_t SetTotalByteLimit(size_t newLimit)
size_t uniformSize() const
SkSpan< const Uniform > uniforms() const
static Result MakeForBlender(SkString sksl, const Options &)
static Result MakeForShader(SkString sksl, const Options &)
static TracedShader MakeTraced(sk_sp< SkShader > shader, const SkIPoint &traceCoord)
static void DrawShadow(SkCanvas *canvas, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, SkColor ambientColor, SkColor spotColor, uint32_t flags=SkShadowFlags::kNone_ShadowFlag)
static bool GetLocalBounds(const SkMatrix &ctm, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, uint32_t flags, SkRect *bounds)
static void ComputeTonalColors(SkColor inAmbientColor, SkColor inSpotColor, SkColor *outAmbientColor, SkColor *outSpotColor)
@ kDiscard_ContentChangeMode
discards surface on change
@ kFlushRead
back-end object is readable
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
static sk_sp< SkTextBlob > MakeFromRSXform(const void *text, size_t byteLength, const SkRSXform xform[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
static sk_sp< SkPathEffect > Make(SkScalar startT, SkScalar stopT, Mode=Mode::kNormal)
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
static void Register(FactoryId id, sk_sp< SkTypeface >(*make)(std::unique_ptr< SkStreamAsset >, const SkFontArguments &))
sk_sp< SkVertices > detach()
uint32_t uniqueID() const
@ kWhiteSpace_VisitorFlag
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlutterSemanticsFlag flags
uint32_t uint32_t * format
Dart_NativeFunction function
static sk_sp< GrDirectContext > MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
SkRTreeFactory bbhFactory
SK_API GrBackendRenderTarget MakeGL(int width, int height, int sampleCnt, int stencilBits, const GrGLFramebufferInfo &glInfo)
SK_API GrBackendTexture MakeGL(int width, int height, skgpu::Mipmapped, const GrGLTextureInfo &glInfo, std::string_view label={})
SK_API sk_sp< GrDirectContext > MakeGL(sk_sp< const GrGLInterface >, const GrContextOptions &)
SK_API sk_sp< const GrGLInterface > MakeWebGL()
SK_API bool IsBmp(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsGif(const void *, size_t)
SK_API bool IsIco(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API sk_sp< SkImage > DeferredFromTextureGenerator(std::unique_ptr< GrTextureGenerator > gen)
SK_API sk_sp< SkImage > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API bool IsJpeg(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
static constexpr skcms_Matrix3x3 kAdobeRGB
static constexpr skcms_Matrix3x3 kDisplayP3
static constexpr skcms_TransferFunction k2Dot2
static constexpr skcms_TransferFunction kSRGB
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsPng(const void *, size_t)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
sk_sp< const SkImage > atlas
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
sk_sp< const SkImage > image
sk_sp< const SkImageFilter > backdrop
PODArray< SkRSXform > xforms
sk_sp< SkBlender > blender SkRect rect
PODArray< SkColor > colors
SkSamplingOptions sampling
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
SK_API sk_sp< SkShader > Color(SkColor)
SK_API sk_sp< SkShader > MakeTurbulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize *tileSize=nullptr)
SK_API sk_sp< SkShader > MakeFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize *tileSize=nullptr)
SK_API sk_sp< SkSurface > WrapPixels(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
SK_API sk_sp< SkSurface > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API GrBackendRenderTarget GetBackendRenderTarget(SkSurface *, BackendHandleAccess)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
SK_API bool IsWbmp(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsWebp(const void *, size_t)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
void raw_destructor< SkTextBlob >(SkTextBlob *ptr)
void raw_destructor(ClassType *)
void raw_destructor< SkTypeface >(SkTypeface *ptr)
void raw_destructor< SkVertices >(SkVertices *ptr)
void raw_destructor< SkContourMeasure >(SkContourMeasure *ptr)
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
font
Font Metadata and Metrics.
const myers::Point & get< 0 >(const myers::Segment &s)
SK_API void FlushAndSubmit(sk_sp< SkSurface >)
SK_API std::unique_ptr< Context > MakeDawn(const DawnBackendContext &, const ContextOptions &)
SkSamplingOptions(SkFilterMode::kLinear))
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
static SkString fmt(SkColor4f c)
bool EMSCRIPTEN_KEEPALIVE ApplySimplify(SkPath &path)
bool EMSCRIPTEN_KEEPALIVE ApplyPathOp(SkPath &pathOne, const SkPath &pathTwo, SkPathOp op)
OptionalMatrix(WASMPointerF32 mPtr)
sk_sp< SkColorSpace > colorSpace
SkDeserialImageFromDataProc fImageDataProc
SkScalar fTop
greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable ...
SkScalar fLeading
distance to add between lines, typically positive or zero
SkScalar fBottom
greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable ...
uint32_t fFlags
FontMetricsFlags indicating which metrics are valid.
SkScalar fAscent
distance to reserve above baseline, typically negative
@ kBoundsInvalid_Flag
set if fTop, fBottom, fXMin, fXMax invalid
SkScalar fDescent
distance to reserve below baseline, typically positive
SkScalar fXMin
greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with vari...
SkScalar fXMax
greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with var...
static constexpr SkIPoint Make(int32_t x, int32_t y)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkAlphaType alphaType() const
SkColorType colorType() const
static sk_sp< SkColorFilter > Make()
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
sk_sp< SkSL::DebugTrace > debugTrace
SkSerialImageProc fImageProc
SkSerialTypefaceProc fTypefaceProc
std::shared_ptr< const fml::Mapping > data