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));
231 const SkRect rect =
reinterpret_cast<const SkRect*
>(twelveFloats)[0];
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);
445 orig.
arcTo(rx, ry, xAxisRotate, arcSize, sweep,
x,
y);
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");
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");
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);
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;
862void castUniforms(
void* data,
size_t dataLen,
const SkRuntimeEffect& effect) {
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");
991 auto backendTexture =
997 return std::make_unique<ExternalWebGLTexture>(
998 backendTexture, glInfo.
fID, emscripten_webgl_get_current_context());
1009 auto gen = std::make_unique<WebGLTextureImageGenerator>(
toSkImageInfo(ii), callbackObj);
1028 if (quality >= 100) {
1038 return emscripten::val::null();
1045 constant(
"gpu",
true);
1049#ifdef CK_ENABLE_WEBGL
1050 constant(
"webgl",
true);
1057#ifdef CK_ENABLE_WEBGPU
1058 constant(
"webgpu",
true);
1059 function(
"_MakeGPUTextureSurface", &MakeGPUTextureSurface);
1069 uint8_t* imgData =
reinterpret_cast<uint8_t*
>(iptr);
1072 if (codec ==
nullptr) {
1076 if (aCodec ==
nullptr) {
1081 }), allow_raw_pointers());
1084 uint8_t* imgData =
reinterpret_cast<uint8_t*
>(iptr);
1087 if (codec ==
nullptr) {
1090 return std::get<0>(codec->getImage());
1091 }), allow_raw_pointers());
1097 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1102 }), allow_raw_pointers());
1104 function(
"_getShadowLocalBounds", optional_override([](
1109 const SkScalar* nineMatrixValues =
reinterpret_cast<const SkScalar*
>(ctmPtr);
1110 ctm.
set9(nineMatrixValues);
1113 SkRect* outputBounds =
reinterpret_cast<SkRect*
>(outPtr);
1115 flags, outputBounds);
1118#ifdef CK_SERIALIZE_SKP
1121 uint8_t*
d =
reinterpret_cast<uint8_t*
>(dPtr);
1136 if (codec ==
nullptr) {
1140 if (at.has_value()) {
1146 return std::get<0>(codec->getImage(
info));
1150 }), allow_raw_pointers());
1154 class_<GrDirectContext>(
"GrDirectContext")
1156 .
function(
"_getResourceCacheLimitBytes",
1158 int maxResources = 0;
1160 self.getResourceCacheLimits(&maxResources, &currMax);
1163 .function(
"_getResourceCacheUsageBytes",
1165 int usedResources = 0;
1166 size_t currUsage = 0;
1167 self.getResourceCacheUsage(&usedResources, &currUsage);
1170 .function(
"_releaseResourcesAndAbandonContext",
1172 .function(
"_setResourceCacheLimitBytes",
1174 int maxResources = 0;
1176 self.getResourceCacheLimits(&maxResources, &currMax);
1177 self.setResourceCacheLimits(maxResources, maxResourceBytes);
1180#ifdef CK_ENABLE_WEBGL
1183 function(
"_setTextureCleanup", optional_override([](
JSObject callbackObj)->
void {
1184 textureCleanup = callbackObj;
1188 class_<SkAnimatedImage>(
"AnimatedImage")
1204 class_<SkBlender>(
"Blender")
1208 class_<SkCanvas>(
"Canvas")
1210 .constructor<SkScalar,SkScalar>()
1219 const SkRect* rect =
reinterpret_cast<const SkRect*
>(fPtr);
1220 self.clipRect(*rect, op, doAntiAlias);
1224 const SkScalar* sixteenMatrixValues =
reinterpret_cast<const SkScalar*
>(mPtr);
1231 const SkRect* oval =
reinterpret_cast<const SkRect*
>(fPtr);
1232 self.drawArc(*oval, startAngle, sweepAngle, useCenter,
paint);
1234 .function(
"_drawAtlasOptions", optional_override([](
SkCanvas&
self,
1240 const SkRect* srcRects =
reinterpret_cast<const SkRect*
>(rptr);
1241 const SkColor* colors =
nullptr;
1243 colors =
reinterpret_cast<const SkColor*
>(cptr);
1246 self.drawAtlas(atlas.
get(), dstXforms, srcRects, colors,
count, mode, sampling,
1248 }), allow_raw_pointers())
1254 const SkRect* srcRects =
reinterpret_cast<const SkRect*
>(rptr);
1255 const SkColor* colors =
nullptr;
1257 colors =
reinterpret_cast<const SkColor*
>(cptr);
1260 self.drawAtlas(atlas.
get(), dstXforms, srcRects, colors,
count, mode, sampling,
1262 }), allow_raw_pointers())
1277 .function(
"_drawGlyphs", optional_override([](
SkCanvas&
self,
1285 reinterpret_cast<const uint16_t*
>(
glyphs),
1286 reinterpret_cast<const SkPoint*
>(positions),
1293 }), allow_raw_pointers())
1299 }), allow_raw_pointers())
1305 }), allow_raw_pointers())
1311 const SkRect* dst =
reinterpret_cast<const SkRect*
>(dstPtr);
1314 }), allow_raw_pointers())
1319 const SkRect* src =
reinterpret_cast<const SkRect*
>(srcPtr);
1320 const SkRect* dst =
reinterpret_cast<const SkRect*
>(dstPtr);
1324 }), allow_raw_pointers())
1329 const SkRect* src =
reinterpret_cast<const SkRect*
>(srcPtr);
1330 const SkRect* dst =
reinterpret_cast<const SkRect*
>(dstPtr);
1333 }), allow_raw_pointers())
1338 const SkRect* src =
reinterpret_cast<const SkRect*
>(srcPtr);
1339 const SkRect* dst =
reinterpret_cast<const SkRect*
>(dstPtr);
1341 self.drawImageRect(
image.
get(), *src, *dst, {filter, mipmap},
paint, constraint);
1342 }), allow_raw_pointers())
1346 const SkRect* oval =
reinterpret_cast<const SkRect*
>(fPtr);
1350#ifdef CK_INCLUDE_PARAGRAPH
1354 }), allow_raw_pointers())
1357 .function(
"_drawPatch", optional_override([](
SkCanvas&
self,
1363 self.drawPatch(
reinterpret_cast<const SkPoint*
>(cubics),
1364 reinterpret_cast<const SkColor*
>(colors),
1365 reinterpret_cast<const SkPoint*
>(texs),
1382 const SkRect* rect =
reinterpret_cast<const SkRect*
>(fPtr);
1410 const char* str =
reinterpret_cast<const char*
>(sptr);
1423 self.getDeviceClipBounds(outputRect);
1430 if (!sixteenMatrixValues) {
1434 m.getRowMajor(sixteenMatrixValues);
1442 if (!nineMatrixValues) {
1446 m.get9(nineMatrixValues);
1450 }), allow_raw_pointers())
1454 size_t dstRowBytes,
int srcX,
int srcY) {
1455 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1458 return self.readPixels(dstInfo, pixels, dstRowBytes, srcX, srcY);
1459 }), allow_raw_pointers())
1468 }), allow_raw_pointers())
1477 size_t srcRowBytes,
int dstX,
int dstY) {
1478 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1481 return self.writePixels(dstInfo, pixels, srcRowBytes, dstX, dstY);
1484 class_<SkColorFilter>(
"ColorFilter")
1493 .class_function(
"_makeMatrix", optional_override([](
WASMPointerF32 fPtr) {
1494 float* twentyFloats =
reinterpret_cast<float*
>(fPtr);
1500 class_<SkContourMeasureIter>(
"ContourMeasureIter")
1504 class_<SkContourMeasure>(
"ContourMeasure")
1510 if (!
self.getPosTan(distance, pointAndVector, pointAndVector + 1)) {
1511 SkDebugf(
"zero-length path in getPosTan\n");
1517 bool ok =
self.getSegment(startD, stopD, &p, startWithMoveTo);
1527 class_<SkFont>(
"Font")
1540 self.getWidthsBounds(
glyphs, numGlyphs, outputWidths, outputRects,
paint);
1541 }), allow_raw_pointers())
1543 size_t strLen,
size_t expectedCodePoints,
1545 char* str =
reinterpret_cast<char*
>(sptr);
1549 glyphIDs, expectedCodePoints);
1550 return actualCodePoints;
1554 self.getMetrics(&fm);
1556 JSObject j = emscripten::val::object();
1561 const float rect[] = {
1568 .function(
"_getGlyphIntercepts", optional_override([](
SkFont&
self,
1574 if (
glyphs.size() > (
pos.size() >> 1)) {
1575 return emscripten::val(
"Not enough x,y position pairs for glyphs");
1580 }), allow_raw_pointers())
1597 class_<SkFontMgr>(
"FontMgr")
1599 .class_function(
"_fromData", optional_override([](
WASMPointerU32 dPtr,
1602 auto datas =
reinterpret_cast<const uint8_t**
>(dPtr);
1603 auto sizes =
reinterpret_cast<const size_t*
>(sPtr);
1605 std::unique_ptr<sk_sp<SkData>[]> skdatas(
new sk_sp<SkData>[numFonts]);
1606 for (
int i = 0; i < numFonts; ++i) {
1611 }), allow_raw_pointers())
1613 .function(
"getFamilyName", optional_override([](
SkFontMgr&
self,
int index)->JSString {
1614 if (index < 0 || index >=
self.countFamilies()) {
1615 return emscripten::val::null();
1618 self.getFamilyName(index, &
s);
1619 return emscripten::val(
s.c_str());
1621 .function(
"matchFamilyStyle", optional_override([](
SkFontMgr&
self, std::string
name, emscripten::val jsFontStyle)->sk_sp<
SkTypeface> {
1628 return self.matchFamilyStyle(
name.c_str(), style);
1629 }), allow_raw_pointers())
1632 int numFam =
self.countFamilies();
1633 SkDebugf(
"There are %d font families\n", numFam);
1634 for (
int i = 0 ; i< numFam; i++) {
1636 self.getFamilyName(i, &
s);
1641 .function(
"_makeTypefaceFromData", optional_override([](
SkFontMgr&
self,
1644 uint8_t* font =
reinterpret_cast<uint8_t*
>(fPtr);
1647 return self.makeFromData(fontData);
1648 }), allow_raw_pointers());
1651 class_<SkImage>(
"Image")
1653#ifdef CK_ENABLE_WEBGL
1654 .class_function(
"_makeFromGenerator", &MakeImageFromGenerator)
1658 return self->imageInfo().refColorSpace();
1659 }), allow_raw_pointers())
1676#if defined(ENABLE_GPU)
1682 }), allow_raw_pointers())
1694 }), allow_raw_pointers())
1700 return self->makeShader(tx, ty, {filter, mipmap}, mPtr ? &localMatrix :
nullptr);
1701 }), allow_raw_pointers())
1702#
if defined(ENABLE_GPU)
1705 size_t dstRowBytes,
int srcX,
int srcY,
1707 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1709 return self->readPixels(dContext, ii, pixels, dstRowBytes, srcX, srcY);
1710 }), allow_raw_pointers())
1714 size_t dstRowBytes,
int srcX,
int srcY)->bool {
1715 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
1717 return self->readPixels(
nullptr, ii, pixels, dstRowBytes, srcX, srcY);
1718 }), allow_raw_pointers())
1721 class_<SkImageFilter>(
"ImageFilter")
1733 .class_function(
"MakeBlur", optional_override([](
SkScalar sigmaX,
SkScalar sigmaY,
1742 .class_function(
"MakeDilate", optional_override([](
SkScalar radiusX,
SkScalar radiusY,
1746 .class_function(
"MakeDisplacementMap", optional_override([](
SkColorChannel xChannelSelector,
1756 .class_function(
"_MakeDropShadow", optional_override([](
SkScalar dx,
SkScalar dy,
1762 .class_function(
"_MakeDropShadowOnly", optional_override([](
SkScalar dx,
SkScalar dy,
1768 .class_function(
"MakeErode", optional_override([](
SkScalar radiusX,
SkScalar radiusY,
1777 const SkRect* src =
reinterpret_cast<const SkRect*
>(srcPtr);
1778 const SkRect* dst =
reinterpret_cast<const SkRect*
>(dstPtr);
1790 const SkRect* src =
reinterpret_cast<const SkRect*
>(srcPtr);
1791 const SkRect* dst =
reinterpret_cast<const SkRect*
>(dstPtr);
1797 .class_function(
"_MakeMatrixTransformCubic",
1803 .class_function(
"_MakeMatrixTransformOptions",
1809 .class_function(
"MakeOffset", optional_override([](
SkScalar dx,
SkScalar dy,
1814 class_<SkMaskFilter>(
"MaskFilter")
1819 }), allow_raw_pointers());
1821 class_<SkPaint>(
"Paint")
1830 float* fourFloats =
reinterpret_cast<float*
>(cPtr);
1831 memcpy(fourFloats, c.vec(), 4 *
sizeof(
SkScalar));
1864 class_<SkColorSpace>(
"ColorSpace")
1872 .class_function(
"_MakeDisplayP3", optional_override([]()->sk_sp<
SkColorSpace> {
1875 .class_function(
"_MakeAdobeRGB", optional_override([]()->sk_sp<
SkColorSpace> {
1879 class_<SkPathEffect>(
"PathEffect")
1884 const float* intervals =
reinterpret_cast<const float*
>(cptr);
1886 }), allow_raw_pointers())
1888 .class_function(
"_MakeLine2D", optional_override([](
SkScalar width,
1891 const SkScalar* nineMatrixValues =
reinterpret_cast<const SkScalar*
>(mPtr);
1892 matrix.set9(nineMatrixValues);
1894 }), allow_raw_pointers())
1896 .class_function(
"_MakePath2D", optional_override([](
WASMPointerF32 mPtr,
1899 const SkScalar* nineMatrixValues =
reinterpret_cast<const SkScalar*
>(mPtr);
1900 matrix.set9(nineMatrixValues);
1902 }), allow_raw_pointers());
1905 class_<SkPath>(
"Path")
1907#ifdef CK_INCLUDE_PATHOPS
1908 .class_function(
"MakeFromOp", &MakePathFromOp)
1915 .function(
"_addArc", optional_override([](
SkPath&
self,
1918 const SkRect* oval =
reinterpret_cast<const SkRect*
>(fPtr);
1919 self.addArc(*oval, startAngle, sweepAngle);
1921 .function(
"_addOval", optional_override([](
SkPath&
self,
1923 bool ccw,
unsigned start)->void {
1924 const SkRect* oval =
reinterpret_cast<const SkRect*
>(fPtr);
1927 .function(
"_addCircle", optional_override([](
SkPath&
self,
1936 .function(
"_addPoly", optional_override([](
SkPath&
self,
1938 int count,
bool close)->void {
1942 .function(
"_addRect", optional_override([](
SkPath&
self,
1945 const SkRect* rect =
reinterpret_cast<const SkRect*
>(fPtr);
1948 .function(
"_addRRect", optional_override([](
SkPath&
self,
1954 .function(
"_arcToOval", optional_override([](
SkPath&
self,
1956 SkScalar sweepAngle,
bool forceMoveTo)->void {
1957 const SkRect* oval =
reinterpret_cast<const SkRect*
>(fPtr);
1958 self.arcTo(*oval, startAngle, sweepAngle, forceMoveTo);
1967 .function(
"_getPoint", optional_override([](
SkPath&
self,
int index,
1970 *output =
self.getPoint(index);
1986 .function(
"_transform", select_overload<
void(
SkPath&,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar,
SkScalar)>(&
ApplyTransform))
1993#ifdef CK_INCLUDE_PATHOPS
1997 .function(
"makeAsWinding", &MakeAsWinding)
2001 .function(
"toCmds", &
ToCmds)
2005 .function(
"_getBounds", optional_override([](
SkPath&
self,
2008 output[0] =
self.getBounds();
2010 .function(
"_computeTightBounds", optional_override([](
SkPath&
self,
2013 output[0] =
self.computeTightBounds();
2015 .function(
"equals", &
Equals)
2018 .function(
"dump", select_overload<
void()
const>(&
SkPath::dump))
2024 class_<SkPictureRecorder>(
"PictureRecorder")
2030 return self.beginRecording(*bounds, computeBounds ? &
bbhFactory :
nullptr);
2031 }), allow_raw_pointers())
2034 return self.finishRecordingAsPicture();
2035 }), allow_raw_pointers());
2037 class_<SkPicture>(
"Picture")
2044 return self.makeShader(
tmx,
tmy, mode, mPtr ? &localMatrix :
nullptr, tileRect);
2045 }), allow_raw_pointers())
2049 output[0] =
self.cullRect();
2052#ifdef CK_SERIALIZE_SKP
2070 return emscripten::val::null();
2073 }), allow_raw_pointers())
2077 class_<SkShader>(
"Shader")
2080 .class_function(
"_MakeColor",
2085 .class_function(
"MakeFractalNoise", optional_override([](
2088 int tileW,
int tileH)->sk_sp<
SkShader> {
2096 .class_function(
"_MakeLinearGradient", optional_override([](
2111 mPtr ? &localMatrix :
nullptr);
2116 mPtr ? &localMatrix :
nullptr);
2120 }), allow_raw_pointers())
2121 .class_function(
"_MakeRadialGradient", optional_override([](
2134 mPtr ? &localMatrix :
nullptr);
2139 mPtr ? &localMatrix :
nullptr);
2143 }), allow_raw_pointers())
2144 .class_function(
"_MakeSweepGradient", optional_override([](
SkScalar cx,
SkScalar cy,
2157 mode, startAngle, endAngle,
flags,
2158 mPtr ? &localMatrix :
nullptr);
2162 mode, startAngle, endAngle,
flags,
2163 mPtr ? &localMatrix :
nullptr);
2167 }), allow_raw_pointers())
2168 .class_function(
"MakeTurbulence", optional_override([](
2171 int tileW,
int tileH)->sk_sp<
SkShader> {
2176 .class_function(
"_MakeTwoPointConicalGradient", optional_override([](
2184 const SkPoint* startAndEnd =
reinterpret_cast<const SkPoint*
>(fourFloatsPtr);
2191 startAndEnd[1], endRadius,
2192 colors, colorSpace, positions,
count, mode,
2194 mPtr ? &localMatrix :
nullptr);
2206 mPtr ? &localMatrix :
nullptr);
2210 }), allow_raw_pointers());
2212#ifdef CK_INCLUDE_RUNTIME_EFFECT
2213 class_<SkSL::DebugTrace>(
"DebugTrace")
2217 self.writeTrace(&wstream);
2219 return std::string(
reinterpret_cast<const char*
>(trace->bytes()), trace->size());
2222 value_object<SkRuntimeEffect::TracedShader>(
"TracedShader")
2226 class_<SkRuntimeEffect>(
"RuntimeEffect")
2228 .class_function(
"_Make", optional_override([](std::string sksl,
2229 emscripten::val errHandler
2231 SkString s(sksl.c_str(), sksl.length());
2234 errHandler.call<
void>(
"onError", val(errorText.c_str()));
2239 .class_function(
"_MakeForBlender", optional_override([](std::string sksl,
2240 emscripten::val errHandler
2242 SkString s(sksl.c_str(), sksl.length());
2245 errHandler.call<
void>(
"onError", val(errorText.c_str()));
2250 .class_function(
"MakeTraced", optional_override([](
2259 bool shouldOwnUniforms,
2261 void* uniformData =
reinterpret_cast<void*
>(fPtr);
2262 castUniforms(uniformData, fLen,
self);
2264 if (shouldOwnUniforms) {
2271 return self.makeShader(uniforms,
nullptr, 0, mPtr ? &localMatrix :
nullptr);
2276 bool shouldOwnUniforms,
2280 void* uniformData =
reinterpret_cast<void*
>(fPtr);
2281 castUniforms(uniformData, fLen,
self);
2283 if (shouldOwnUniforms) {
2291 for (
size_t i = 0; i < cLen; i++) {
2294 children[i] = sk_ref_sp<SkShader>(childrenPtrs[i]);
2297 auto s =
self.makeShader(uniforms, children, cLen, mPtr ? &localMatrix :
nullptr);
2304 bool shouldOwnUniforms)->sk_sp<
SkBlender> {
2305 void* uniformData =
reinterpret_cast<void*
>(fPtr);
2306 castUniforms(uniformData, fLen,
self);
2308 if (shouldOwnUniforms) {
2314 return self.makeBlender(uniforms, {});
2317 return self.uniforms().size();
2320 return self.uniformSize() /
sizeof(float);
2322 .function(
"getUniformName", optional_override([](
SkRuntimeEffect&
self,
int i)->JSString {
2323 auto it =
self.uniforms().begin() + i;
2324 return emscripten::val(std::string(it->name).c_str());
2326 .function(
"getUniform", optional_override([](
SkRuntimeEffect&
self,
int i)->RuntimeEffectUniform {
2327 auto it =
self.uniforms().begin() + i;
2328 RuntimeEffectUniform su = fromUniform(*it);
2332 value_object<RuntimeEffectUniform>(
"RuntimeEffectUniform")
2333 .field(
"columns", &RuntimeEffectUniform::columns)
2334 .field(
"rows", &RuntimeEffectUniform::rows)
2335 .field(
"slot", &RuntimeEffectUniform::slot)
2336 .field(
"isInteger", &RuntimeEffectUniform::isInteger);
2338 constant(
"rt_effect",
true);
2341 class_<SkSurface>(
"Surface")
2343 .class_function(
"_makeRasterDirect", optional_override([](
const SimpleImageInfo ii,
2346 uint8_t* pixels =
reinterpret_cast<uint8_t*
>(pPtr);
2349 }), allow_raw_pointers())
2351#ifdef CK_ENABLE_WEBGL
2357 const auto& ii =
self.imageInfo();
2361#ifdef CK_ENABLE_WEBGL
2362 .function(
"_makeImageFromTexture", optional_override([](
SkSurface&
self,
2363 uint32_t webglHandle, uint32_t texHandle,
2365 auto releaseCtx =
new TextureReleaseContext{webglHandle, texHandle};
2381#ifdef CK_ENABLE_WEBGPU
2382 .function(
"_replaceBackendTexture", optional_override([](
SkSurface&
self,
2383 uint32_t texHandle, uint32_t texFormat,
2385 return ReplaceBackendTexture(
self, texHandle, texFormat,
width,
height);
2391 return self.makeImageSnapshot();
2393 return self.makeImageSnapshot(*bounds);
2397 }), allow_raw_pointers())
2400 return self.getCanvas()->recordingContext() !=
nullptr;
2402 .function(
"sampleCnt", optional_override([](
SkSurface&
self)->int {
2404 &
self, SkSurfaces::BackendHandleAccess::kFlushRead);
2405 return (backendRT.isValid()) ? backendRT.sampleCnt() : 0;
2407 .function(
"_resetContext",optional_override([](
SkSurface&
self)->void {
2411 .function(
"reportBackendTypeIsGPU", optional_override([](
SkSurface&
self) ->
bool {
2418 class_<SkTextBlob>(
"TextBlob")
2420 .class_function(
"_MakeFromRSXform", optional_override([](
WASMPointerU8 sptr,
2424 const char* str =
reinterpret_cast<const char*
>(sptr);
2428 }), allow_raw_pointers())
2429 .class_function(
"_MakeFromRSXformGlyphs", optional_override([](
WASMPointerU16 gPtr,
2437 }), allow_raw_pointers())
2438 .class_function(
"_MakeFromText", optional_override([](
WASMPointerU8 sptr,
2440 const char* str =
reinterpret_cast<const char*
>(sptr);
2442 }), allow_raw_pointers())
2443 .class_function(
"_MakeFromGlyphs", optional_override([](
WASMPointerU16 gPtr,
2447 }), allow_raw_pointers());
2449 class_<SkTypeface>(
"Typeface")
2452#if defined(CK_EMBED_FONT)
2453 if (SK_EMBEDDED_FONTS.
count == 0) {
2460 auto stream = std::make_unique<SkMemoryStream>(fontEntry.
data, fontEntry.
size,
false);
2463 return default_face;
2467 }), allow_raw_pointers())
2468 .class_function(
"_MakeTypefaceFromData", optional_override([](
2470 uint8_t* font =
reinterpret_cast<uint8_t*
>(fPtr);
2472 stream->setMemoryOwned(font, flen);
2474 }), allow_raw_pointers())
2476 size_t strLen,
size_t expectedCodePoints,
2478 char* str =
reinterpret_cast<char*
>(sptr);
2482 glyphIDs, expectedCodePoints);
2483 return actualCodePoints;
2487 class_<SkVertices>(
"Vertices")
2492 output[0] =
self.bounds();
2497 class_<SkVertices::Builder>(
"_VerticesBuilder")
2517 enum_<SkAlphaType>(
"AlphaType")
2522 enum_<SkBlendMode>(
"BlendMode")
2553 enum_<SkBlurStyle>(
"BlurStyle")
2559 enum_<SkClipOp>(
"ClipOp")
2563 enum_<SkColorChannel>(
"ColorChannel")
2569 enum_<SkColorType>(
"ColorType")
2580 enum_<SkPathFillType>(
"FillType")
2584 enum_<SkFilterMode>(
"FilterMode")
2590 enum_<SkEncodedImageFormat>(
"ImageFormat")
2595 enum_<SkMipmapMode>(
"MipmapMode")
2600 enum_<SkPaint::Style>(
"PaintStyle")
2604 enum_<SkPath1DPathEffect::Style>(
"Path1DEffect")
2609#ifdef CK_INCLUDE_PATHOPS
2610 enum_<SkPathOp>(
"PathOp")
2618 enum_<SkCanvas::PointMode>(
"PointMode")
2623 enum_<SkPaint::Cap>(
"StrokeCap")
2628 enum_<SkPaint::Join>(
"StrokeJoin")
2634 enum_<SkFontHinting>(
"FontHinting")
2640 enum_<SkFont::Edging>(
"FontEdging")
2641#ifndef CK_NO_ALIAS_FONT
2648 enum_<SkTileMode>(
"TileMode")
2654 enum_<SkVertices::VertexMode>(
"VertexMode")
2663 value_object<SimpleImageInfo>(
"ImageInfo")
2670 value_object<StrokeOpts>(
"StrokeOpts")
2677 constant(
"MOVE_VERB",
MOVE);
2678 constant(
"LINE_VERB",
LINE);
2679 constant(
"QUAD_VERB",
QUAD);
2680 constant(
"CONIC_VERB",
CONIC);
2681 constant(
"CUBIC_VERB",
CUBIC);
2682 constant(
"CLOSE_VERB",
CLOSE);
2691#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
@ kUnpremul_SkAlphaType
pixel components are independent of 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
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
Type::kYUV Type::kRGBA() int(0.7 *637)
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)
@ kInitWithPrevious_SaveLayerFlag
initializes with previous contents
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)
@ kLines_PointMode
draw each pair of points as a line segment
@ kPolygon_PointMode
draw the array of points as a open polygon
@ kPoints_PointMode
draw each point separately
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)
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={})
sk_sp< SkImage > withDefaultMipmaps() const
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
@ kButt_Cap
no stroke extension
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
@ kFill_Style
set to fill 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
@ kMiter_Join
extends to miter limit
@ kBevel_Join
connects outside edges
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)
@ kSmall_ArcSize
smaller of arc pair
@ kLarge_ArcSize
larger of arc pair
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
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
sk_sp< SkSurface > makeSurface(const SkImageInfo &imageInfo)
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
@ kTriangleStrip_VertexMode
@ kTriangleFan_VertexMode
@ 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_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_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 data
SK_API void FlushAndSubmit(sk_sp< SkSurface >)
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)
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
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 SkRGBA4f FromColor(SkColor color)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
sk_sp< SkSL::DebugTrace > debugTrace
SkSerialImageProc fImageProc
SkSerialTypefaceProc fTypefaceProc