@gtkx/cairo 1.2.2 → 1.3.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,kBAAkB,GAAG,SAAS,CAAC,sBAAsB,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEnF,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,OAAe,EAAQ,EAAE;IAC1D,IAAI,MAAM,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO;IACX,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,kBAAkB,OAAO,MAAM,cAAc,CAAC,MAAM,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAClG,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,MAA8B,EAA0B,EAAE;IAC5E,WAAW,CAAC,kBAAkB,CAAC,MAAM,CAAW,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import type { ExternalObject, Handle } from \"@gtkx/runtime\";\nimport { t } from \"@gtkx/runtime\";\nimport { Status } from \"./enums.js\";\nimport { bindCairo, SURFACE_T } from \"./lib.js\";\nimport { statusToString } from \"./version.js\";\n\nconst cairoSurfaceStatus = bindCairo(\"cairo_surface_status\", [SURFACE_T], t.int32);\n\nconst checkStatus = (status: Status, subject: string): void => {\n if (status === Status.SUCCESS) {\n return;\n }\n\n throw new Error(`cairo error on ${subject}: \"${statusToString(status)}\" (${String(status)})`);\n};\n\nconst checkSurface = (handle: ExternalObject<Handle>): ExternalObject<Handle> => {\n checkStatus(cairoSurfaceStatus(handle) as Status, \"surface\");\n\n return handle;\n};\n\nexport { checkStatus, checkSurface };\n"]}
package/dist/surface.d.ts CHANGED
@@ -12,7 +12,7 @@ declare abstract class Surface {
12
12
  /** Creates a surface of the given `content` and size as compatible as possible with `other`. */
13
13
  static createSimilar(other: Surface, content: Content, width: number, height: number): Surface;
14
14
  /** Creates an image surface of the given `format` and size as compatible as possible with `other`. */
15
- static createSimilarImage(other: Surface, format: Format, width: number, height: number): Surface;
15
+ static createSimilarImage(other: Surface, format: Format, width: number, height: number): ImageSurface;
16
16
  /** Creates a surface that draws onto the given rectangle of `target`. */
17
17
  static createForRectangle(target: Surface, x: number, y: number, width: number, height: number): Surface;
18
18
  /** GType of `CairoSurface`, the boxed type this class is registered under. */
@@ -68,7 +68,7 @@ declare abstract class Surface {
68
68
  declare class ImageSurface extends Surface {
69
69
  /** Creates an image surface of the given pixel `format` and size, the same as `new ImageSurface(...)`. */
70
70
  static create(format: Format, width: number, height: number): ImageSurface;
71
- /** Loads a PNG file into a new image surface; a missing or invalid file yields a surface in an error status. */
71
+ /** Loads a PNG file into a new image surface; throws when the file is missing or invalid. */
72
72
  static createFromPng(filename: string): ImageSurface;
73
73
  /** Creates an image surface of the given pixel `format` and size. */
74
74
  constructor(format: Format, width: number, height: number);
@@ -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,aA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aAAa,GAAG,IAAI;CAMrC;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC"}
package/dist/surface.js CHANGED
@@ -2,6 +2,7 @@ import { alloc, getHandle, read, registerWrapperClass, registerWrapperClassResol
2
2
  import { SurfaceType } from "./enums.js";
3
3
  import { FontOptions } from "./font-options.js";
4
4
  import { bindCairo, cairoGType, DEVICE_T, FONT_OPTIONS_T, RECTANGLE_INT_T, RECTANGLE_T, SURFACE_FULL_T, SURFACE_T, } from "./lib.js";
5
+ import { checkSurface } from "./status.js";
5
6
  const SURFACE_TYPE = cairoGType("cairo_gobject_surface_get_type");
6
7
  const RECTANGLE_SIZE = 32;
7
8
  const DEVICE_PAIR_ARGS = [SURFACE_T, t.float64, t.float64];
@@ -89,15 +90,18 @@ class Surface {
89
90
  }
90
91
  /** Creates a surface of the given `content` and size as compatible as possible with `other`. */
91
92
  static createSimilar(other, content, width, height) {
92
- return wrapSurface(cairoSurfaceCreateSimilar(getHandle(other), content, width, height));
93
+ const handle = cairoSurfaceCreateSimilar(getHandle(other), content, width, height);
94
+ return wrapSurface(checkSurface(handle));
93
95
  }
94
96
  /** Creates an image surface of the given `format` and size as compatible as possible with `other`. */
95
97
  static createSimilarImage(other, format, width, height) {
96
- return wrapSurface(cairoSurfaceCreateSimilarImage(getHandle(other), format, width, height));
98
+ const handle = cairoSurfaceCreateSimilarImage(getHandle(other), format, width, height);
99
+ return wrapHandle(checkSurface(handle), ImageSurface);
97
100
  }
98
101
  /** Creates a surface that draws onto the given rectangle of `target`. */
99
102
  static createForRectangle(target, x, y, width, height) {
100
- return wrapSurface(cairoSurfaceCreateForRectangle(getHandle(target), x, y, width, height));
103
+ const handle = cairoSurfaceCreateForRectangle(getHandle(target), x, y, width, height);
104
+ return wrapSurface(checkSurface(handle));
101
105
  }
102
106
  /** Writes the surface to a PNG file at `filename` and returns the resulting status. */
103
107
  writeToPng(filename) {
@@ -201,16 +205,16 @@ class Surface {
201
205
  class ImageSurface extends Surface {
202
206
  /** Creates an image surface of the given pixel `format` and size, the same as `new ImageSurface(...)`. */
203
207
  static create(format, width, height) {
204
- return wrapHandle(cairoImageSurfaceCreate(format, width, height), this);
208
+ return wrapHandle(checkSurface(cairoImageSurfaceCreate(format, width, height)), this);
205
209
  }
206
- /** Loads a PNG file into a new image surface; a missing or invalid file yields a surface in an error status. */
210
+ /** Loads a PNG file into a new image surface; throws when the file is missing or invalid. */
207
211
  static createFromPng(filename) {
208
- return wrapHandle(cairoImageSurfaceCreateFromPng(filename), this);
212
+ return wrapHandle(checkSurface(cairoImageSurfaceCreateFromPng(filename)), this);
209
213
  }
210
214
  /** Creates an image surface of the given pixel `format` and size. */
211
215
  constructor(format, width, height) {
212
216
  super();
213
- setHandle(this, cairoImageSurfaceCreate(format, width, height));
217
+ setHandle(this, checkSurface(cairoImageSurfaceCreate(format, width, height)));
214
218
  }
215
219
  /** Returns the width of the surface in pixels. */
216
220
  getWidth() {
@@ -252,7 +256,7 @@ class RecordingSurface extends Surface {
252
256
  /** Creates a recording surface of the given `content`, bounded to `extents` or unbounded when omitted. */
253
257
  constructor(content, extents) {
254
258
  super();
255
- setHandle(this, createRecordingSurface(content, extents));
259
+ setHandle(this, checkSurface(createRecordingSurface(content, extents)));
256
260
  }
257
261
  /** Returns the area that has been drawn on so far. */
258
262
  inkExtents() {
@@ -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,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACH,SAAS,EAET,UAAU,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf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C;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\";\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 return wrapSurface(cairoSurfaceCreateSimilar(getHandle(other), content, width, height));\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): Surface {\n return wrapSurface(cairoSurfaceCreateSimilarImage(getHandle(other), format, width, height));\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 return wrapSurface(cairoSurfaceCreateForRectangle(getHandle(target), x, y, width, height));\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(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>, this);\n }\n\n /** Loads a PNG file into a new image surface; a missing or invalid file yields a surface in an error status. */\n static createFromPng(filename: string): ImageSurface {\n return wrapHandle(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, 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, 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,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,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACH,SAAS,EAET,UAAU,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,WAAW,EACX,cAAc,EACd,SAAS,GACZ,MAAM,U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AE,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"]}
package/package.json CHANGED
@@ -1,64 +1,63 @@
1
1
  {
2
- "name": "@gtkx/cairo",
3
- "version": "1.2.2",
4
- "description": "Cairo drawing bindings for GTKX: contexts, surfaces, patterns, fonts, regions and matrices behind the GTK draw callbacks",
5
- "keywords": [
6
- "gtkx",
7
- "gtk",
8
- "gtk4",
9
- "cairo",
10
- "drawing",
11
- "graphics",
12
- "linux",
13
- "desktop"
14
- ],
15
- "homepage": "https://gtkx.dev",
16
- "bugs": {
17
- "url": "https://github.com/gtkx-org/gtkx/issues"
18
- },
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/gtkx-org/gtkx.git",
22
- "directory": "packages/cairo"
23
- },
24
- "license": "MPL-2.0",
25
- "author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
26
- "type": "module",
27
- "sideEffects": true,
28
- "exports": {
29
- "./package.json": "./package.json",
30
- ".": {
31
- "source": "./src/index.ts",
32
- "types": "./dist/index.d.ts",
33
- "default": "./dist/index.js"
34
- }
35
- },
36
- "files": [
37
- "dist",
38
- "src"
39
- ],
40
- "scripts": {
41
- "release": "tsx ../../scripts/release-package.ts"
42
- },
43
- "nx": {
44
- "targets": {
45
- "lint": {
46
- "options": {
47
- "cwd": ".",
48
- "command": "eslint {projectRoot}"
49
- }
50
- }
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",
5
+ "keywords": [
6
+ "gtkx",
7
+ "gtk",
8
+ "gtk4",
9
+ "cairo",
10
+ "drawing",
11
+ "graphics",
12
+ "linux",
13
+ "desktop"
14
+ ],
15
+ "homepage": "https://gtkx.dev",
16
+ "bugs": {
17
+ "url": "https://github.com/gtkx-org/gtkx/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/gtkx-org/gtkx.git",
22
+ "directory": "packages/cairo"
23
+ },
24
+ "license": "MPL-2.0",
25
+ "author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
26
+ "type": "module",
27
+ "sideEffects": true,
28
+ "exports": {
29
+ "./package.json": "./package.json",
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "src"
38
+ ],
39
+ "nx": {
40
+ "targets": {
41
+ "lint": {
42
+ "options": {
43
+ "cwd": ".",
44
+ "command": "eslint {projectRoot}"
51
45
  }
52
- },
53
- "engines": {
54
- "node": ">=24"
55
- },
56
- "dependencies": {
57
- "@gtkx/runtime": "workspace:*"
58
- },
59
- "devDependencies": {
60
- "@gtkx/vitest": "workspace:*",
61
- "@types/node": "catalog:",
62
- "fast-xml-parser": "^5.11.0"
46
+ }
63
47
  }
64
- }
48
+ },
49
+ "engines": {
50
+ "node": ">=24"
51
+ },
52
+ "dependencies": {
53
+ "@gtkx/runtime": "1.3.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/node": "^26.2.0",
57
+ "fast-xml-parser": "^5.11.0",
58
+ "@gtkx/vitest": "1.3.0"
59
+ },
60
+ "scripts": {
61
+ "release": "tsx ../../scripts/release-package.ts"
62
+ }
63
+ }
package/src/context.ts CHANGED
@@ -61,6 +61,7 @@ import { allocMatrix, Matrix } from "./matrix.js";
61
61
  import { parsePath } from "./path.js";
62
62
  import { Pattern } from "./pattern.js";
63
63
  import { ScaledFont } from "./scaled-font.js";
64
+ import { checkStatus } from "./status.js";
64
65
  import { Surface } from "./surface.js";
65
66
  import {
66
67
  allocClusterBuffer,
@@ -308,9 +309,11 @@ class Context {
308
309
  /** GType of `CairoContext`, the boxed type this class is registered under. */
309
310
  declare __type__: bigint;
310
311
 
311
- /** Creates a context drawing onto `target`. */
312
+ /** Creates a context drawing onto `target`, throwing when it cannot be created, such as on a finished surface. */
312
313
  constructor(target: Surface) {
313
- setHandle(this, cairoCreate(getHandle(target)) as ExternalObject<Handle>);
314
+ const handle = cairoCreate(getHandle(target)) as ExternalObject<Handle>;
315
+ checkStatus(cairoStatus(handle) as Status, "context");
316
+ setHandle(this, handle);
314
317
  }
315
318
 
316
319
  /** Begins a new sub-path at `(x, y)`, which becomes the current point. */
package/src/pattern.ts CHANGED
@@ -8,7 +8,6 @@ import {
8
8
  wrapHandle,
9
9
  type WrapperClassResolver,
10
10
  } from "@gtkx/runtime";
11
- import type { Surface } from "./surface.js";
12
11
  import type { ColorStop, LinearPoints, PathData, Point, RadialCircles, RgbaColor } from "./types.js";
13
12
  import { type Extend, type Filter, PatternType, type Status } from "./enums.js";
14
13
  import {
@@ -23,6 +22,8 @@ import {
23
22
  } from "./lib.js";
24
23
  import { allocMatrix, Matrix } from "./matrix.js";
25
24
  import { parsePath } from "./path.js";
25
+ import { checkStatus } from "./status.js";
26
+ import { Surface } from "./surface.js";
26
27
 
27
28
  type RgbaRefs = [
28
29
  red: { value: number },
@@ -91,6 +92,7 @@ const cairoPatternSetMatrix = bindCairo("cairo_pattern_set_matrix", [PATTERN_T,
91
92
  const cairoPatternGetMatrix = bindCairo("cairo_pattern_get_matrix", [PATTERN_T, MATRIX_T], t.void);
92
93
  const cairoPatternGetType = bindCairo("cairo_pattern_get_type", [PATTERN_T], t.int32);
93
94
  const cairoPatternGetReferenceCount = bindCairo("cairo_pattern_get_reference_count", [PATTERN_T], t.int32);
95
+ const cairoPatternGetSurface = bindCairo("cairo_pattern_get_surface", [PATTERN_T, t.ref(SURFACE_T)], t.int32);
94
96
 
95
97
  const cairoPatternGetLinearPoints = bindCairo(
96
98
  "cairo_pattern_get_linear_points",
@@ -155,6 +157,12 @@ const cairoMeshPatternGetCornerColorRgba = bindCairo(
155
157
 
156
158
  const wrapPattern = (handle: unknown): Pattern => wrapHandle(handle as ExternalObject<Handle>, Pattern);
157
159
 
160
+ const checkPattern = <T extends Pattern>(pattern: T): T => {
161
+ checkStatus(pattern.status(), "pattern");
162
+
163
+ return pattern;
164
+ };
165
+
158
166
  const readRgba = (fill: (...refs: RgbaRefs) => void): RgbaColor => {
159
167
  const red = { value: 0 };
160
168
  const green = { value: 0 };
@@ -203,17 +211,19 @@ abstract class Pattern {
203
211
 
204
212
  /** Creates an opaque solid-color pattern. */
205
213
  static createRgb(red: number, green: number, blue: number): Pattern {
206
- return wrapPattern(cairoPatternCreateRgb(red, green, blue));
214
+ return checkPattern(wrapPattern(cairoPatternCreateRgb(red, green, blue)));
207
215
  }
208
216
 
209
217
  /** Creates a translucent solid-color pattern. */
210
218
  static createRgba(red: number, green: number, blue: number, alpha: number): Pattern {
211
- return wrapPattern(cairoPatternCreateRgba(red, green, blue, alpha));
219
+ return checkPattern(wrapPattern(cairoPatternCreateRgba(red, green, blue, alpha)));
212
220
  }
213
221
 
214
222
  /** Creates a linear gradient between `(x0, y0)` and `(x1, y1)`; add stops with `addColorStopRgba`. */
215
223
  static createLinear(x0: number, y0: number, x1: number, y1: number): LinearPattern {
216
- return wrapHandle(cairoPatternCreateLinear(x0, y0, x1, y1) as ExternalObject<Handle>, LinearPattern);
224
+ const handle = cairoPatternCreateLinear(x0, y0, x1, y1) as ExternalObject<Handle>;
225
+
226
+ return checkPattern(wrapHandle(handle, LinearPattern));
217
227
  }
218
228
 
219
229
  /** Creates a radial gradient between two circles; add stops with `addColorStopRgba`. */
@@ -227,17 +237,19 @@ abstract class Pattern {
227
237
  ): RadialPattern {
228
238
  const handle = cairoPatternCreateRadial(cx0, cy0, radius0, cx1, cy1, radius1) as ExternalObject<Handle>;
229
239
 
230
- return wrapHandle(handle, RadialPattern);
240
+ return checkPattern(wrapHandle(handle, RadialPattern));
231
241
  }
232
242
 
233
243
  /** Creates an empty mesh gradient; describe its patches with the `MeshPattern` methods. */
234
244
  static createMesh(): MeshPattern {
235
- return wrapHandle(cairoPatternCreateMesh() as ExternalObject<Handle>, MeshPattern);
245
+ return checkPattern(wrapHandle(cairoPatternCreateMesh() as ExternalObject<Handle>, MeshPattern));
236
246
  }
237
247
 
238
248
  /** Creates a pattern that paints with the content of `surface`. */
239
249
  static createForSurface(surface: Surface): Pattern {
240
- return wrapPattern(cairoPatternCreateForSurface(getHandle(surface)));
250
+ const handle = getHandle(surface);
251
+
252
+ return checkPattern(wrapPattern(cairoPatternCreateForSurface(handle)));
241
253
  }
242
254
 
243
255
  /** GType of `CairoPattern`, the boxed type this class is registered under. */
@@ -318,6 +330,18 @@ abstract class Pattern {
318
330
  getReferenceCount(): number {
319
331
  return cairoPatternGetReferenceCount(getHandle(this)) as number;
320
332
  }
333
+
334
+ /** Returns the surface of a surface pattern; throws for a pattern that has no surface. */
335
+ getSurface(): Surface {
336
+ const surface: { value: ExternalObject<Handle> | null } = { value: null };
337
+ checkStatus(cairoPatternGetSurface(getHandle(this), surface) as Status, "pattern");
338
+
339
+ if (surface.value === null) {
340
+ throw new Error("cairo pattern has no surface");
341
+ }
342
+
343
+ return wrapHandle(surface.value, Surface);
344
+ }
321
345
  }
322
346
 
323
347
  /** A linear gradient pattern, created with `Pattern.createLinear`. */
package/src/status.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { ExternalObject, Handle } from "@gtkx/runtime";
2
+ import { t } from "@gtkx/runtime";
3
+ import { Status } from "./enums.js";
4
+ import { bindCairo, SURFACE_T } from "./lib.js";
5
+ import { statusToString } from "./version.js";
6
+
7
+ const cairoSurfaceStatus = bindCairo("cairo_surface_status", [SURFACE_T], t.int32);
8
+
9
+ const checkStatus = (status: Status, subject: string): void => {
10
+ if (status === Status.SUCCESS) {
11
+ return;
12
+ }
13
+
14
+ throw new Error(`cairo error on ${subject}: "${statusToString(status)}" (${String(status)})`);
15
+ };
16
+
17
+ const checkSurface = (handle: ExternalObject<Handle>): ExternalObject<Handle> => {
18
+ checkStatus(cairoSurfaceStatus(handle) as Status, "surface");
19
+
20
+ return handle;
21
+ };
22
+
23
+ export { checkStatus, checkSurface };
package/src/surface.ts CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  SURFACE_FULL_T,
28
28
  SURFACE_T,
29
29
  } from "./lib.js";
30
+ import { checkSurface } from "./status.js";
30
31
 
31
32
  const SURFACE_TYPE = cairoGType("cairo_gobject_surface_get_type");
32
33
  const RECTANGLE_SIZE = 32;
@@ -174,17 +175,25 @@ abstract class Surface {
174
175
 
175
176
  /** Creates a surface of the given `content` and size as compatible as possible with `other`. */
176
177
  static createSimilar(other: Surface, content: Content, width: number, height: number): Surface {
177
- return wrapSurface(cairoSurfaceCreateSimilar(getHandle(other), content, width, height));
178
+ const handle = cairoSurfaceCreateSimilar(getHandle(other), content, width, height) as ExternalObject<Handle>;
179
+
180
+ return wrapSurface(checkSurface(handle));
178
181
  }
179
182
 
180
183
  /** Creates an image surface of the given `format` and size as compatible as possible with `other`. */
181
- static createSimilarImage(other: Surface, format: Format, width: number, height: number): Surface {
182
- return wrapSurface(cairoSurfaceCreateSimilarImage(getHandle(other), format, width, height));
184
+ static createSimilarImage(other: Surface, format: Format, width: number, height: number): ImageSurface {
185
+ const handle =
186
+ cairoSurfaceCreateSimilarImage(getHandle(other), format, width, height) as ExternalObject<Handle>;
187
+
188
+ return wrapHandle(checkSurface(handle), ImageSurface);
183
189
  }
184
190
 
185
191
  /** Creates a surface that draws onto the given rectangle of `target`. */
186
192
  static createForRectangle(target: Surface, x: number, y: number, width: number, height: number): Surface {
187
- return wrapSurface(cairoSurfaceCreateForRectangle(getHandle(target), x, y, width, height));
193
+ const handle =
194
+ cairoSurfaceCreateForRectangle(getHandle(target), x, y, width, height) as ExternalObject<Handle>;
195
+
196
+ return wrapSurface(checkSurface(handle));
188
197
  }
189
198
 
190
199
  /** GType of `CairoSurface`, the boxed type this class is registered under. */
@@ -316,18 +325,21 @@ abstract class Surface {
316
325
  class ImageSurface extends Surface {
317
326
  /** Creates an image surface of the given pixel `format` and size, the same as `new ImageSurface(...)`. */
318
327
  static create(format: Format, width: number, height: number): ImageSurface {
319
- return wrapHandle(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>, this);
328
+ return wrapHandle(
329
+ checkSurface(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>),
330
+ this,
331
+ );
320
332
  }
321
333
 
322
- /** Loads a PNG file into a new image surface; a missing or invalid file yields a surface in an error status. */
334
+ /** Loads a PNG file into a new image surface; throws when the file is missing or invalid. */
323
335
  static createFromPng(filename: string): ImageSurface {
324
- return wrapHandle(cairoImageSurfaceCreateFromPng(filename) as ExternalObject<Handle>, this);
336
+ return wrapHandle(checkSurface(cairoImageSurfaceCreateFromPng(filename) as ExternalObject<Handle>), this);
325
337
  }
326
338
 
327
339
  /** Creates an image surface of the given pixel `format` and size. */
328
340
  constructor(format: Format, width: number, height: number) {
329
341
  super();
330
- setHandle(this, cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>);
342
+ setHandle(this, checkSurface(cairoImageSurfaceCreate(format, width, height) as ExternalObject<Handle>));
331
343
  }
332
344
 
333
345
  /** Returns the width of the surface in pixels. */
@@ -385,7 +397,7 @@ class RecordingSurface extends Surface {
385
397
  /** Creates a recording surface of the given `content`, bounded to `extents` or unbounded when omitted. */
386
398
  constructor(content: Content, extents?: RectangleData) {
387
399
  super();
388
- setHandle(this, createRecordingSurface(content, extents));
400
+ setHandle(this, checkSurface(createRecordingSurface(content, extents)));
389
401
  }
390
402
 
391
403
  /** Returns the area that has been drawn on so far. */