@gtkx/cairo 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/surface.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { type ExternalObject, type Handle } from "@gtkx/runtime";
2
- import type { RectangleInt } from "./structs.js";
3
2
  import type { DeviceOffset, DeviceScale, FallbackResolution, InkExtents, RectangleData } from "./types.js";
4
3
  import { type Content, type Format, type Status, SurfaceType } from "./enums.js";
5
4
  import { FontOptions } from "./font-options.js";
@@ -59,10 +58,6 @@ declare abstract class Surface {
59
58
  hasShowTextGlyphs(): boolean;
60
59
  /** Returns whether the surface can embed data of the given MIME type. */
61
60
  supportsMimeType(mimeType: string): boolean;
62
- /** Returns an image surface giving direct access to the pixels of `extents`; release it with `unmapImage`. */
63
- mapToImage(extents: RectangleInt): Surface;
64
- /** Uploads the pixels of `image`, obtained from `mapToImage`, back to the surface and releases it. */
65
- unmapImage(image: Surface): void;
66
61
  }
67
62
  /** A surface backed by an in-memory pixel buffer, the usual target for offscreen drawing. */
68
63
  declare class ImageSurface extends Surface {
@@ -1 +1 @@
1
- {"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../src/surface.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,cAAc,EAEnB,KAAK,MAAM,EASd,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmJhD;;;;GAIG;AACH,uBAAe,OAAO;IAMlB,gGAAgG;IAChG,M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,OAAO;IAC9B,0GAA0G;IAC1G,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY;IAO1E,6FAA6F;IAC7F,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY;IAIpD,qEAAqE;gBACzD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKzD,kDAAkD;IAClD,QAAQ,IAAI,MAAM;IAIlB,mDAAmD;IACnD,SAAS,IAAI,MAAM;IAInB,+CAA+C;IAC/C,SAAS,IAAI,MAAM;IAInB,0EAA0E;IAC1E,SAAS,IAAI,MAAM;IAInB,mGAAmG;IACnG,OAAO,IAAI,UAAU;CAsBxB;AAED,2GAA2G;AAC3G,cAAM,gBAAiB,SAAQ,OAAO;IAClC,4EAA4E;IAC5E,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,gBAAgB;IAI1E,0GAA0G;gBAC9F,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa;IAKrD,sDAAsD;IACtD,UAAU,IAAI,UAAU;IAUxB,0FAA0F;IAC1F,UAAU,IAAI,aAAa,GAAG,IAAI;CAMrC;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC"}
package/dist/surface.js CHANGED
@@ -1,10 +1,12 @@
1
- import { alloc, getHandle, read, registerWrapperClass, registerWrapperClassResolver, setHandle, t, wrapHandle, write, } from "@gtkx/runtime";
1
+ import { alloc, getHandle, registerWrapperClass, registerWrapperClassResolver, setHandle, t, wrapHandle, write, } from "@gtkx/runtime";
2
2
  import { SurfaceType } from "./enums.js";
3
3
  import { FontOptions } from "./font-options.js";
4
- import { bindCairo, cairoGType, DEVICE_T, FONT_OPTIONS_T, RECTANGLE_INT_T, RECTANGLE_T, SURFACE_FULL_T, SURFACE_T, } from "./lib.js";
4
+ import { bindCairo, cairoGType, DEVICE_T, FONT_OPTIONS_T, RECTANGLE_T, SURFACE_FULL_T, SURFACE_T, } from "./lib.js";
5
5
  import { checkSurface } from "./status.js";
6
6
  const SURFACE_TYPE = cairoGType("cairo_gobject_surface_get_type");
7
7
  const RECTANGLE_SIZE = 32;
8
+ const DOUBLE = t.fieldAt(t.float64);
9
+ const UINT8 = t.fieldAt(t.uint8);
8
10
  const DEVICE_PAIR_ARGS = [SURFACE_T, t.float64, t.float64];
9
11
  const DEVICE_PAIR_OUT_ARGS = [SURFACE_T, t.ref(t.float64), t.ref(t.float64)];
10
12
  const SIMILAR_ARGS = [SURFACE_T, t.int32, t.int32, t.int32];
@@ -32,8 +34,6 @@ const cairoSurfaceCopyPage = bindCairo("cairo_surface_copy_page", [SURFACE_T], t
32
34
  const cairoSurfaceShowPage = bindCairo("cairo_surface_show_page", [SURFACE_T], t.void);
33
35
  const cairoSurfaceHasShowTextGlyphs = bindCairo("cairo_surface_has_show_text_glyphs", [SURFACE_T], t.boolean);
34
36
  const cairoSurfaceSupportsMimeType = bindCairo("cairo_surface_supports_mime_type", [SURFACE_T, t.string("full")], t.boolean);
35
- const cairoSurfaceMapToImage = bindCairo("cairo_surface_map_to_image", [SURFACE_T, RECTANGLE_INT_T], SURFACE_T);
36
- const cairoSurfaceUnmapImage = bindCairo("cairo_surface_unmap_image", [SURFACE_T, SURFACE_T], t.void);
37
37
  const cairoImageSurfaceCreate = bindCairo("cairo_image_surface_create", [t.int32, t.int32, t.int32], SURFACE_FULL_T);
38
38
  const cairoImageSurfaceCreateFromPng = bindCairo("cairo_image_surface_create_from_png", [t.string("full")], SURFACE_FULL_T);
39
39
  const cairoImageSurfaceGetWidth = bindCairo("cairo_image_surface_get_width", [SURFACE_T], t.int32);
@@ -60,10 +60,10 @@ const allocRectangle = (rect) => {
60
60
  return buffer;
61
61
  };
62
62
  const readRectangle = (buffer) => ({
63
- x: read(buffer, t.float64, 0),
64
- y: read(buffer, t.float64, 8),
65
- width: read(buffer, t.float64, 16),
66
- height: read(buffer, t.float64, 24),
63
+ x: DOUBLE.read(buffer, 0),
64
+ y: DOUBLE.read(buffer, 8),
65
+ width: DOUBLE.read(buffer, 16),
66
+ height: DOUBLE.read(buffer, 24),
67
67
  });
68
68
  const createRecordingSurface = (content, extents) => (extents === undefined
69
69
  ? cairoRecordingSurfaceCreateUnbounded(content, 0)
@@ -192,14 +192,6 @@ class Surface {
192
192
  supportsMimeType(mimeType) {
193
193
  return cairoSurfaceSupportsMimeType(getHandle(this), mimeType);
194
194
  }
195
- /** Returns an image surface giving direct access to the pixels of `extents`; release it with `unmapImage`. */
196
- mapToImage(extents) {
197
- return wrapSurface(cairoSurfaceMapToImage(getHandle(this), getHandle(extents)));
198
- }
199
- /** Uploads the pixels of `image`, obtained from `mapToImage`, back to the surface and releases it. */
200
- unmapImage(image) {
201
- cairoSurfaceUnmapImage(getHandle(this), getHandle(image));
202
- }
203
195
  }
204
196
  /** A surface backed by an in-memory pixel buffer, the usual target for offscreen drawing. */
205
197
  class ImageSurface extends Surface {
@@ -244,7 +236,7 @@ class ImageSurface extends Surface {
244
236
  if (data === null) {
245
237
  return new Uint8Array(0);
246
238
  }
247
- return Uint8Array.from({ length: totalBytes }, (_, index) => read(data, t.uint8, index));
239
+ return Uint8Array.from({ length: totalBytes }, (_, index) => UINT8.read(data, index));
248
240
  }
249
241
  }
250
242
  /** A surface that records the drawing operations applied to it, for replaying them onto other surfaces. */
@@ -1 +1 @@
1
- {"version":3,"file":"surface.js","sourceRoot":"","sources":["../src/surface.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAEL,SAAS,EAET,IAAI,EACJ,oBAAoB,EACpB,4BAA4B,EAC5B,SAAS,EACT,CAAC,EACD,UAAU,EAEV,KAAK,GACR,MAAM,eAAe,CAAC;AAGvB,OAAO,EAA0C,WAAW,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,WAAW,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AAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAExE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACpF,CAAC;IAED,0FAA0F;IAC1F,UAAU;QACN,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,+BAA+B,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAY,CAAC;QAEtF,OAAO,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpD,CAAC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import {\n alloc,\n type ExternalObject,\n getHandle,\n type Handle,\n read,\n registerWrapperClass,\n registerWrapperClassResolver,\n setHandle,\n t,\n wrapHandle,\n type WrapperClassResolver,\n write,\n} from \"@gtkx/runtime\";\nimport type { RectangleInt } from \"./structs.js\";\nimport type { DeviceOffset, DeviceScale, FallbackResolution, InkExtents, RectangleData } from \"./types.js\";\nimport { type Content, type Format, type Status, SurfaceType } from \"./enums.js\";\nimport { FontOptions } from \"./font-options.js\";\nimport {\n bindCairo,\n type BoundFunction,\n cairoGType,\n DEVICE_T,\n FONT_OPTIONS_T,\n RECTANGLE_INT_T,\n RECTANGLE_T,\n SURFACE_FULL_T,\n SURFACE_T,\n} from \"./lib.js\";\nimport { checkSurface } from \"./status.js\";\n\nconst SURFACE_TYPE = cairoGType(\"cairo_gobject_surface_get_type\");\nconst RECTANGLE_SIZE = 32;\nconst DEVICE_PAIR_ARGS = [SURFACE_T, t.float64, t.float64];\nconst DEVICE_PAIR_OUT_ARGS = [SURFACE_T, t.ref(t.float64), t.ref(t.float64)];\nconst SIMILAR_ARGS = [SURFACE_T, t.int32, t.int32, t.int32];\nconst cairoSurfaceCreateSimilar = bindCairo(\"cairo_surface_create_similar\", SIMILAR_ARGS, SURFACE_FULL_T);\nconst cairoSurfaceCreateSimilarImage = bindCairo(\"cairo_surface_create_similar_image\", SIMILAR_ARGS, SURFACE_FULL_T);\n\nconst cairoSurfaceCreateForRectangle = bindCairo(\n \"cairo_surface_create_for_rectangle\",\n [SURFACE_T, t.float64, t.float64, t.float64, t.float64],\n SURFACE_FULL_T,\n);\n\nconst cairoSurfaceWriteToPng = bindCairo(\"cairo_surface_write_to_png\", [SURFACE_T, t.string(\"full\")], t.int32);\nconst cairoSurfaceStatus = bindCairo(\"cairo_surface_status\", [SURFACE_T], t.int32);\nconst cairoSurfaceFinish = bindCairo(\"cairo_surface_finish\", [SURFACE_T], t.void);\nconst cairoSurfaceFlush = bindCairo(\"cairo_surface_flush\", [SURFACE_T], t.void);\nconst cairoSurfaceGetDevice = bindCairo(\"cairo_surface_get_device\", [SURFACE_T], DEVICE_T);\nconst cairoSurfaceGetFontOptions = bindCairo(\"cairo_surface_get_font_options\", [SURFACE_T, FONT_OPTIONS_T], t.void);\nconst cairoSurfaceGetContent = bindCairo(\"cairo_surface_get_content\", [SURFACE_T], t.int32);\nconst cairoSurfaceMarkDirty = bindCairo(\"cairo_surface_mark_dirty\", [SURFACE_T], t.void);\n\nconst cairoSurfaceMarkDirtyRectangle = bindCairo(\n \"cairo_surface_mark_dirty_rectangle\",\n [SURFACE_T, t.int32, t.int32, t.int32, t.int32],\n t.void,\n);\n\nconst cairoSurfaceSetDeviceOffset = bindCairo(\"cairo_surface_set_device_offset\", DEVICE_PAIR_ARGS, t.void);\nconst cairoSurfaceGetDeviceOffset = bindCairo(\"cairo_surface_get_device_offset\", DEVICE_PAIR_OUT_ARGS, t.void);\nconst cairoSurfaceGetDeviceScale = bindCairo(\"cairo_surface_get_device_scale\", DEVICE_PAIR_OUT_ARGS, t.void);\nconst cairoSurfaceSetDeviceScale = bindCairo(\"cairo_surface_set_device_scale\", DEVICE_PAIR_ARGS, t.void);\nconst cairoSurfaceSetFallbackResolution = bindCairo(\"cairo_surface_set_fallback_resolution\", DEVICE_PAIR_ARGS, t.void);\n\nconst cairoSurfaceGetFallbackResolution = bindCairo(\n \"cairo_surface_get_fallback_resolution\",\n DEVICE_PAIR_OUT_ARGS,\n t.void,\n);\n\nconst cairoSurfaceGetType = bindCairo(\"cairo_surface_get_type\", [SURFACE_T], t.int32);\nconst cairoSurfaceGetReferenceCount = bindCairo(\"cairo_surface_get_reference_count\", [SURFACE_T], t.int32);\nconst cairoSurfaceCopyPage = bindCairo(\"cairo_surface_copy_page\", [SURFACE_T], t.void);\nconst cairoSurfaceShowPage = bindCairo(\"cairo_surface_show_page\", [SURFACE_T], t.void);\nconst cairoSurfaceHasShowTextGlyphs = bindCairo(\"cairo_surface_has_show_text_glyphs\", [SURFACE_T], t.boolean);\n\nconst cairoSurfaceSupportsMimeType = bindCairo(\n \"cairo_surface_supports_mime_type\",\n [SURFACE_T, t.string(\"full\")],\n t.boolean,\n);\n\nconst cairoSurfaceMapToImage = bindCairo(\"cairo_surface_map_to_image\", [SURFACE_T, RECTANGLE_INT_T], SURFACE_T);\nconst cairoSurfaceUnmapImage = bindCairo(\"cairo_surface_unmap_image\", [SURFACE_T, SURFACE_T], t.void);\nconst cairoImageSurfaceCreate = bindCairo(\"cairo_image_surface_create\", [t.int32, t.int32, t.int32], SURFACE_FULL_T);\n\nconst cairoImageSurfaceCreateFromPng = bindCairo(\n \"cairo_image_surface_create_from_png\",\n [t.string(\"full\")],\n SURFACE_FULL_T,\n);\n\nconst cairoImageSurfaceGetWidth = bindCairo(\"cairo_image_surface_get_width\", [SURFACE_T], t.int32);\nconst cairoImageSurfaceGetHeight = bindCairo(\"cairo_image_surface_get_height\", [SURFACE_T], t.int32);\nconst cairoImageSurfaceGetFormat = bindCairo(\"cairo_image_surface_get_format\", [SURFACE_T], t.int32);\nconst cairoImageSurfaceGetStride = bindCairo(\"cairo_image_surface_get_stride\", [SURFACE_T], t.int32);\nconst cairoRecordingSurfaceCreate = bindCairo(\"cairo_recording_surface_create\", [t.int32, RECTANGLE_T], SURFACE_FULL_T);\n\nconst cairoRecordingSurfaceCreateUnbounded = bindCairo(\n \"cairo_recording_surface_create\",\n [t.int32, t.uint64],\n SURFACE_FULL_T,\n);\n\nconst cairoRecordingSurfaceInkExtents = bindCairo(\n \"cairo_recording_surface_ink_extents\",\n [SURFACE_T, t.ref(t.float64), t.ref(t.float64), t.ref(t.float64), t.ref(t.float64)],\n t.void,\n);\n\nconst cairoRecordingSurfaceGetExtents = bindCairo(\n \"cairo_recording_surface_get_extents\",\n [SURFACE_T, RECTANGLE_T],\n t.boolean,\n);\n\nconst wrapSurface = (handle: unknown): Surface => wrapHandle(handle as ExternalObject<Handle>, Surface);\n\nconst readPair = <T>(boundFn: BoundFunction, self: object, build: (first: number, second: number) => T): T => {\n const first = { value: 0 };\n const second = { value: 0 };\n boundFn(getHandle(self), first, second);\n\n return build(first.value, second.value);\n};\n\nconst allocRectangle = (rect: RectangleData): ExternalObject<Handle> => {\n const buffer = alloc(RECTANGLE_SIZE);\n write(buffer, t.float64, 0, rect.x);\n write(buffer, t.float64, 8, rect.y);\n write(buffer, t.float64, 16, rect.width);\n write(buffer, t.float64, 24, rect.height);\n\n return buffer;\n};\n\nconst readRectangle = (buffer: ExternalObject<Handle>): RectangleData => ({\n x: read(buffer, t.float64, 0) as number,\n y: read(buffer, t.float64, 8) as number,\n width: read(buffer, t.float64, 16) as number,\n height: read(buffer, t.float64, 24) as number,\n});\n\nconst createRecordingSurface = (content: Content, extents?: RectangleData): ExternalObject<Handle> =>\n (extents === undefined\n ? cairoRecordingSurfaceCreateUnbounded(content, 0)\n : cairoRecordingSurfaceCreate(content, allocRectangle(extents))) as ExternalObject<Handle>;\n\nconst surfaceClassFor: WrapperClassResolver = (handle) => {\n const type = cairoSurfaceGetType(handle) as SurfaceType;\n\n if (type === SurfaceType.IMAGE) {\n return ImageSurface;\n }\n\n if (type === SurfaceType.RECORDING) {\n return RecordingSurface;\n }\n\n return Surface;\n};\n\n/**\n * A cairo surface (`cairo_surface_t`): the target a context draws onto. Surfaces come from the `create*`\n * statics, from `ImageSurface` and `RecordingSurface`, or from GTK, and wrap as the concrete class their\n * backend reports (`instanceof ImageSurface` for an image surface).\n */\nabstract class Surface {\n static {\n registerWrapperClass(this, SURFACE_TYPE);\n registerWrapperClassResolver(this, surfaceClassFor);\n }\n\n /** Creates a surface of the given `content` and size as compatible as possible with `other`. */\n static createSimilar(other: Surface, content: Content, width: number, height: number): Surface {\n const handle = cairoSurfaceCreateSimilar(getHandle(other), content, width, height) as ExternalObject<Handle>;\n\n return wrapSurface(checkSurface(handle));\n }\n\n /** Creates an image surface of the given `format` and size as compatible as possible with `other`. */\n static createSimilarImage(other: Surface, format: Format, width: number, height: number): ImageSurface {\n const handle =\n cairoSurfaceCreateSimilarImage(getHandle(other), format, width, height) as ExternalObject<Handle>;\n\n return wrapHandle(checkSurface(handle), ImageSurface);\n }\n\n /** Creates a surface that draws onto the given rectangle of `target`. */\n static createForRectangle(target: Surface, x: number, y: number, width: number, height: number): Surface {\n const handle =\n cairoSurfaceCreateForRectangle(getHandle(target), x, y, width, height) as ExternalObject<Handle>;\n\n return wrapSurface(checkSurface(handle));\n }\n\n /** GType of `CairoSurface`, the boxed type this class is registered under. */\n declare __type__: bigint;\n\n /** Writes the surface to a PNG file at `filename` and returns the resulting status. */\n writeToPng(filename: string): Status {\n return cairoSurfaceWriteToPng(getHandle(this), filename) as Status;\n }\n\n /** Returns the error status of the surface, `Status.SUCCESS` when it is usable. */\n status(): Status {\n return cairoSurfaceStatus(getHandle(this)) as Status;\n }\n\n /** Finishes the surface and drops its backend resources; further drawing reports an error. */\n finish(): void {\n cairoSurfaceFinish(getHandle(this));\n }\n\n /** Performs any pending drawing so the backend storage is up to date. */\n flush(): void {\n cairoSurfaceFlush(getHandle(this));\n }\n\n /** Returns the raw handle of the device behind the surface, or null when it has none. */\n getDevice(): ExternalObject<Handle> | null {\n return cairoSurfaceGetDevice(getHandle(this)) as ExternalObject<Handle> | null;\n }\n\n /** Returns the font options the surface's backend prefers for rendering text. */\n getFontOptions(): FontOptions {\n const options = FontOptions.create();\n cairoSurfaceGetFontOptions(getHandle(this), getHandle(options));\n\n return options;\n }\n\n /** Returns whether the surface holds color, alpha or both. */\n getContent(): Content {\n return cairoSurfaceGetContent(getHandle(this)) as Content;\n }\n\n /** Tells cairo the surface's storage was modified outside of cairo. */\n markDirty(): void {\n cairoSurfaceMarkDirty(getHandle(this));\n }\n\n /** Tells cairo the given rectangle of the surface's storage was modified outside of cairo. */\n markDirtyRectangle(x: number, y: number, width: number, height: number): void {\n cairoSurfaceMarkDirtyRectangle(getHandle(this), x, y, width, height);\n }\n\n /** Sets the offset added to device coordinates when drawing onto the surface. */\n setDeviceOffset(xOffset: number, yOffset: number): void {\n cairoSurfaceSetDeviceOffset(getHandle(this), xOffset, yOffset);\n }\n\n /** Returns the offset added to device coordinates when drawing onto the surface. */\n getDeviceOffset(): DeviceOffset {\n return readPair(cairoSurfaceGetDeviceOffset, this, (xOffset, yOffset) => ({ xOffset, yOffset }));\n }\n\n /** Returns the scale applied between user and device units. */\n getDeviceScale(): DeviceScale {\n return readPair(cairoSurfaceGetDeviceScale, this, (xScale, yScale) => ({ xScale, yScale }));\n }\n\n /** Sets the scale applied between user and device units. */\n setDeviceScale(xScale: number, yScale: number): void {\n cairoSurfaceSetDeviceScale(getHandle(this), xScale, yScale);\n }\n\n /** Sets the resolution used when vector content has to be rasterized. */\n setFallbackResolution(xPixelsPerInch: number, yPixelsPerInch: number): void {\n cairoSurfaceSetFallbackResolution(getHandle(this), xPixelsPerInch, yPixelsPerInch);\n }\n\n /** Returns the resolution used when vector content has to be rasterized. */\n getFallbackResolution(): FallbackResolution {\n return readPair(cairoSurfaceGetFallbackResolution, this, (xPixelsPerInch, yPixelsPerInch) => ({\n xPixelsPerInch,\n yPixelsPerInch,\n }));\n }\n\n /** Returns the backend type of the surface. */\n getType(): SurfaceType {\n return cairoSurfaceGetType(getHandle(this)) as SurfaceType;\n }\n\n /** Returns the reference count of the surface. */\n getReferenceCount(): number {\n return cairoSurfaceGetReferenceCount(getHandle(this)) as number;\n }\n\n /** Emits the current page and keeps its content for the next one, on paged backends. */\n copyPage(): void {\n cairoSurfaceCopyPage(getHandle(this));\n }\n\n /** Emits the current page and starts a blank one, on paged backends. */\n showPage(): void {\n cairoSurfaceShowPage(getHandle(this));\n }\n\n /** Returns whether the surface supports `Context.showTextGlyphs` natively. */\n hasShowTextGlyphs(): boolean {\n return cairoSurfaceHasShowTextGlyphs(getHandle(this)) as boolean;\n }\n\n /** Returns whether the surface can embed data of the given MIME type. */\n supportsMimeType(mimeType: string): boolean {\n return cairoSurfaceSupportsMimeType(getHandle(this), mimeType) as boolean;\n }\n\n /** Returns an image surface giving direct access to the pixels of `extents`; release it with `unmapImage`. */\n mapToImage(extents: RectangleInt): Surface {\n return wrapSurface(cairoSurfaceMapToImage(getHandle(this), getHandle(extents)));\n }\n\n /** Uploads the pixels of `image`, obtained from `mapToImage`, back to the surface and releases it. */\n unmapImage(image: Surface): void {\n cairoSurfaceUnmapImage(getHandle(this), getHandle(image));\n }\n}\n\n/** A surface backed by an in-memory pixel buffer, the usual target for offscreen drawing. */\nclass ImageSurface extends Surface {\n /** Creates an image surface of the given pixel `format` and size, the same as `new ImageSurface(...)`. */\n static create(format: Format, width: number, height: number): ImageSurface {\n return wrapHandle(\n checkSurface(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>),\n this,\n );\n }\n\n /** Loads a PNG file into a new image surface; throws when the file is missing or invalid. */\n static createFromPng(filename: string): ImageSurface {\n return wrapHandle(checkSurface(cairoImageSurfaceCreateFromPng(filename) as ExternalObject<Handle>), this);\n }\n\n /** Creates an image surface of the given pixel `format` and size. */\n constructor(format: Format, width: number, height: number) {\n super();\n setHandle(this, checkSurface(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>));\n }\n\n /** Returns the width of the surface in pixels. */\n getWidth(): number {\n return cairoImageSurfaceGetWidth(getHandle(this)) as number;\n }\n\n /** Returns the height of the surface in pixels. */\n getHeight(): number {\n return cairoImageSurfaceGetHeight(getHandle(this)) as number;\n }\n\n /** Returns the pixel format of the surface. */\n getFormat(): Format {\n return cairoImageSurfaceGetFormat(getHandle(this)) as Format;\n }\n\n /** Returns the number of bytes between the starts of consecutive rows. */\n getStride(): number {\n return cairoImageSurfaceGetStride(getHandle(this)) as number;\n }\n\n /** Returns a copy of the pixel data, `getStride() * getHeight()` bytes in the surface's format. */\n getData(): Uint8Array {\n this.flush();\n const totalBytes = this.getStride() * this.getHeight();\n\n if (totalBytes === 0) {\n return new Uint8Array(0);\n }\n\n const getImageData = bindCairo(\n \"cairo_image_surface_get_data\",\n [SURFACE_T],\n t.struct(\"borrowed\", { size: totalBytes }),\n );\n\n const data = getImageData(getHandle(this)) as ExternalObject<Handle> | null;\n\n if (data === null) {\n return new Uint8Array(0);\n }\n\n return Uint8Array.from({ length: totalBytes }, (_, index) => read(data, t.uint8, index) as number);\n }\n}\n\n/** A surface that records the drawing operations applied to it, for replaying them onto other surfaces. */\nclass RecordingSurface extends Surface {\n /** Creates a recording surface, the same as `new RecordingSurface(...)`. */\n static create(content: Content, extents?: RectangleData): RecordingSurface {\n return new RecordingSurface(content, extents);\n }\n\n /** Creates a recording surface of the given `content`, bounded to `extents` or unbounded when omitted. */\n constructor(content: Content, extents?: RectangleData) {\n super();\n setHandle(this, checkSurface(createRecordingSurface(content, extents)));\n }\n\n /** Returns the area that has been drawn on so far. */\n inkExtents(): InkExtents {\n const x0 = { value: 0 };\n const y0 = { value: 0 };\n const width = { value: 0 };\n const height = { value: 0 };\n cairoRecordingSurfaceInkExtents(getHandle(this), x0, y0, width, height);\n\n return { x0: x0.value, y0: y0.value, width: width.value, height: height.value };\n }\n\n /** Returns the extents the surface was created with, or null for an unbounded surface. */\n getExtents(): RectangleData | null {\n const buffer = alloc(RECTANGLE_SIZE);\n const isBounded = cairoRecordingSurfaceGetExtents(getHandle(this), buffer) as boolean;\n\n return isBounded ? readRectangle(buffer) : null;\n }\n}\n\nexport { ImageSurface, RecordingSurface, Surface };\n"]}
1
+ {"version":3,"file":"surface.js","sourceRoot":"","sources":["../src/surface.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAEL,SAAS,EAET,oBAAoB,EACpB,4BAA4B,EAC5B,SAAS,EACT,CAAC,EACD,UAAU,EAEV,KAAK,GACR,MAAM,eAAe,CAAC;AAEvB,OAAO,EAA0C,WAAW,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACH,SAAS,EAET,UAAU,EACV,QAAQ,EACR,cAAc,EACd,WAAW,EACX,cAAc,EACd,SAAS,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,YAAY,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC;AAClE,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AACpC,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACjC,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AAC3D,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7E,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAA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E,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAExE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACpF,CAAC;IAED,0FAA0F;IAC1F,UAAU;QACN,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,+BAA+B,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAY,CAAC;QAEtF,OAAO,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpD,CAAC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import {\n alloc,\n type ExternalObject,\n getHandle,\n type Handle,\n registerWrapperClass,\n registerWrapperClassResolver,\n setHandle,\n t,\n wrapHandle,\n type WrapperClassResolver,\n write,\n} from \"@gtkx/runtime\";\nimport type { DeviceOffset, DeviceScale, FallbackResolution, InkExtents, RectangleData } from \"./types.js\";\nimport { type Content, type Format, type Status, SurfaceType } from \"./enums.js\";\nimport { FontOptions } from \"./font-options.js\";\nimport {\n bindCairo,\n type BoundFunction,\n cairoGType,\n DEVICE_T,\n FONT_OPTIONS_T,\n RECTANGLE_T,\n SURFACE_FULL_T,\n SURFACE_T,\n} from \"./lib.js\";\nimport { checkSurface } from \"./status.js\";\n\nconst SURFACE_TYPE = cairoGType(\"cairo_gobject_surface_get_type\");\nconst RECTANGLE_SIZE = 32;\nconst DOUBLE = t.fieldAt(t.float64);\nconst UINT8 = t.fieldAt(t.uint8);\nconst DEVICE_PAIR_ARGS = [SURFACE_T, t.float64, t.float64];\nconst DEVICE_PAIR_OUT_ARGS = [SURFACE_T, t.ref(t.float64), t.ref(t.float64)];\nconst SIMILAR_ARGS = [SURFACE_T, t.int32, t.int32, t.int32];\nconst cairoSurfaceCreateSimilar = bindCairo(\"cairo_surface_create_similar\", SIMILAR_ARGS, SURFACE_FULL_T);\nconst cairoSurfaceCreateSimilarImage = bindCairo(\"cairo_surface_create_similar_image\", SIMILAR_ARGS, SURFACE_FULL_T);\n\nconst cairoSurfaceCreateForRectangle = bindCairo(\n \"cairo_surface_create_for_rectangle\",\n [SURFACE_T, t.float64, t.float64, t.float64, t.float64],\n SURFACE_FULL_T,\n);\n\nconst cairoSurfaceWriteToPng = bindCairo(\"cairo_surface_write_to_png\", [SURFACE_T, t.string(\"full\")], t.int32);\nconst cairoSurfaceStatus = bindCairo(\"cairo_surface_status\", [SURFACE_T], t.int32);\nconst cairoSurfaceFinish = bindCairo(\"cairo_surface_finish\", [SURFACE_T], t.void);\nconst cairoSurfaceFlush = bindCairo(\"cairo_surface_flush\", [SURFACE_T], t.void);\nconst cairoSurfaceGetDevice = bindCairo(\"cairo_surface_get_device\", [SURFACE_T], DEVICE_T);\nconst cairoSurfaceGetFontOptions = bindCairo(\"cairo_surface_get_font_options\", [SURFACE_T, FONT_OPTIONS_T], t.void);\nconst cairoSurfaceGetContent = bindCairo(\"cairo_surface_get_content\", [SURFACE_T], t.int32);\nconst cairoSurfaceMarkDirty = bindCairo(\"cairo_surface_mark_dirty\", [SURFACE_T], t.void);\n\nconst cairoSurfaceMarkDirtyRectangle = bindCairo(\n \"cairo_surface_mark_dirty_rectangle\",\n [SURFACE_T, t.int32, t.int32, t.int32, t.int32],\n t.void,\n);\n\nconst cairoSurfaceSetDeviceOffset = bindCairo(\"cairo_surface_set_device_offset\", DEVICE_PAIR_ARGS, t.void);\nconst cairoSurfaceGetDeviceOffset = bindCairo(\"cairo_surface_get_device_offset\", DEVICE_PAIR_OUT_ARGS, t.void);\nconst cairoSurfaceGetDeviceScale = bindCairo(\"cairo_surface_get_device_scale\", DEVICE_PAIR_OUT_ARGS, t.void);\nconst cairoSurfaceSetDeviceScale = bindCairo(\"cairo_surface_set_device_scale\", DEVICE_PAIR_ARGS, t.void);\nconst cairoSurfaceSetFallbackResolution = bindCairo(\"cairo_surface_set_fallback_resolution\", DEVICE_PAIR_ARGS, t.void);\n\nconst cairoSurfaceGetFallbackResolution = bindCairo(\n \"cairo_surface_get_fallback_resolution\",\n DEVICE_PAIR_OUT_ARGS,\n t.void,\n);\n\nconst cairoSurfaceGetType = bindCairo(\"cairo_surface_get_type\", [SURFACE_T], t.int32);\nconst cairoSurfaceGetReferenceCount = bindCairo(\"cairo_surface_get_reference_count\", [SURFACE_T], t.int32);\nconst cairoSurfaceCopyPage = bindCairo(\"cairo_surface_copy_page\", [SURFACE_T], t.void);\nconst cairoSurfaceShowPage = bindCairo(\"cairo_surface_show_page\", [SURFACE_T], t.void);\nconst cairoSurfaceHasShowTextGlyphs = bindCairo(\"cairo_surface_has_show_text_glyphs\", [SURFACE_T], t.boolean);\n\nconst cairoSurfaceSupportsMimeType = bindCairo(\n \"cairo_surface_supports_mime_type\",\n [SURFACE_T, t.string(\"full\")],\n t.boolean,\n);\n\nconst cairoImageSurfaceCreate = bindCairo(\"cairo_image_surface_create\", [t.int32, t.int32, t.int32], SURFACE_FULL_T);\n\nconst cairoImageSurfaceCreateFromPng = bindCairo(\n \"cairo_image_surface_create_from_png\",\n [t.string(\"full\")],\n SURFACE_FULL_T,\n);\n\nconst cairoImageSurfaceGetWidth = bindCairo(\"cairo_image_surface_get_width\", [SURFACE_T], t.int32);\nconst cairoImageSurfaceGetHeight = bindCairo(\"cairo_image_surface_get_height\", [SURFACE_T], t.int32);\nconst cairoImageSurfaceGetFormat = bindCairo(\"cairo_image_surface_get_format\", [SURFACE_T], t.int32);\nconst cairoImageSurfaceGetStride = bindCairo(\"cairo_image_surface_get_stride\", [SURFACE_T], t.int32);\nconst cairoRecordingSurfaceCreate = bindCairo(\"cairo_recording_surface_create\", [t.int32, RECTANGLE_T], SURFACE_FULL_T);\n\nconst cairoRecordingSurfaceCreateUnbounded = bindCairo(\n \"cairo_recording_surface_create\",\n [t.int32, t.uint64],\n SURFACE_FULL_T,\n);\n\nconst cairoRecordingSurfaceInkExtents = bindCairo(\n \"cairo_recording_surface_ink_extents\",\n [SURFACE_T, t.ref(t.float64), t.ref(t.float64), t.ref(t.float64), t.ref(t.float64)],\n t.void,\n);\n\nconst cairoRecordingSurfaceGetExtents = bindCairo(\n \"cairo_recording_surface_get_extents\",\n [SURFACE_T, RECTANGLE_T],\n t.boolean,\n);\n\nconst wrapSurface = (handle: unknown): Surface => wrapHandle(handle as ExternalObject<Handle>, Surface);\n\nconst readPair = <T>(boundFn: BoundFunction, self: object, build: (first: number, second: number) => T): T => {\n const first = { value: 0 };\n const second = { value: 0 };\n boundFn(getHandle(self), first, second);\n\n return build(first.value, second.value);\n};\n\nconst allocRectangle = (rect: RectangleData): ExternalObject<Handle> => {\n const buffer = alloc(RECTANGLE_SIZE);\n write(buffer, t.float64, 0, rect.x);\n write(buffer, t.float64, 8, rect.y);\n write(buffer, t.float64, 16, rect.width);\n write(buffer, t.float64, 24, rect.height);\n\n return buffer;\n};\n\nconst readRectangle = (buffer: ExternalObject<Handle>): RectangleData => ({\n x: DOUBLE.read(buffer, 0) as number,\n y: DOUBLE.read(buffer, 8) as number,\n width: DOUBLE.read(buffer, 16) as number,\n height: DOUBLE.read(buffer, 24) as number,\n});\n\nconst createRecordingSurface = (content: Content, extents?: RectangleData): ExternalObject<Handle> =>\n (extents === undefined\n ? cairoRecordingSurfaceCreateUnbounded(content, 0)\n : cairoRecordingSurfaceCreate(content, allocRectangle(extents))) as ExternalObject<Handle>;\n\nconst surfaceClassFor: WrapperClassResolver = (handle) => {\n const type = cairoSurfaceGetType(handle) as SurfaceType;\n\n if (type === SurfaceType.IMAGE) {\n return ImageSurface;\n }\n\n if (type === SurfaceType.RECORDING) {\n return RecordingSurface;\n }\n\n return Surface;\n};\n\n/**\n * A cairo surface (`cairo_surface_t`): the target a context draws onto. Surfaces come from the `create*`\n * statics, from `ImageSurface` and `RecordingSurface`, or from GTK, and wrap as the concrete class their\n * backend reports (`instanceof ImageSurface` for an image surface).\n */\nabstract class Surface {\n static {\n registerWrapperClass(this, SURFACE_TYPE);\n registerWrapperClassResolver(this, surfaceClassFor);\n }\n\n /** Creates a surface of the given `content` and size as compatible as possible with `other`. */\n static createSimilar(other: Surface, content: Content, width: number, height: number): Surface {\n const handle = cairoSurfaceCreateSimilar(getHandle(other), content, width, height) as ExternalObject<Handle>;\n\n return wrapSurface(checkSurface(handle));\n }\n\n /** Creates an image surface of the given `format` and size as compatible as possible with `other`. */\n static createSimilarImage(other: Surface, format: Format, width: number, height: number): ImageSurface {\n const handle =\n cairoSurfaceCreateSimilarImage(getHandle(other), format, width, height) as ExternalObject<Handle>;\n\n return wrapHandle(checkSurface(handle), ImageSurface);\n }\n\n /** Creates a surface that draws onto the given rectangle of `target`. */\n static createForRectangle(target: Surface, x: number, y: number, width: number, height: number): Surface {\n const handle =\n cairoSurfaceCreateForRectangle(getHandle(target), x, y, width, height) as ExternalObject<Handle>;\n\n return wrapSurface(checkSurface(handle));\n }\n\n /** GType of `CairoSurface`, the boxed type this class is registered under. */\n declare __type__: bigint;\n\n /** Writes the surface to a PNG file at `filename` and returns the resulting status. */\n writeToPng(filename: string): Status {\n return cairoSurfaceWriteToPng(getHandle(this), filename) as Status;\n }\n\n /** Returns the error status of the surface, `Status.SUCCESS` when it is usable. */\n status(): Status {\n return cairoSurfaceStatus(getHandle(this)) as Status;\n }\n\n /** Finishes the surface and drops its backend resources; further drawing reports an error. */\n finish(): void {\n cairoSurfaceFinish(getHandle(this));\n }\n\n /** Performs any pending drawing so the backend storage is up to date. */\n flush(): void {\n cairoSurfaceFlush(getHandle(this));\n }\n\n /** Returns the raw handle of the device behind the surface, or null when it has none. */\n getDevice(): ExternalObject<Handle> | null {\n return cairoSurfaceGetDevice(getHandle(this)) as ExternalObject<Handle> | null;\n }\n\n /** Returns the font options the surface's backend prefers for rendering text. */\n getFontOptions(): FontOptions {\n const options = FontOptions.create();\n cairoSurfaceGetFontOptions(getHandle(this), getHandle(options));\n\n return options;\n }\n\n /** Returns whether the surface holds color, alpha or both. */\n getContent(): Content {\n return cairoSurfaceGetContent(getHandle(this)) as Content;\n }\n\n /** Tells cairo the surface's storage was modified outside of cairo. */\n markDirty(): void {\n cairoSurfaceMarkDirty(getHandle(this));\n }\n\n /** Tells cairo the given rectangle of the surface's storage was modified outside of cairo. */\n markDirtyRectangle(x: number, y: number, width: number, height: number): void {\n cairoSurfaceMarkDirtyRectangle(getHandle(this), x, y, width, height);\n }\n\n /** Sets the offset added to device coordinates when drawing onto the surface. */\n setDeviceOffset(xOffset: number, yOffset: number): void {\n cairoSurfaceSetDeviceOffset(getHandle(this), xOffset, yOffset);\n }\n\n /** Returns the offset added to device coordinates when drawing onto the surface. */\n getDeviceOffset(): DeviceOffset {\n return readPair(cairoSurfaceGetDeviceOffset, this, (xOffset, yOffset) => ({ xOffset, yOffset }));\n }\n\n /** Returns the scale applied between user and device units. */\n getDeviceScale(): DeviceScale {\n return readPair(cairoSurfaceGetDeviceScale, this, (xScale, yScale) => ({ xScale, yScale }));\n }\n\n /** Sets the scale applied between user and device units. */\n setDeviceScale(xScale: number, yScale: number): void {\n cairoSurfaceSetDeviceScale(getHandle(this), xScale, yScale);\n }\n\n /** Sets the resolution used when vector content has to be rasterized. */\n setFallbackResolution(xPixelsPerInch: number, yPixelsPerInch: number): void {\n cairoSurfaceSetFallbackResolution(getHandle(this), xPixelsPerInch, yPixelsPerInch);\n }\n\n /** Returns the resolution used when vector content has to be rasterized. */\n getFallbackResolution(): FallbackResolution {\n return readPair(cairoSurfaceGetFallbackResolution, this, (xPixelsPerInch, yPixelsPerInch) => ({\n xPixelsPerInch,\n yPixelsPerInch,\n }));\n }\n\n /** Returns the backend type of the surface. */\n getType(): SurfaceType {\n return cairoSurfaceGetType(getHandle(this)) as SurfaceType;\n }\n\n /** Returns the reference count of the surface. */\n getReferenceCount(): number {\n return cairoSurfaceGetReferenceCount(getHandle(this)) as number;\n }\n\n /** Emits the current page and keeps its content for the next one, on paged backends. */\n copyPage(): void {\n cairoSurfaceCopyPage(getHandle(this));\n }\n\n /** Emits the current page and starts a blank one, on paged backends. */\n showPage(): void {\n cairoSurfaceShowPage(getHandle(this));\n }\n\n /** Returns whether the surface supports `Context.showTextGlyphs` natively. */\n hasShowTextGlyphs(): boolean {\n return cairoSurfaceHasShowTextGlyphs(getHandle(this)) as boolean;\n }\n\n /** Returns whether the surface can embed data of the given MIME type. */\n supportsMimeType(mimeType: string): boolean {\n return cairoSurfaceSupportsMimeType(getHandle(this), mimeType) as boolean;\n }\n}\n\n/** A surface backed by an in-memory pixel buffer, the usual target for offscreen drawing. */\nclass ImageSurface extends Surface {\n /** Creates an image surface of the given pixel `format` and size, the same as `new ImageSurface(...)`. */\n static create(format: Format, width: number, height: number): ImageSurface {\n return wrapHandle(\n checkSurface(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>),\n this,\n );\n }\n\n /** Loads a PNG file into a new image surface; throws when the file is missing or invalid. */\n static createFromPng(filename: string): ImageSurface {\n return wrapHandle(checkSurface(cairoImageSurfaceCreateFromPng(filename) as ExternalObject<Handle>), this);\n }\n\n /** Creates an image surface of the given pixel `format` and size. */\n constructor(format: Format, width: number, height: number) {\n super();\n setHandle(this, checkSurface(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>));\n }\n\n /** Returns the width of the surface in pixels. */\n getWidth(): number {\n return cairoImageSurfaceGetWidth(getHandle(this)) as number;\n }\n\n /** Returns the height of the surface in pixels. */\n getHeight(): number {\n return cairoImageSurfaceGetHeight(getHandle(this)) as number;\n }\n\n /** Returns the pixel format of the surface. */\n getFormat(): Format {\n return cairoImageSurfaceGetFormat(getHandle(this)) as Format;\n }\n\n /** Returns the number of bytes between the starts of consecutive rows. */\n getStride(): number {\n return cairoImageSurfaceGetStride(getHandle(this)) as number;\n }\n\n /** Returns a copy of the pixel data, `getStride() * getHeight()` bytes in the surface's format. */\n getData(): Uint8Array {\n this.flush();\n const totalBytes = this.getStride() * this.getHeight();\n\n if (totalBytes === 0) {\n return new Uint8Array(0);\n }\n\n const getImageData = bindCairo(\n \"cairo_image_surface_get_data\",\n [SURFACE_T],\n t.struct(\"borrowed\", { size: totalBytes }),\n );\n\n const data = getImageData(getHandle(this)) as ExternalObject<Handle> | null;\n\n if (data === null) {\n return new Uint8Array(0);\n }\n\n return Uint8Array.from({ length: totalBytes }, (_, index) => UINT8.read(data, index) as number);\n }\n}\n\n/** A surface that records the drawing operations applied to it, for replaying them onto other surfaces. */\nclass RecordingSurface extends Surface {\n /** Creates a recording surface, the same as `new RecordingSurface(...)`. */\n static create(content: Content, extents?: RectangleData): RecordingSurface {\n return new RecordingSurface(content, extents);\n }\n\n /** Creates a recording surface of the given `content`, bounded to `extents` or unbounded when omitted. */\n constructor(content: Content, extents?: RectangleData) {\n super();\n setHandle(this, checkSurface(createRecordingSurface(content, extents)));\n }\n\n /** Returns the area that has been drawn on so far. */\n inkExtents(): InkExtents {\n const x0 = { value: 0 };\n const y0 = { value: 0 };\n const width = { value: 0 };\n const height = { value: 0 };\n cairoRecordingSurfaceInkExtents(getHandle(this), x0, y0, width, height);\n\n return { x0: x0.value, y0: y0.value, width: width.value, height: height.value };\n }\n\n /** Returns the extents the surface was created with, or null for an unbounded surface. */\n getExtents(): RectangleData | null {\n const buffer = alloc(RECTANGLE_SIZE);\n const isBounded = cairoRecordingSurfaceGetExtents(getHandle(this), buffer) as boolean;\n\n return isBounded ? readRectangle(buffer) : null;\n }\n}\n\nexport { ImageSurface, RecordingSurface, Surface };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,cAAc,EAAE,KAAK,MAAM,EAAkB,MAAM,eAAe,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,C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I,QAAQ,cAAc,CAAC,MAAM,CAAC,KAAG,WAMxD,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC"}
package/dist/text.js CHANGED
@@ -1,15 +1,18 @@
1
- import { alloc, read, t, write } from "@gtkx/runtime";
1
+ import { alloc, t } from "@gtkx/runtime";
2
2
  const GLYPH_SIZE = 24;
3
3
  const CLUSTER_SIZE = 8;
4
4
  const TEXT_EXTENTS_SIZE = 48;
5
5
  const FONT_EXTENTS_SIZE = 40;
6
+ const DOUBLE = t.fieldAt(t.float64);
7
+ const UINT64 = t.fieldAt(t.uint64);
8
+ const INT = t.fieldAt(t.int32);
6
9
  const allocGlyphBuffer = (glyphs) => {
7
10
  const buffer = alloc(glyphs.length * GLYPH_SIZE);
8
11
  let offset = 0;
9
12
  for (const glyph of glyphs) {
10
- write(buffer, t.uint64, offset, glyph.index);
11
- write(buffer, t.float64, offset + 8, glyph.x);
12
- write(buffer, t.float64, offset + 16, glyph.y);
13
+ UINT64.write(buffer, offset, glyph.index);
14
+ DOUBLE.write(buffer, offset + 8, glyph.x);
15
+ DOUBLE.write(buffer, offset + 16, glyph.y);
13
16
  offset += GLYPH_SIZE;
14
17
  }
15
18
  return buffer;
@@ -18,8 +21,8 @@ const allocClusterBuffer = (clusters) => {
18
21
  const buffer = alloc(clusters.length * CLUSTER_SIZE);
19
22
  let offset = 0;
20
23
  for (const cluster of clusters) {
21
- write(buffer, t.int32, offset, cluster.numBytes);
22
- write(buffer, t.int32, offset + 4, cluster.numGlyphs);
24
+ INT.write(buffer, offset, cluster.numBytes);
25
+ INT.write(buffer, offset + 4, cluster.numGlyphs);
23
26
  offset += CLUSTER_SIZE;
24
27
  }
25
28
  return buffer;
@@ -27,19 +30,19 @@ const allocClusterBuffer = (clusters) => {
27
30
  const allocTextExtents = () => alloc(TEXT_EXTENTS_SIZE);
28
31
  const allocFontExtents = () => alloc(FONT_EXTENTS_SIZE);
29
32
  const readTextExtents = (handle) => ({
30
- xBearing: read(handle, t.float64, 0),
31
- yBearing: read(handle, t.float64, 8),
32
- width: read(handle, t.float64, 16),
33
- height: read(handle, t.float64, 24),
34
- xAdvance: read(handle, t.float64, 32),
35
- yAdvance: read(handle, t.float64, 40),
33
+ xBearing: DOUBLE.read(handle, 0),
34
+ yBearing: DOUBLE.read(handle, 8),
35
+ width: DOUBLE.read(handle, 16),
36
+ height: DOUBLE.read(handle, 24),
37
+ xAdvance: DOUBLE.read(handle, 32),
38
+ yAdvance: DOUBLE.read(handle, 40),
36
39
  });
37
40
  const readFontExtents = (handle) => ({
38
- ascent: read(handle, t.float64, 0),
39
- descent: read(handle, t.float64, 8),
40
- height: read(handle, t.float64, 16),
41
- maxXAdvance: read(handle, t.float64, 24),
42
- maxYAdvance: read(handle, t.float64, 32),
41
+ ascent: DOUBLE.read(handle, 0),
42
+ descent: DOUBLE.read(handle, 8),
43
+ height: DOUBLE.read(handle, 16),
44
+ maxXAdvance: DOUBLE.read(handle, 24),
45
+ maxYAdvance: DOUBLE.read(handle, 32),
43
46
  });
44
47
  export { allocClusterBuffer, allocFontExtents, allocGlyphBuffer, allocTextExtents, readFontExtents, readTextExtents };
45
48
  //# sourceMappingURL=text.js.map
package/dist/text.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGxF,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,gBAAgB,GAAG,CAAC,MAAoB,EAA0B,EAAE;IACtE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAA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CAAC,CAAC;IACtE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAW;IAC9C,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAW;IAC9C,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAW;IAC5C,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAW;IAC7C,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAW;IAC/C,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAW;CAClD,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,MAA8B,EAAe,EAAE,CAAC,CAAC;IACtE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAW;IAC5C,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAW;IAC7C,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAW;IAC7C,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAW;IAClD,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAW;CACrD,CAAC,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { alloc, type ExternalObject, type Handle, read, t, write } from \"@gtkx/runtime\";\nimport type { CairoGlyph, CairoTextCluster, FontExtents, TextExtents } from \"./types.js\";\n\nconst GLYPH_SIZE = 24;\nconst CLUSTER_SIZE = 8;\nconst TEXT_EXTENTS_SIZE = 48;\nconst FONT_EXTENTS_SIZE = 40;\n\nconst allocGlyphBuffer = (glyphs: CairoGlyph[]): ExternalObject<Handle> => {\n const buffer = alloc(glyphs.length * GLYPH_SIZE);\n let offset = 0;\n\n for (const glyph of glyphs) {\n write(buffer, t.uint64, offset, glyph.index);\n write(buffer, t.float64, offset + 8, glyph.x);\n write(buffer, t.float64, offset + 16, glyph.y);\n offset += GLYPH_SIZE;\n }\n\n return buffer;\n};\n\nconst allocClusterBuffer = (clusters: CairoTextCluster[]): ExternalObject<Handle> => {\n const buffer = alloc(clusters.length * CLUSTER_SIZE);\n let offset = 0;\n\n for (const cluster of clusters) {\n write(buffer, t.int32, offset, cluster.numBytes);\n write(buffer, t.int32, offset + 4, cluster.numGlyphs);\n offset += CLUSTER_SIZE;\n }\n\n return buffer;\n};\n\nconst allocTextExtents = (): ExternalObject<Handle> => alloc(TEXT_EXTENTS_SIZE);\nconst allocFontExtents = (): ExternalObject<Handle> => alloc(FONT_EXTENTS_SIZE);\n\nconst readTextExtents = (handle: ExternalObject<Handle>): TextExtents => ({\n xBearing: read(handle, t.float64, 0) as number,\n yBearing: read(handle, t.float64, 8) as number,\n width: read(handle, t.float64, 16) as number,\n height: read(handle, t.float64, 24) as number,\n xAdvance: read(handle, t.float64, 32) as number,\n yAdvance: read(handle, t.float64, 40) as number,\n});\n\nconst readFontExtents = (handle: ExternalObject<Handle>): FontExtents => ({\n ascent: read(handle, t.float64, 0) as number,\n descent: read(handle, t.float64, 8) as number,\n height: read(handle, t.float64, 16) as number,\n maxXAdvance: read(handle, t.float64, 24) as number,\n maxYAdvance: read(handle, t.float64, 32) as number,\n});\n\nexport { allocClusterBuffer, allocFontExtents, allocGlyphBuffer, allocTextExtents, readFontExtents, readTextExtents };\n"]}
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoC,CAAC,EAAE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AM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAW;CACjD,CAAC,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { alloc, type ExternalObject, type Handle, t } from \"@gtkx/runtime\";\nimport type { CairoGlyph, CairoTextCluster, FontExtents, TextExtents } from \"./types.js\";\n\nconst GLYPH_SIZE = 24;\nconst CLUSTER_SIZE = 8;\nconst TEXT_EXTENTS_SIZE = 48;\nconst FONT_EXTENTS_SIZE = 40;\nconst DOUBLE = t.fieldAt(t.float64);\nconst UINT64 = t.fieldAt(t.uint64);\nconst INT = t.fieldAt(t.int32);\n\nconst allocGlyphBuffer = (glyphs: CairoGlyph[]): ExternalObject<Handle> => {\n const buffer = alloc(glyphs.length * GLYPH_SIZE);\n let offset = 0;\n\n for (const glyph of glyphs) {\n UINT64.write(buffer, offset, glyph.index);\n DOUBLE.write(buffer, offset + 8, glyph.x);\n DOUBLE.write(buffer, offset + 16, glyph.y);\n offset += GLYPH_SIZE;\n }\n\n return buffer;\n};\n\nconst allocClusterBuffer = (clusters: CairoTextCluster[]): ExternalObject<Handle> => {\n const buffer = alloc(clusters.length * CLUSTER_SIZE);\n let offset = 0;\n\n for (const cluster of clusters) {\n INT.write(buffer, offset, cluster.numBytes);\n INT.write(buffer, offset + 4, cluster.numGlyphs);\n offset += CLUSTER_SIZE;\n }\n\n return buffer;\n};\n\nconst allocTextExtents = (): ExternalObject<Handle> => alloc(TEXT_EXTENTS_SIZE);\nconst allocFontExtents = (): ExternalObject<Handle> => alloc(FONT_EXTENTS_SIZE);\n\nconst readTextExtents = (handle: ExternalObject<Handle>): TextExtents => ({\n xBearing: DOUBLE.read(handle, 0) as number,\n yBearing: DOUBLE.read(handle, 8) as number,\n width: DOUBLE.read(handle, 16) as number,\n height: DOUBLE.read(handle, 24) as number,\n xAdvance: DOUBLE.read(handle, 32) as number,\n yAdvance: DOUBLE.read(handle, 40) as number,\n});\n\nconst readFontExtents = (handle: ExternalObject<Handle>): FontExtents => ({\n ascent: DOUBLE.read(handle, 0) as number,\n descent: DOUBLE.read(handle, 8) as number,\n height: DOUBLE.read(handle, 16) as number,\n maxXAdvance: DOUBLE.read(handle, 24) as number,\n maxYAdvance: DOUBLE.read(handle, 32) as number,\n});\n\nexport { allocClusterBuffer, allocFontExtents, allocGlyphBuffer, allocTextExtents, readFontExtents, readTextExtents };\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gtkx/cairo",
3
- "version": "1.3.0",
4
- "description": "Cairo drawing bindings for GTKX: contexts, surfaces, patterns, fonts, regions and matrices behind the GTK draw callbacks",
3
+ "version": "1.4.0",
4
+ "description": "Cairo drawing bindings for GTK: contexts, surfaces, patterns, fonts.",
5
5
  "keywords": [
6
6
  "gtkx",
7
7
  "gtk",
@@ -50,12 +50,12 @@
50
50
  "node": ">=24"
51
51
  },
52
52
  "dependencies": {
53
- "@gtkx/runtime": "1.3.0"
53
+ "@gtkx/runtime": "1.4.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^26.2.0",
57
57
  "fast-xml-parser": "^5.11.0",
58
- "@gtkx/vitest": "1.3.0"
58
+ "@gtkx/vitest": "1.4.0"
59
59
  },
60
60
  "scripts": {
61
61
  "release": "tsx ../../scripts/release-package.ts"
package/src/context.ts CHANGED
@@ -8,7 +8,6 @@ import {
8
8
  setHandle,
9
9
  t,
10
10
  wrapHandle,
11
- write,
12
11
  } from "@gtkx/runtime";
13
12
  import type {
14
13
  Antialias,
@@ -75,6 +74,8 @@ import {
75
74
  const CONTEXT_TYPE = cairoGType("cairo_gobject_context_get_type");
76
75
  const RECTANGLE_SIZE = 32;
77
76
  const RECTANGLE_LIST_COUNT_OFFSET = 16;
77
+ const DOUBLE = t.fieldAt(t.float64);
78
+ const RECTANGLE_LIST_COUNT = t.field(t.int32, RECTANGLE_LIST_COUNT_OFFSET);
78
79
  const RECTANGLE_LIST_DATA_OFFSET = 8;
79
80
  const POINT_ARGS = [CONTEXT_T, t.float64, t.float64];
80
81
  const EXTENTS_ARGS = [CONTEXT_T, t.ref(t.float64), t.ref(t.float64), t.ref(t.float64), t.ref(t.float64)];
@@ -171,7 +172,6 @@ const cairoInStroke = bindCairo("cairo_in_stroke", POINT_ARGS, t.boolean);
171
172
  const cairoInFill = bindCairo("cairo_in_fill", POINT_ARGS, t.boolean);
172
173
  const cairoInClip = bindCairo("cairo_in_clip", POINT_ARGS, t.boolean);
173
174
  const cairoCopyClipRectangleList = bindCairo("cairo_copy_clip_rectangle_list", [CONTEXT_T], RECTANGLE_LIST_T);
174
- const cairoRectangleListDestroy = bindCairo("cairo_rectangle_list_destroy", [RECTANGLE_LIST_T], t.void);
175
175
  const cairoMask = bindCairo("cairo_mask", [CONTEXT_T, PATTERN_T], t.void);
176
176
  const cairoMaskSurface = bindCairo("cairo_mask_surface", [CONTEXT_T, SURFACE_T, t.float64, t.float64], t.void);
177
177
  const cairoSetMatrix = bindCairo("cairo_set_matrix", [CONTEXT_T, MATRIX_T], t.void);
@@ -236,24 +236,24 @@ const allocDashBuffer = (dashes: number[]): ExternalObject<Handle> => {
236
236
  const buffer = alloc(dashes.length * 8);
237
237
 
238
238
  for (const [index, dash] of dashes.entries()) {
239
- write(buffer, t.float64, index * 8, dash);
239
+ DOUBLE.write(buffer, index * 8, dash);
240
240
  }
241
241
 
242
242
  return buffer;
243
243
  };
244
244
 
245
245
  const readDashes = (buffer: ExternalObject<Handle>, count: number): number[] =>
246
- Array.from({ length: count }, (_, index) => read(buffer, t.float64, index * 8) as number);
246
+ Array.from({ length: count }, (_, index) => DOUBLE.read(buffer, index * 8) as number);
247
247
 
248
248
  const readRectangle = (rects: ExternalObject<Handle>, base: number): RectangleData => ({
249
- x: read(rects, t.float64, base) as number,
250
- y: read(rects, t.float64, base + 8) as number,
251
- width: read(rects, t.float64, base + 16) as number,
252
- height: read(rects, t.float64, base + 24) as number,
249
+ x: DOUBLE.read(rects, base) as number,
250
+ y: DOUBLE.read(rects, base + 8) as number,
251
+ width: DOUBLE.read(rects, base + 16) as number,
252
+ height: DOUBLE.read(rects, base + 24) as number,
253
253
  });
254
254
 
255
255
  const readRectangleList = (listHandle: ExternalObject<Handle>): RectangleData[] => {
256
- const count = read(listHandle, t.int32, RECTANGLE_LIST_COUNT_OFFSET) as number;
256
+ const count = RECTANGLE_LIST_COUNT.read(listHandle) as number;
257
257
 
258
258
  if (count === 0) {
259
259
  return [];
@@ -695,11 +695,7 @@ class Context {
695
695
 
696
696
  /** Returns the current clip as a list of rectangles in user space. */
697
697
  copyClipRectangleList(): RectangleData[] {
698
- const listHandle = cairoCopyClipRectangleList(getHandle(this)) as ExternalObject<Handle>;
699
- const rects = readRectangleList(listHandle);
700
- cairoRectangleListDestroy(listHandle);
701
-
702
- return rects;
698
+ return readRectangleList(cairoCopyClipRectangleList(getHandle(this)) as ExternalObject<Handle>);
703
699
  }
704
700
 
705
701
  /** Paints the current source using the alpha channel of `pattern` as a mask. */
package/src/font-face.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  type WrapperClassResolver,
10
10
  } from "@gtkx/runtime";
11
11
  import { type FontSlant, FontType, type FontWeight, type Status } from "./enums.js";
12
- import { bindCairo, cairoGType, FC_PATTERN_T, FONT_FACE_FULL_T, FONT_FACE_T, FT_FACE_T } from "./lib.js";
12
+ import { bindCairo, cairoGType, FONT_FACE_FULL_T, FONT_FACE_T } from "./lib.js";
13
13
 
14
14
  /** One of the `FtSynthesize` styles a FreeType font face synthesizes. */
15
15
  type FtSynthesize = (typeof FtSynthesize)[keyof typeof FtSynthesize];
@@ -24,24 +24,12 @@ const cairoFtFontFaceGetSynthesize = bindCairo("cairo_ft_font_face_get_synthesiz
24
24
  const cairoFtFontFaceSetSynthesize = bindCairo("cairo_ft_font_face_set_synthesize", [FONT_FACE_T, t.int32], t.void);
25
25
  const cairoToyFontFaceGetFamily = bindCairo("cairo_toy_font_face_get_family", [FONT_FACE_T], t.string("borrowed"));
26
26
 
27
- const cairoFtFontFaceCreateForPattern = bindCairo(
28
- "cairo_ft_font_face_create_for_pattern",
29
- [FC_PATTERN_T],
30
- FONT_FACE_FULL_T,
31
- );
32
-
33
27
  const cairoToyFontFaceCreate = bindCairo(
34
28
  "cairo_toy_font_face_create",
35
29
  [t.string("full"), t.int32, t.int32],
36
30
  FONT_FACE_FULL_T,
37
31
  );
38
32
 
39
- const cairoFtFontFaceCreateForFtFace = bindCairo(
40
- "cairo_ft_font_face_create_for_ft_face",
41
- [FT_FACE_T, t.int32],
42
- FONT_FACE_FULL_T,
43
- );
44
-
45
33
  const cairoFtFontFaceUnsetSynthesize = bindCairo(
46
34
  "cairo_ft_font_face_unset_synthesize",
47
35
  [FONT_FACE_T, t.int32],
@@ -75,7 +63,7 @@ const fontFaceClassFor: WrapperClassResolver = (handle) => {
75
63
 
76
64
  /**
77
65
  * A cairo font face (`cairo_font_face_t`): a typeface independent of size and transformation. Font faces come
78
- * from the `create*` statics or from a context, and wrap as the concrete class their type reports
66
+ * from `create` or a context, and wrap as the concrete class their type reports
79
67
  * (`instanceof ToyFontFace` after `selectFontFace`).
80
68
  */
81
69
  abstract class FontFace {
@@ -89,16 +77,6 @@ abstract class FontFace {
89
77
  return wrapHandle(cairoToyFontFaceCreate(family, slant, weight) as ExternalObject<Handle>, ToyFontFace);
90
78
  }
91
79
 
92
- /** Creates a font face for a FreeType `FT_Face` handle, with the given `FT_LOAD_*` flags. */
93
- static createForFtFace(face: ExternalObject<Handle>, loadFlags: number): FtFontFace {
94
- return wrapHandle(cairoFtFontFaceCreateForFtFace(face, loadFlags) as ExternalObject<Handle>, FtFontFace);
95
- }
96
-
97
- /** Creates a font face for a fontconfig `FcPattern` handle. */
98
- static createForPattern(pattern: ExternalObject<Handle>): FtFontFace {
99
- return wrapHandle(cairoFtFontFaceCreateForPattern(pattern) as ExternalObject<Handle>, FtFontFace);
100
- }
101
-
102
80
  /** GType of `CairoFontFace`, the boxed type this class is registered under. */
103
81
  declare __type__: bigint;
104
82
 
@@ -136,7 +114,7 @@ class ToyFontFace extends FontFace {
136
114
  }
137
115
  }
138
116
 
139
- /** A FreeType font face, created with `FontFace.createForFtFace` or `FontFace.createForPattern`. */
117
+ /** A FreeType font face returned by Cairo or another native library. */
140
118
  class FtFontFace extends FontFace {
141
119
  /** Returns the styles currently synthesized for the font face. */
142
120
  getSynthesize(): FtSynthesize {
package/src/lib.ts CHANGED
@@ -97,8 +97,6 @@ const SCALED_FONT_FULL_T: BoxedDescriptor = t.boxed("CairoScaledFont", {
97
97
  getTypeFnName: "cairo_gobject_scaled_font_get_type",
98
98
  });
99
99
 
100
- const FC_PATTERN_T: BoxedDescriptor = t.boxed("FcPattern", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
101
- const FT_FACE_T: BoxedDescriptor = t.boxed("FT_Face", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
102
100
  const MATRIX_T: BoxedDescriptor = t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
103
101
 
104
102
  const RECTANGLE_T: BoxedDescriptor = t.boxed("cairo_rectangle_t", {
@@ -117,8 +115,9 @@ const RECTANGLE_INT_ARRAY_T: BoxedDescriptor = t.boxed("cairo_rectangle_int_t[]"
117
115
  });
118
116
 
119
117
  const RECTANGLE_LIST_T: BoxedDescriptor = t.boxed("cairo_rectangle_list_t", {
120
- ownership: "borrowed",
118
+ ownership: "full",
121
119
  sharedLibrary: CAIRO_LIBRARY,
120
+ freeFnName: "cairo_rectangle_list_destroy",
122
121
  });
123
122
 
124
123
  const GLYPH_T: BoxedDescriptor = t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
@@ -159,13 +158,11 @@ export {
159
158
  CONTEXT_T,
160
159
  DEVICE_T,
161
160
  DOUBLE_BUFFER_T,
162
- FC_PATTERN_T,
163
161
  FONT_EXTENTS_T,
164
162
  FONT_FACE_FULL_T,
165
163
  FONT_FACE_T,
166
164
  FONT_OPTIONS_FULL_T,
167
165
  FONT_OPTIONS_T,
168
- FT_FACE_T,
169
166
  GLYPH_T,
170
167
  MATRIX_T,
171
168
  PATH_T,
package/src/path.ts CHANGED
@@ -9,10 +9,13 @@ type SegmentReader = (data: PathBuffer, base: number) => PathData;
9
9
  const ELEMENT_SIZE = 16;
10
10
  const DATA_OFFSET = 8;
11
11
  const NUM_DATA_OFFSET = 16;
12
+ const DOUBLE = t.fieldAt(t.float64);
13
+ const INT = t.fieldAt(t.int32);
14
+ const NUM_DATA = t.field(t.int32, NUM_DATA_OFFSET);
12
15
 
13
16
  const readPoint = (data: PathBuffer, base: number): Point => ({
14
- x: read(data, t.float64, base) as number,
15
- y: read(data, t.float64, base + 8) as number,
17
+ x: DOUBLE.read(data, base) as number,
18
+ y: DOUBLE.read(data, base + 8) as number,
16
19
  });
17
20
 
18
21
  const readMoveTo: SegmentReader = (data, base) => ({ type: "moveTo", ...readPoint(data, base + ELEMENT_SIZE) });
@@ -49,7 +52,7 @@ const segmentReaderFor = (headerType: PathDataType): SegmentReader | null => {
49
52
  };
50
53
 
51
54
  const parsePath = (pathHandle: PathBuffer): PathData[] => {
52
- const numData = read(pathHandle, t.int32, NUM_DATA_OFFSET) as number;
55
+ const numData = NUM_DATA.read(pathHandle) as number;
53
56
 
54
57
  if (numData === 0) {
55
58
  return [];
@@ -61,13 +64,13 @@ const parsePath = (pathHandle: PathBuffer): PathData[] => {
61
64
 
62
65
  while (index < numData) {
63
66
  const base = index * ELEMENT_SIZE;
64
- const reader = segmentReaderFor(read(data, t.int32, base) as PathDataType);
67
+ const reader = segmentReaderFor(INT.read(data, base) as PathDataType);
65
68
 
66
69
  if (reader !== null) {
67
70
  segments.push(reader(data, base));
68
71
  }
69
72
 
70
- index += read(data, t.int32, base + 4) as number;
73
+ index += INT.read(data, base + 4) as number;
71
74
  }
72
75
 
73
76
  return segments;
package/src/region.ts CHANGED
@@ -7,7 +7,6 @@ import {
7
7
  setHandle,
8
8
  t,
9
9
  wrapHandle,
10
- write,
11
10
  } from "@gtkx/runtime";
12
11
  import type { RegionOverlap, Status } from "./enums.js";
13
12
  import type { RectangleData } from "./types.js";
@@ -53,16 +52,17 @@ const cairoRegionIntersectRectangle = bindCairo("cairo_region_intersect_rectangl
53
52
  const cairoRegionSubtractRectangle = bindCairo("cairo_region_subtract_rectangle", RECTANGLE_OP_ARGS, t.int32);
54
53
  const cairoRegionUnionRectangle = bindCairo("cairo_region_union_rectangle", RECTANGLE_OP_ARGS, t.int32);
55
54
  const cairoRegionXorRectangle = bindCairo("cairo_region_xor_rectangle", RECTANGLE_OP_ARGS, t.int32);
55
+ const INT = t.fieldAt(t.int32);
56
56
 
57
57
  const allocRectangleBuffer = (rects: RectangleData[]): ExternalObject<Handle> => {
58
58
  const buffer = alloc(rects.length * RECTANGLE_INT_SIZE);
59
59
  let offset = 0;
60
60
 
61
61
  for (const rect of rects) {
62
- write(buffer, t.int32, offset, rect.x);
63
- write(buffer, t.int32, offset + 4, rect.y);
64
- write(buffer, t.int32, offset + 8, rect.width);
65
- write(buffer, t.int32, offset + 12, rect.height);
62
+ INT.write(buffer, offset, rect.x);
63
+ INT.write(buffer, offset + 4, rect.y);
64
+ INT.write(buffer, offset + 8, rect.width);
65
+ INT.write(buffer, offset + 12, rect.height);
66
66
  offset += RECTANGLE_INT_SIZE;
67
67
  }
68
68