@gtkx/cairo 1.2.2 → 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.
Files changed (55) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +174 -0
  3. package/dist/context.d.ts +1 -1
  4. package/dist/context.d.ts.map +1 -1
  5. package/dist/context.js +16 -15
  6. package/dist/context.js.map +1 -1
  7. package/dist/font-face.d.ts +2 -7
  8. package/dist/font-face.d.ts.map +1 -1
  9. package/dist/font-face.js +3 -13
  10. package/dist/font-face.js.map +1 -1
  11. package/dist/lib.d.ts +1 -3
  12. package/dist/lib.d.ts.map +1 -1
  13. package/dist/lib.js +3 -4
  14. package/dist/lib.js.map +1 -1
  15. package/dist/path.d.ts.map +1 -1
  16. package/dist/path.js +8 -5
  17. package/dist/path.js.map +1 -1
  18. package/dist/pattern.d.ts +3 -1
  19. package/dist/pattern.d.ts.map +1 -1
  20. package/dist/pattern.js +24 -6
  21. package/dist/pattern.js.map +1 -1
  22. package/dist/region.d.ts.map +1 -1
  23. package/dist/region.js +6 -5
  24. package/dist/region.js.map +1 -1
  25. package/dist/scaled-font.d.ts +3 -5
  26. package/dist/scaled-font.d.ts.map +1 -1
  27. package/dist/scaled-font.js +3 -62
  28. package/dist/scaled-font.js.map +1 -1
  29. package/dist/status.d.ts +6 -0
  30. package/dist/status.d.ts.map +1 -0
  31. package/dist/status.js +17 -0
  32. package/dist/status.js.map +1 -0
  33. package/dist/structs.d.ts +1 -1
  34. package/dist/structs.d.ts.map +1 -1
  35. package/dist/structs.js +1 -1
  36. package/dist/structs.js.map +1 -1
  37. package/dist/surface.d.ts +2 -7
  38. package/dist/surface.d.ts.map +1 -1
  39. package/dist/surface.js +21 -25
  40. package/dist/surface.js.map +1 -1
  41. package/dist/text.d.ts.map +1 -1
  42. package/dist/text.js +20 -17
  43. package/dist/text.js.map +1 -1
  44. package/package.json +60 -61
  45. package/src/context.ts +15 -16
  46. package/src/font-face.ts +3 -25
  47. package/src/lib.ts +2 -5
  48. package/src/path.ts +8 -5
  49. package/src/pattern.ts +31 -7
  50. package/src/region.ts +5 -5
  51. package/src/scaled-font.ts +3 -92
  52. package/src/status.ts +23 -0
  53. package/src/structs.ts +1 -1
  54. package/src/surface.ts +28 -29
  55. package/src/text.ts +20 -17
@@ -1 +1 @@
1
- {"version":3,"file":"scaled-font.js","sourceRoot":"","sources":["../src/scaled-font.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,EAET,IAAI,EACJ,oBAAoB,EACpB,SAAS,EACT,CAAC,EACD,UAAU,GACb,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACH,SAAS,EAET,UAAU,EACV,cAAc,EACd,WAAW,EACX,cAAc,EACd,OAAO,EACP,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,cAAc,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEnH,MAAM,gBAAgB,GAAG,UAAU,CAAC,oCAAoC,CAAC,CAAC;AAC1E,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,qBAAqB,GAAG,SAAS,CAAC,0BAA0B,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAC9F,MAAM,sBAAsB,GAAG,SAAS,CAAC,2BAA2B,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/G,MAAM,0BAA0B,GAAG,SAAS,CAAC,iCAAiC,EAAE,C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M,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;QAEvE,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC3B,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,WAAW,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC7B,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,KAAyB,CAAC,CAAC;IACzE,CAAC;CACJ;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import {\n type ExternalObject,\n getHandle,\n type Handle,\n read,\n registerWrapperClass,\n setHandle,\n t,\n wrapHandle,\n} from \"@gtkx/runtime\";\nimport type { FontType, Status, TextClusterFlags } from \"./enums.js\";\nimport type { CairoGlyph, CairoTextCluster, FontExtents, TextExtents } from \"./types.js\";\nimport { FontFace } from \"./font-face.js\";\nimport { FontOptions } from \"./font-options.js\";\nimport {\n bindCairo,\n type BoundFunction,\n cairoGType,\n FONT_EXTENTS_T,\n FONT_FACE_T,\n FONT_OPTIONS_T,\n GLYPH_T,\n MATRIX_T,\n SCALED_FONT_FULL_T,\n SCALED_FONT_T,\n TEXT_CLUSTER_T,\n TEXT_EXTENTS_T,\n} from \"./lib.js\";\nimport { allocMatrix, Matrix } from \"./matrix.js\";\nimport { allocFontExtents, allocGlyphBuffer, allocTextExtents, readFontExtents, readTextExtents } from \"./text.js\";\n\nconst SCALED_FONT_TYPE = cairoGType(\"cairo_gobject_scaled_font_get_type\");\nconst GLYPH_SIZE = 24;\nconst CLUSTER_SIZE = 8;\nconst cairoScaledFontStatus = bindCairo(\"cairo_scaled_font_status\", [SCALED_FONT_T], t.int32);\nconst cairoScaledFontExtents = bindCairo(\"cairo_scaled_font_extents\", [SCALED_FONT_T, FONT_EXTENTS_T], t.void);\nconst cairoScaledFontGetFontFace = bindCairo(\"cairo_scaled_font_get_font_face\", [SCALED_FONT_T], FONT_FACE_T);\nconst cairoScaledFontGetFontMatrix = bindCairo(\"cairo_scaled_font_get_font_matrix\", [SCALED_FONT_T, MATRIX_T], t.void);\nconst cairoScaledFontGetCtm = bindCairo(\"cairo_scaled_font_get_ctm\", [SCALED_FONT_T, MATRIX_T], t.void);\nconst cairoScaledFontGetType = bindCairo(\"cairo_scaled_font_get_type\", [SCALED_FONT_T], t.int32);\nconst cairoGlyphFree = bindCairo(\"cairo_glyph_free\", [GLYPH_T], t.void);\nconst cairoTextClusterFree = bindCairo(\"cairo_text_cluster_free\", [TEXT_CLUSTER_T], t.void);\n\nconst cairoScaledFontCreate = bindCairo(\n \"cairo_scaled_font_create\",\n [FONT_FACE_T, MATRIX_T, MATRIX_T, FONT_OPTIONS_T],\n SCALED_FONT_FULL_T,\n);\n\nconst cairoScaledFontTextExtents = bindCairo(\n \"cairo_scaled_font_text_extents\",\n [SCALED_FONT_T, t.string(\"full\"), TEXT_EXTENTS_T],\n t.void,\n);\n\nconst cairoScaledFontGlyphExtents = bindCairo(\n \"cairo_scaled_font_glyph_extents\",\n [SCALED_FONT_T, GLYPH_T, t.int32, TEXT_EXTENTS_T],\n t.void,\n);\n\nconst cairoScaledFontGetFontOptions = bindCairo(\n \"cairo_scaled_font_get_font_options\",\n [SCALED_FONT_T, FONT_OPTIONS_T],\n t.void,\n);\n\nconst cairoScaledFontGetScaleMatrix = bindCairo(\n \"cairo_scaled_font_get_scale_matrix\",\n [SCALED_FONT_T, MATRIX_T],\n t.void,\n);\n\nconst cairoScaledFontGetReferenceCount = bindCairo(\n \"cairo_scaled_font_get_reference_count\",\n [SCALED_FONT_T],\n t.int32,\n);\n\nconst cairoScaledFontTextToGlyphs = bindCairo(\n \"cairo_scaled_font_text_to_glyphs\",\n [\n SCALED_FONT_T,\n t.float64,\n t.float64,\n t.string(\"full\"),\n t.int32,\n t.ref(t.struct(\"borrowed\")),\n t.ref(t.int32),\n t.ref(t.struct(\"borrowed\")),\n t.ref(t.int32),\n t.ref(t.int32),\n ],\n t.int32,\n);\n\nconst readMatrixVia = (self: ScaledFont, boundFn: BoundFunction): Matrix => {\n const { handle, matrix } = allocMatrix();\n boundFn(getHandle(self), handle);\n\n return matrix;\n};\n\nconst readGlyphs = (buffer: ExternalObject<Handle> | null, count: number): CairoGlyph[] => {\n if (buffer === null) {\n return [];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const offset = index * GLYPH_SIZE;\n\n return {\n index: read(buffer, t.uint64, offset) as number,\n x: read(buffer, t.float64, offset + 8) as number,\n y: read(buffer, t.float64, offset + 16) as number,\n };\n });\n};\n\nconst readClusters = (buffer: ExternalObject<Handle> | null, count: number): CairoTextCluster[] => {\n if (buffer === null) {\n return [];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const offset = index * CLUSTER_SIZE;\n\n return {\n numBytes: read(buffer, t.int32, offset) as number,\n numGlyphs: read(buffer, t.int32, offset + 4) as number,\n };\n });\n};\n\n/**\n * A cairo scaled font (`cairo_scaled_font_t`): a font face frozen at a given font matrix, transformation and\n * set of font options, ready to measure and shape text.\n */\nclass ScaledFont {\n static {\n registerWrapperClass(this, SCALED_FONT_TYPE);\n }\n\n /** Creates a scaled font, the same as `new ScaledFont(fontFace, fontMatrix, ctm, options)`. */\n static create(fontFace: FontFace, fontMatrix: Matrix, ctm: Matrix, options: FontOptions): ScaledFont {\n return new ScaledFont(fontFace, fontMatrix, ctm, options);\n }\n\n /** GType of `CairoScaledFont`, the boxed type this class is registered under. */\n declare __type__: bigint;\n\n /** Creates a scaled font from a font face, a font matrix, a user-to-device transformation and font options. */\n constructor(fontFace: FontFace, fontMatrix: Matrix, ctm: Matrix, options: FontOptions) {\n const handle = cairoScaledFontCreate(\n getHandle(fontFace),\n getHandle(fontMatrix),\n getHandle(ctm),\n getHandle(options),\n ) as ExternalObject<Handle>;\n\n setHandle(this, handle);\n }\n\n /** Returns the error status of the scaled font, `Status.SUCCESS` when it is usable. */\n status(): Status {\n return cairoScaledFontStatus(getHandle(this)) as Status;\n }\n\n /** Returns the metrics of the font. */\n extents(): FontExtents {\n const ext = allocFontExtents();\n cairoScaledFontExtents(getHandle(this), ext);\n\n return readFontExtents(ext);\n }\n\n /** Measures `text` with the font. */\n textExtents(text: string): TextExtents {\n const ext = allocTextExtents();\n cairoScaledFontTextExtents(getHandle(this), text, ext);\n\n return readTextExtents(ext);\n }\n\n /** Measures positioned glyphs with the font. */\n glyphExtents(glyphs: CairoGlyph[]): TextExtents {\n const buf = allocGlyphBuffer(glyphs);\n const ext = allocTextExtents();\n cairoScaledFontGlyphExtents(getHandle(this), buf, glyphs.length, ext);\n\n return readTextExtents(ext);\n }\n\n /** Returns the font face the scaled font was created from, wrapped as its concrete class. */\n getFontFace(): FontFace {\n return wrapHandle(cairoScaledFontGetFontFace(getHandle(this)) as ExternalObject<Handle>, FontFace);\n }\n\n /** Returns a copy of the font options the scaled font was created with. */\n getFontOptions(): FontOptions {\n const options = FontOptions.create();\n cairoScaledFontGetFontOptions(getHandle(this), getHandle(options));\n\n return options;\n }\n\n /** Returns the font matrix the scaled font was created with. */\n getFontMatrix(): Matrix {\n return readMatrixVia(this, cairoScaledFontGetFontMatrix);\n }\n\n /** Returns the user-to-device transformation the scaled font was created with. */\n getCtm(): Matrix {\n return readMatrixVia(this, cairoScaledFontGetCtm);\n }\n\n /** Returns the scale matrix: the font matrix multiplied by the transformation, without translation. */\n getScaleMatrix(): Matrix {\n return readMatrixVia(this, cairoScaledFontGetScaleMatrix);\n }\n\n /** Returns the backend the scaled font belongs to. */\n getType(): FontType {\n return cairoScaledFontGetType(getHandle(this)) as FontType;\n }\n\n /** Returns the reference count of the scaled font. */\n getReferenceCount(): number {\n return cairoScaledFontGetReferenceCount(getHandle(this)) as number;\n }\n\n /** Shapes `text` starting at `(x, y)` into glyphs, clusters and the flags describing their order. */\n textToGlyphs(x: number, y: number, text: string): [CairoGlyph[], CairoTextCluster[], TextClusterFlags] {\n const glyphsRef: { value: ExternalObject<Handle> | null } = { value: null };\n const numGlyphsRef = { value: 0 };\n const clustersRef: { value: ExternalObject<Handle> | null } = { value: null };\n const numClustersRef = { value: 0 };\n const clusterFlagsRef = { value: 0 };\n\n cairoScaledFontTextToGlyphs(\n getHandle(this),\n x,\n y,\n text,\n -1,\n glyphsRef,\n numGlyphsRef,\n clustersRef,\n numClustersRef,\n clusterFlagsRef,\n );\n\n const glyphs = readGlyphs(glyphsRef.value, numGlyphsRef.value);\n const clusters = readClusters(clustersRef.value, numClustersRef.value);\n\n if (glyphsRef.value !== null) {\n cairoGlyphFree(glyphsRef.value);\n }\n\n if (clustersRef.value !== null) {\n cairoTextClusterFree(clustersRef.value);\n }\n\n return [glyphs, clusters, clusterFlagsRef.value as TextClusterFlags];\n }\n}\n\nexport { ScaledFont };\n"]}
1
+ {"version":3,"file":"scaled-font.js","sourceRoot":"","sources":["../src/scaled-font.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,EAET,oBAAoB,EACpB,SAAS,EACT,CAAC,EACD,UAAU,GACb,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACH,SAAS,EAET,UAAU,EACV,cAAc,EACd,WAAW,EACX,cAAc,EACd,OAAO,EACP,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,cAAc,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEnH,MAAM,gBAAgB,GAAG,UAAU,CAAC,oCAAoC,CAAC,CAAC;AAC1E,MAAM,qBAAqB,GAAG,SAAS,CAAC,0BAA0B,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IACtD,OAAO;QACH,OAAO,sBAAsB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAa,CAAC;IAC/D,CAAC;IAED,sDAAsD;IACtD,iBAAiB;QACb,OAAO,gCAAgC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAW,CAAC;IACvE,CAAC;CACJ;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import {\n type ExternalObject,\n getHandle,\n type Handle,\n registerWrapperClass,\n setHandle,\n t,\n wrapHandle,\n} from \"@gtkx/runtime\";\nimport type { FontType, Status } from \"./enums.js\";\nimport type { CairoGlyph, FontExtents, TextExtents } from \"./types.js\";\nimport { FontFace } from \"./font-face.js\";\nimport { FontOptions } from \"./font-options.js\";\nimport {\n bindCairo,\n type BoundFunction,\n cairoGType,\n FONT_EXTENTS_T,\n FONT_FACE_T,\n FONT_OPTIONS_T,\n GLYPH_T,\n MATRIX_T,\n SCALED_FONT_FULL_T,\n SCALED_FONT_T,\n TEXT_EXTENTS_T,\n} from \"./lib.js\";\nimport { allocMatrix, Matrix } from \"./matrix.js\";\nimport { allocFontExtents, allocGlyphBuffer, allocTextExtents, readFontExtents, readTextExtents } from \"./text.js\";\n\nconst SCALED_FONT_TYPE = cairoGType(\"cairo_gobject_scaled_font_get_type\");\nconst cairoScaledFontStatus = bindCairo(\"cairo_scaled_font_status\", [SCALED_FONT_T], t.int32);\nconst cairoScaledFontExtents = bindCairo(\"cairo_scaled_font_extents\", [SCALED_FONT_T, FONT_EXTENTS_T], t.void);\nconst cairoScaledFontGetFontFace = bindCairo(\"cairo_scaled_font_get_font_face\", [SCALED_FONT_T], FONT_FACE_T);\nconst cairoScaledFontGetFontMatrix = bindCairo(\"cairo_scaled_font_get_font_matrix\", [SCALED_FONT_T, MATRIX_T], t.void);\nconst cairoScaledFontGetCtm = bindCairo(\"cairo_scaled_font_get_ctm\", [SCALED_FONT_T, MATRIX_T], t.void);\nconst cairoScaledFontGetType = bindCairo(\"cairo_scaled_font_get_type\", [SCALED_FONT_T], t.int32);\n\nconst cairoScaledFontCreate = bindCairo(\n \"cairo_scaled_font_create\",\n [FONT_FACE_T, MATRIX_T, MATRIX_T, FONT_OPTIONS_T],\n SCALED_FONT_FULL_T,\n);\n\nconst cairoScaledFontTextExtents = bindCairo(\n \"cairo_scaled_font_text_extents\",\n [SCALED_FONT_T, t.string(\"full\"), TEXT_EXTENTS_T],\n t.void,\n);\n\nconst cairoScaledFontGlyphExtents = bindCairo(\n \"cairo_scaled_font_glyph_extents\",\n [SCALED_FONT_T, GLYPH_T, t.int32, TEXT_EXTENTS_T],\n t.void,\n);\n\nconst cairoScaledFontGetFontOptions = bindCairo(\n \"cairo_scaled_font_get_font_options\",\n [SCALED_FONT_T, FONT_OPTIONS_T],\n t.void,\n);\n\nconst cairoScaledFontGetScaleMatrix = bindCairo(\n \"cairo_scaled_font_get_scale_matrix\",\n [SCALED_FONT_T, MATRIX_T],\n t.void,\n);\n\nconst cairoScaledFontGetReferenceCount = bindCairo(\n \"cairo_scaled_font_get_reference_count\",\n [SCALED_FONT_T],\n t.int32,\n);\n\nconst readMatrixVia = (self: ScaledFont, boundFn: BoundFunction): Matrix => {\n const { handle, matrix } = allocMatrix();\n boundFn(getHandle(self), handle);\n\n return matrix;\n};\n\n/**\n * A cairo scaled font (`cairo_scaled_font_t`): a font face frozen at a given font matrix, transformation and\n * set of font options, ready to measure text and positioned glyphs.\n */\nclass ScaledFont {\n static {\n registerWrapperClass(this, SCALED_FONT_TYPE);\n }\n\n /** Creates a scaled font, the same as `new ScaledFont(fontFace, fontMatrix, ctm, options)`. */\n static create(fontFace: FontFace, fontMatrix: Matrix, ctm: Matrix, options: FontOptions): ScaledFont {\n return new ScaledFont(fontFace, fontMatrix, ctm, options);\n }\n\n /** GType of `CairoScaledFont`, the boxed type this class is registered under. */\n declare __type__: bigint;\n\n /** Creates a scaled font from a font face, a font matrix, a user-to-device transformation and font options. */\n constructor(fontFace: FontFace, fontMatrix: Matrix, ctm: Matrix, options: FontOptions) {\n const handle = cairoScaledFontCreate(\n getHandle(fontFace),\n getHandle(fontMatrix),\n getHandle(ctm),\n getHandle(options),\n ) as ExternalObject<Handle>;\n\n setHandle(this, handle);\n }\n\n /** Returns the error status of the scaled font, `Status.SUCCESS` when it is usable. */\n status(): Status {\n return cairoScaledFontStatus(getHandle(this)) as Status;\n }\n\n /** Returns the metrics of the font. */\n extents(): FontExtents {\n const ext = allocFontExtents();\n cairoScaledFontExtents(getHandle(this), ext);\n\n return readFontExtents(ext);\n }\n\n /** Measures `text` with the font. */\n textExtents(text: string): TextExtents {\n const ext = allocTextExtents();\n cairoScaledFontTextExtents(getHandle(this), text, ext);\n\n return readTextExtents(ext);\n }\n\n /** Measures positioned glyphs with the font. */\n glyphExtents(glyphs: CairoGlyph[]): TextExtents {\n const buf = allocGlyphBuffer(glyphs);\n const ext = allocTextExtents();\n cairoScaledFontGlyphExtents(getHandle(this), buf, glyphs.length, ext);\n\n return readTextExtents(ext);\n }\n\n /** Returns the font face the scaled font was created from, wrapped as its concrete class. */\n getFontFace(): FontFace {\n return wrapHandle(cairoScaledFontGetFontFace(getHandle(this)) as ExternalObject<Handle>, FontFace);\n }\n\n /** Returns a copy of the font options the scaled font was created with. */\n getFontOptions(): FontOptions {\n const options = FontOptions.create();\n cairoScaledFontGetFontOptions(getHandle(this), getHandle(options));\n\n return options;\n }\n\n /** Returns the font matrix the scaled font was created with. */\n getFontMatrix(): Matrix {\n return readMatrixVia(this, cairoScaledFontGetFontMatrix);\n }\n\n /** Returns the user-to-device transformation the scaled font was created with. */\n getCtm(): Matrix {\n return readMatrixVia(this, cairoScaledFontGetCtm);\n }\n\n /** Returns the scale matrix: the font matrix multiplied by the transformation, without translation. */\n getScaleMatrix(): Matrix {\n return readMatrixVia(this, cairoScaledFontGetScaleMatrix);\n }\n\n /** Returns the backend the scaled font belongs to. */\n getType(): FontType {\n return cairoScaledFontGetType(getHandle(this)) as FontType;\n }\n\n /** Returns the reference count of the scaled font. */\n getReferenceCount(): number {\n return cairoScaledFontGetReferenceCount(getHandle(this)) as number;\n }\n}\n\nexport { ScaledFont };\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ExternalObject, Handle } from "@gtkx/runtime";
2
+ import { Status } from "./enums.js";
3
+ declare const checkStatus: (status: Status, subject: string) => void;
4
+ declare const checkSurface: (handle: ExternalObject<Handle>) => ExternalObject<Handle>;
5
+ export { checkStatus, checkSurface };
6
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAMpC,QAAA,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,IAMtD,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,QAAQ,cAAc,CAAC,MAAM,CAAC,KAAG,cAAc,CAAC,MAAM,CAI3E,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
package/dist/status.js ADDED
@@ -0,0 +1,17 @@
1
+ import { t } from "@gtkx/runtime";
2
+ import { Status } from "./enums.js";
3
+ import { bindCairo, SURFACE_T } from "./lib.js";
4
+ import { statusToString } from "./version.js";
5
+ const cairoSurfaceStatus = bindCairo("cairo_surface_status", [SURFACE_T], t.int32);
6
+ const checkStatus = (status, subject) => {
7
+ if (status === Status.SUCCESS) {
8
+ return;
9
+ }
10
+ throw new Error(`cairo error on ${subject}: "${statusToString(status)}" (${String(status)})`);
11
+ };
12
+ const checkSurface = (handle) => {
13
+ checkStatus(cairoSurfaceStatus(handle), "surface");
14
+ return handle;
15
+ };
16
+ export { checkStatus, checkSurface };
17
+ //# sourceMappingURL=status.js.map
@@ -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/structs.d.ts CHANGED
@@ -59,7 +59,7 @@ declare class Rectangle {
59
59
  /** Height of the rectangle. */
60
60
  set height(value: number);
61
61
  }
62
- /** A rectangle with integer edges, as regions and `Surface.mapToImage` use. */
62
+ /** A rectangle with integer edges, as Cairo regions use. */
63
63
  declare class RectangleInt {
64
64
  /** GType of `CairoRectangleInt`, the boxed type this struct is registered under. */
65
65
  __type__: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAgBA,0FAA0F;AAC1F,KAAK,yBAAyB,GAAG;IAC7B,4CAA4C;IAC5C,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,yCAAyC;IACzC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,6FAA6F;AAC7F,KAAK,4BAA4B,GAAG;IAChC,4CAA4C;IAC5C,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,yCAAyC;IACzC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,sFAAsF;AACtF,KAAK,qBAAqB,GAAG;IACzB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+CAA+C;IAC/C,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,6CAA6C;IAC7C,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;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,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAElB;IAED,6CAA6C;IAC7C,IAAI,CAAC,IAAI,MAAM,CAEd;IAED,6CAA6C;IAC7C,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAElB;CACJ;AAED,+EAA+E;AAC/E,cAAM,WAAW;IAKb,mFAAmF;IAC3E,QAAQ,EAAE,MAAM,CAAC;IAEzB,oFAAoF;gBACxE,KAAK,GAAE,2BAAgC;IAOnD,gDAAgD;IAChD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,gDAAgD;IAChD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAEzB;IAED,2CAA2C;IAC3C,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,2CAA2C;IAC3C,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,EAE1B;CACJ;AAED,OAAO,EACH,KAAK,EACL,KAAK,qBAAqB,EAC1B,SAAS,EACT,KAAK,yBAAyB,EAC9B,YAAY,EACZ,KAAK,4BAA4B,EACjC,WAAW,EACX,KAAK,2BAA2B,GACnC,CAAC"}
package/dist/structs.js CHANGED
@@ -67,7 +67,7 @@ class Rectangle {
67
67
  writeField(this, DOUBLE, 24, value);
68
68
  }
69
69
  }
70
- /** A rectangle with integer edges, as regions and `Surface.mapToImage` use. */
70
+ /** A rectangle with integer edges, as Cairo regions use. */
71
71
  class RectangleInt {
72
72
  static {
73
73
  registerWrapperClass(this, RECTANGLE_INT_TYPE);
@@ -1 +1 @@
1
- {"version":3,"file":"structs.js","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAEL,SAAS,EAET,IAAI,EACJ,oBAAoB,EACpB,WAAW,EACX,SAAS,EACT,CAAC,EACD,QAAQ,EACR,KAAK,GACR,MAAM,eAAe,CAAC;AA8CvB,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AACtD,MAAM,cAAc,GAAG,WAAW,CAAC,qBAAqB,EAAE,kCAAkC,CA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ACtB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,2CAA2C;IAC3C,IAAI,SAAS;QACT,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,2CAA2C;IAC3C,IAAI,SAAS,CAAC,KAAa;QACvB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACJ;AAED,OAAO,EACH,KAAK,EAEL,SAAS,EAET,YAAY,EAEZ,WAAW,GAEd,CAAC","sourcesContent":["import {\n alloc,\n type ExternalObject,\n getHandle,\n type Handle,\n read,\n registerWrapperClass,\n resolveType,\n setHandle,\n t,\n toNative,\n write,\n} from \"@gtkx/runtime\";\n\ntype FieldDescriptor = typeof t.float64 | typeof t.int32 | typeof t.biguint64;\n\n/** Initial field values for a `Rectangle`; a field left out or set to null keeps zero. */\ntype RectangleConstructorProps = {\n /** Horizontal position of the left edge. */\n x?: number | null;\n /** Vertical position of the top edge. */\n y?: number | null;\n /** Width of the rectangle. */\n width?: number | null;\n /** Height of the rectangle. */\n height?: number | null;\n};\n\n/** Initial field values for a `RectangleInt`; a field left out or set to null keeps zero. */\ntype RectangleIntConstructorProps = {\n /** Horizontal position of the left edge. */\n x?: number | null;\n /** Vertical position of the top edge. */\n y?: number | null;\n /** Width of the rectangle. */\n width?: number | null;\n /** Height of the rectangle. */\n height?: number | null;\n};\n\n/** Initial field values for a `Glyph`; a field left out or set to null keeps zero. */\ntype GlyphConstructorProps = {\n /** Index of the glyph in the font. */\n index?: bigint | null;\n /** Horizontal position of the glyph origin. */\n x?: number | null;\n /** Vertical position of the glyph origin. */\n y?: number | null;\n};\n\n/** Initial field values for a `TextCluster`; a field left out or set to null keeps zero. */\ntype TextClusterConstructorProps = {\n /** Number of UTF-8 bytes the cluster covers. */\n numBytes?: number | null;\n /** Number of glyphs the cluster covers. */\n numGlyphs?: number | null;\n};\n\nconst CAIRO_GOBJECT_LIBRARY = \"libcairo-gobject.so.2\";\nconst RECTANGLE_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_rectangle_get_type\");\nconst RECTANGLE_INT_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_rectangle_int_get_type\");\nconst GLYPH_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_glyph_get_type\");\nconst TEXT_CLUSTER_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_text_cluster_get_type\");\nconst RECTANGLE_SIZE = 32;\nconst RECTANGLE_INT_SIZE = 16;\nconst GLYPH_SIZE = 24;\nconst TEXT_CLUSTER_SIZE = 8;\nconst DOUBLE = t.float64;\nconst INT = t.int32;\nconst ULONG = t.biguint64;\n\nconst readField = (instance: object, descriptor: FieldDescriptor, offset: number): number =>\n read(getHandle(instance), descriptor, offset) as number;\n\nconst writeField = (instance: object, descriptor: FieldDescriptor, offset: number, value: unknown): void => {\n write(getHandle(instance), descriptor, offset, toNative(descriptor, value));\n};\n\nconst writeInitial = (\n handle: ExternalObject<Handle>,\n descriptor: FieldDescriptor,\n offset: number,\n value: unknown,\n): void => {\n if (value != null) {\n write(handle, descriptor, offset, toNative(descriptor, value));\n }\n};\n\n/** A rectangle with double-precision edges, as `copyClipRectangleList` and recording surfaces report. */\nclass Rectangle {\n static {\n registerWrapperClass(this, RECTANGLE_TYPE);\n }\n\n /** GType of `CairoRectangle`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a rectangle, writing the given fields and leaving the others at zero. */\n constructor(props: RectangleConstructorProps = {}) {\n const handle = alloc(RECTANGLE_SIZE, RECTANGLE_TYPE);\n writeInitial(handle, DOUBLE, 0, props.x);\n writeInitial(handle, DOUBLE, 8, props.y);\n writeInitial(handle, DOUBLE, 16, props.width);\n writeInitial(handle, DOUBLE, 24, props.height);\n setHandle(this, handle);\n }\n\n /** Horizontal position of the left edge. */\n get x(): number {\n return readField(this, DOUBLE, 0);\n }\n\n /** Horizontal position of the left edge. */\n set x(value: number) {\n writeField(this, DOUBLE, 0, value);\n }\n\n /** Vertical position of the top edge. */\n get y(): number {\n return readField(this, DOUBLE, 8);\n }\n\n /** Vertical position of the top edge. */\n set y(value: number) {\n writeField(this, DOUBLE, 8, value);\n }\n\n /** Width of the rectangle. */\n get width(): number {\n return readField(this, DOUBLE, 16);\n }\n\n /** Width of the rectangle. */\n set width(value: number) {\n writeField(this, DOUBLE, 16, value);\n }\n\n /** Height of the rectangle. */\n get height(): number {\n return readField(this, DOUBLE, 24);\n }\n\n /** Height of the rectangle. */\n set height(value: number) {\n writeField(this, DOUBLE, 24, value);\n }\n}\n\n/** A rectangle with integer edges, as regions and `Surface.mapToImage` use. */\nclass RectangleInt {\n static {\n registerWrapperClass(this, RECTANGLE_INT_TYPE);\n }\n\n /** GType of `CairoRectangleInt`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a rectangle, writing the given fields and leaving the others at zero. */\n constructor(props: RectangleIntConstructorProps = {}) {\n const handle = alloc(RECTANGLE_INT_SIZE, RECTANGLE_INT_TYPE);\n writeInitial(handle, INT, 0, props.x);\n writeInitial(handle, INT, 4, props.y);\n writeInitial(handle, INT, 8, props.width);\n writeInitial(handle, INT, 12, props.height);\n setHandle(this, handle);\n }\n\n /** Horizontal position of the left edge. */\n get x(): number {\n return readField(this, INT, 0);\n }\n\n /** Horizontal position of the left edge. */\n set x(value: number) {\n writeField(this, INT, 0, value);\n }\n\n /** Vertical position of the top edge. */\n get y(): number {\n return readField(this, INT, 4);\n }\n\n /** Vertical position of the top edge. */\n set y(value: number) {\n writeField(this, INT, 4, value);\n }\n\n /** Width of the rectangle. */\n get width(): number {\n return readField(this, INT, 8);\n }\n\n /** Width of the rectangle. */\n set width(value: number) {\n writeField(this, INT, 8, value);\n }\n\n /** Height of the rectangle. */\n get height(): number {\n return readField(this, INT, 12);\n }\n\n /** Height of the rectangle. */\n set height(value: number) {\n writeField(this, INT, 12, value);\n }\n}\n\n/** A `cairo_glyph_t`: one glyph index and where to draw it. */\nclass Glyph {\n static {\n registerWrapperClass(this, GLYPH_TYPE);\n }\n\n /** GType of `CairoGlyph`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a glyph, writing the given fields and leaving the others at zero. */\n constructor(props: GlyphConstructorProps = {}) {\n const handle = alloc(GLYPH_SIZE, GLYPH_TYPE);\n writeInitial(handle, ULONG, 0, props.index);\n writeInitial(handle, DOUBLE, 8, props.x);\n writeInitial(handle, DOUBLE, 16, props.y);\n setHandle(this, handle);\n }\n\n /** Index of the glyph in the font. */\n get index(): bigint {\n return read(getHandle(this), ULONG, 0) as bigint;\n }\n\n /** Index of the glyph in the font. */\n set index(value: bigint) {\n writeField(this, ULONG, 0, value);\n }\n\n /** Horizontal position of the glyph origin. */\n get x(): number {\n return readField(this, DOUBLE, 8);\n }\n\n /** Horizontal position of the glyph origin. */\n set x(value: number) {\n writeField(this, DOUBLE, 8, value);\n }\n\n /** Vertical position of the glyph origin. */\n get y(): number {\n return readField(this, DOUBLE, 16);\n }\n\n /** Vertical position of the glyph origin. */\n set y(value: number) {\n writeField(this, DOUBLE, 16, value);\n }\n}\n\n/** A `cairo_text_cluster_t`: how many bytes of text map to how many glyphs. */\nclass TextCluster {\n static {\n registerWrapperClass(this, TEXT_CLUSTER_TYPE);\n }\n\n /** GType of `CairoTextCluster`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a cluster, writing the given fields and leaving the others at zero. */\n constructor(props: TextClusterConstructorProps = {}) {\n const handle = alloc(TEXT_CLUSTER_SIZE, TEXT_CLUSTER_TYPE);\n writeInitial(handle, INT, 0, props.numBytes);\n writeInitial(handle, INT, 4, props.numGlyphs);\n setHandle(this, handle);\n }\n\n /** Number of UTF-8 bytes the cluster covers. */\n get numBytes(): number {\n return readField(this, INT, 0);\n }\n\n /** Number of UTF-8 bytes the cluster covers. */\n set numBytes(value: number) {\n writeField(this, INT, 0, value);\n }\n\n /** Number of glyphs the cluster covers. */\n get numGlyphs(): number {\n return readField(this, INT, 4);\n }\n\n /** Number of glyphs the cluster covers. */\n set numGlyphs(value: number) {\n writeField(this, INT, 4, value);\n }\n}\n\nexport {\n Glyph,\n type GlyphConstructorProps,\n Rectangle,\n type RectangleConstructorProps,\n RectangleInt,\n type RectangleIntConstructorProps,\n TextCluster,\n type TextClusterConstructorProps,\n};\n"]}
1
+ {"version":3,"file":"structs.js","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAEL,SAAS,EAET,IAAI,EACJ,oBAAoB,EACpB,WAAW,EACX,SAAS,EACT,CAAC,EACD,QAAQ,EACR,KAAK,GACR,MAAM,eAAe,CAAC;AA8CvB,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AACtD,MAAM,cAAc,GAAG,WAAW,CAAC,qBAAqB,EAAE,kCAAkC,CAAC,CAAC;AAC9F,MAAM,kBAAkB,GAAG,WAAW,CAAC,qBAAqB,EAAE,sCAAsC,CAAC,CAAC;AACtG,MAAM,UAAU,GAAG,WAAW,CAAC,qBAAqB,EAAE,8BAA8B,CAAC,CAAC;AACtF,MAAM,iBAAiB,GAAG,WAAW,CAAC,qBAAqB,EAAE,qCAAqC,CAAC,CAAC;AACpG,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC;AACzB,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC;AACpB,MAAM,KAAK,GAAG,CAAC,CAAC,SAAS,CAAC;AAE1B,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,UAA2B,EAAE,MAAc,EAAU,EAAE,CACxF,IAAI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ACxC,CAAC;CACJ;AAED,+EAA+E;AAC/E,MAAM,WAAW;IACb;QACI,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;IAKD,oFAAoF;IACpF,YAAY,QAAqC,EAAE;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC3D,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;QAC9C,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,gDAAgD;IAChD,IAAI,QAAQ;QACR,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,gDAAgD;IAChD,IAAI,QAAQ,CAAC,KAAa;QACtB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,2CAA2C;IAC3C,IAAI,SAAS;QACT,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,2CAA2C;IAC3C,IAAI,SAAS,CAAC,KAAa;QACvB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACJ;AAED,OAAO,EACH,KAAK,EAEL,SAAS,EAET,YAAY,EAEZ,WAAW,GAEd,CAAC","sourcesContent":["import {\n alloc,\n type ExternalObject,\n getHandle,\n type Handle,\n read,\n registerWrapperClass,\n resolveType,\n setHandle,\n t,\n toNative,\n write,\n} from \"@gtkx/runtime\";\n\ntype FieldDescriptor = typeof t.float64 | typeof t.int32 | typeof t.biguint64;\n\n/** Initial field values for a `Rectangle`; a field left out or set to null keeps zero. */\ntype RectangleConstructorProps = {\n /** Horizontal position of the left edge. */\n x?: number | null;\n /** Vertical position of the top edge. */\n y?: number | null;\n /** Width of the rectangle. */\n width?: number | null;\n /** Height of the rectangle. */\n height?: number | null;\n};\n\n/** Initial field values for a `RectangleInt`; a field left out or set to null keeps zero. */\ntype RectangleIntConstructorProps = {\n /** Horizontal position of the left edge. */\n x?: number | null;\n /** Vertical position of the top edge. */\n y?: number | null;\n /** Width of the rectangle. */\n width?: number | null;\n /** Height of the rectangle. */\n height?: number | null;\n};\n\n/** Initial field values for a `Glyph`; a field left out or set to null keeps zero. */\ntype GlyphConstructorProps = {\n /** Index of the glyph in the font. */\n index?: bigint | null;\n /** Horizontal position of the glyph origin. */\n x?: number | null;\n /** Vertical position of the glyph origin. */\n y?: number | null;\n};\n\n/** Initial field values for a `TextCluster`; a field left out or set to null keeps zero. */\ntype TextClusterConstructorProps = {\n /** Number of UTF-8 bytes the cluster covers. */\n numBytes?: number | null;\n /** Number of glyphs the cluster covers. */\n numGlyphs?: number | null;\n};\n\nconst CAIRO_GOBJECT_LIBRARY = \"libcairo-gobject.so.2\";\nconst RECTANGLE_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_rectangle_get_type\");\nconst RECTANGLE_INT_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_rectangle_int_get_type\");\nconst GLYPH_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_glyph_get_type\");\nconst TEXT_CLUSTER_TYPE = resolveType(CAIRO_GOBJECT_LIBRARY, \"cairo_gobject_text_cluster_get_type\");\nconst RECTANGLE_SIZE = 32;\nconst RECTANGLE_INT_SIZE = 16;\nconst GLYPH_SIZE = 24;\nconst TEXT_CLUSTER_SIZE = 8;\nconst DOUBLE = t.float64;\nconst INT = t.int32;\nconst ULONG = t.biguint64;\n\nconst readField = (instance: object, descriptor: FieldDescriptor, offset: number): number =>\n read(getHandle(instance), descriptor, offset) as number;\n\nconst writeField = (instance: object, descriptor: FieldDescriptor, offset: number, value: unknown): void => {\n write(getHandle(instance), descriptor, offset, toNative(descriptor, value));\n};\n\nconst writeInitial = (\n handle: ExternalObject<Handle>,\n descriptor: FieldDescriptor,\n offset: number,\n value: unknown,\n): void => {\n if (value != null) {\n write(handle, descriptor, offset, toNative(descriptor, value));\n }\n};\n\n/** A rectangle with double-precision edges, as `copyClipRectangleList` and recording surfaces report. */\nclass Rectangle {\n static {\n registerWrapperClass(this, RECTANGLE_TYPE);\n }\n\n /** GType of `CairoRectangle`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a rectangle, writing the given fields and leaving the others at zero. */\n constructor(props: RectangleConstructorProps = {}) {\n const handle = alloc(RECTANGLE_SIZE, RECTANGLE_TYPE);\n writeInitial(handle, DOUBLE, 0, props.x);\n writeInitial(handle, DOUBLE, 8, props.y);\n writeInitial(handle, DOUBLE, 16, props.width);\n writeInitial(handle, DOUBLE, 24, props.height);\n setHandle(this, handle);\n }\n\n /** Horizontal position of the left edge. */\n get x(): number {\n return readField(this, DOUBLE, 0);\n }\n\n /** Horizontal position of the left edge. */\n set x(value: number) {\n writeField(this, DOUBLE, 0, value);\n }\n\n /** Vertical position of the top edge. */\n get y(): number {\n return readField(this, DOUBLE, 8);\n }\n\n /** Vertical position of the top edge. */\n set y(value: number) {\n writeField(this, DOUBLE, 8, value);\n }\n\n /** Width of the rectangle. */\n get width(): number {\n return readField(this, DOUBLE, 16);\n }\n\n /** Width of the rectangle. */\n set width(value: number) {\n writeField(this, DOUBLE, 16, value);\n }\n\n /** Height of the rectangle. */\n get height(): number {\n return readField(this, DOUBLE, 24);\n }\n\n /** Height of the rectangle. */\n set height(value: number) {\n writeField(this, DOUBLE, 24, value);\n }\n}\n\n/** A rectangle with integer edges, as Cairo regions use. */\nclass RectangleInt {\n static {\n registerWrapperClass(this, RECTANGLE_INT_TYPE);\n }\n\n /** GType of `CairoRectangleInt`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a rectangle, writing the given fields and leaving the others at zero. */\n constructor(props: RectangleIntConstructorProps = {}) {\n const handle = alloc(RECTANGLE_INT_SIZE, RECTANGLE_INT_TYPE);\n writeInitial(handle, INT, 0, props.x);\n writeInitial(handle, INT, 4, props.y);\n writeInitial(handle, INT, 8, props.width);\n writeInitial(handle, INT, 12, props.height);\n setHandle(this, handle);\n }\n\n /** Horizontal position of the left edge. */\n get x(): number {\n return readField(this, INT, 0);\n }\n\n /** Horizontal position of the left edge. */\n set x(value: number) {\n writeField(this, INT, 0, value);\n }\n\n /** Vertical position of the top edge. */\n get y(): number {\n return readField(this, INT, 4);\n }\n\n /** Vertical position of the top edge. */\n set y(value: number) {\n writeField(this, INT, 4, value);\n }\n\n /** Width of the rectangle. */\n get width(): number {\n return readField(this, INT, 8);\n }\n\n /** Width of the rectangle. */\n set width(value: number) {\n writeField(this, INT, 8, value);\n }\n\n /** Height of the rectangle. */\n get height(): number {\n return readField(this, INT, 12);\n }\n\n /** Height of the rectangle. */\n set height(value: number) {\n writeField(this, INT, 12, value);\n }\n}\n\n/** A `cairo_glyph_t`: one glyph index and where to draw it. */\nclass Glyph {\n static {\n registerWrapperClass(this, GLYPH_TYPE);\n }\n\n /** GType of `CairoGlyph`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a glyph, writing the given fields and leaving the others at zero. */\n constructor(props: GlyphConstructorProps = {}) {\n const handle = alloc(GLYPH_SIZE, GLYPH_TYPE);\n writeInitial(handle, ULONG, 0, props.index);\n writeInitial(handle, DOUBLE, 8, props.x);\n writeInitial(handle, DOUBLE, 16, props.y);\n setHandle(this, handle);\n }\n\n /** Index of the glyph in the font. */\n get index(): bigint {\n return read(getHandle(this), ULONG, 0) as bigint;\n }\n\n /** Index of the glyph in the font. */\n set index(value: bigint) {\n writeField(this, ULONG, 0, value);\n }\n\n /** Horizontal position of the glyph origin. */\n get x(): number {\n return readField(this, DOUBLE, 8);\n }\n\n /** Horizontal position of the glyph origin. */\n set x(value: number) {\n writeField(this, DOUBLE, 8, value);\n }\n\n /** Vertical position of the glyph origin. */\n get y(): number {\n return readField(this, DOUBLE, 16);\n }\n\n /** Vertical position of the glyph origin. */\n set y(value: number) {\n writeField(this, DOUBLE, 16, value);\n }\n}\n\n/** A `cairo_text_cluster_t`: how many bytes of text map to how many glyphs. */\nclass TextCluster {\n static {\n registerWrapperClass(this, TEXT_CLUSTER_TYPE);\n }\n\n /** GType of `CairoTextCluster`, the boxed type this struct is registered under. */\n declare __type__: bigint;\n\n /** Allocates a cluster, writing the given fields and leaving the others at zero. */\n constructor(props: TextClusterConstructorProps = {}) {\n const handle = alloc(TEXT_CLUSTER_SIZE, TEXT_CLUSTER_TYPE);\n writeInitial(handle, INT, 0, props.numBytes);\n writeInitial(handle, INT, 4, props.numGlyphs);\n setHandle(this, handle);\n }\n\n /** Number of UTF-8 bytes the cluster covers. */\n get numBytes(): number {\n return readField(this, INT, 0);\n }\n\n /** Number of UTF-8 bytes the cluster covers. */\n set numBytes(value: number) {\n writeField(this, INT, 0, value);\n }\n\n /** Number of glyphs the cluster covers. */\n get numGlyphs(): number {\n return readField(this, INT, 4);\n }\n\n /** Number of glyphs the cluster covers. */\n set numGlyphs(value: number) {\n writeField(this, INT, 4, value);\n }\n}\n\nexport {\n Glyph,\n type GlyphConstructorProps,\n Rectangle,\n type RectangleConstructorProps,\n RectangleInt,\n type RectangleIntConstructorProps,\n TextCluster,\n type TextClusterConstructorProps,\n};\n"]}
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";
@@ -12,7 +11,7 @@ declare abstract class Surface {
12
11
  /** Creates a surface of the given `content` and size as compatible as possible with `other`. */
13
12
  static createSimilar(other: Surface, content: Content, width: number, height: number): Surface;
14
13
  /** 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;
14
+ static createSimilarImage(other: Surface, format: Format, width: number, height: number): ImageSurface;
16
15
  /** Creates a surface that draws onto the given rectangle of `target`. */
17
16
  static createForRectangle(target: Surface, x: number, y: number, width: number, height: number): Surface;
18
17
  /** GType of `CairoSurface`, the boxed type this class is registered under. */
@@ -59,16 +58,12 @@ 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 {
69
64
  /** Creates an image surface of the given pixel `format` and size, the same as `new ImageSurface(...)`. */
70
65
  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. */
66
+ /** Loads a PNG file into a new image surface; throws when the file is missing or invalid. */
72
67
  static createFromPng(filename: string): ImageSurface;
73
68
  /** Creates an image surface of the given pixel `format` and size. */
74
69
  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,aAAa,EAAE,MAAM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tkx/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
+ import { checkSurface } from "./status.js";
5
6
  const SURFACE_TYPE = cairoGType("cairo_gobject_surface_get_type");
6
7
  const RECTANGLE_SIZE = 32;
8
+ const DOUBLE = t.fieldAt(t.float64);
9
+ const UINT8 = t.fieldAt(t.uint8);
7
10
  const DEVICE_PAIR_ARGS = [SURFACE_T, t.float64, t.float64];
8
11
  const DEVICE_PAIR_OUT_ARGS = [SURFACE_T, t.ref(t.float64), t.ref(t.float64)];
9
12
  const SIMILAR_ARGS = [SURFACE_T, t.int32, t.int32, t.int32];
@@ -31,8 +34,6 @@ const cairoSurfaceCopyPage = bindCairo("cairo_surface_copy_page", [SURFACE_T], t
31
34
  const cairoSurfaceShowPage = bindCairo("cairo_surface_show_page", [SURFACE_T], t.void);
32
35
  const cairoSurfaceHasShowTextGlyphs = bindCairo("cairo_surface_has_show_text_glyphs", [SURFACE_T], t.boolean);
33
36
  const cairoSurfaceSupportsMimeType = bindCairo("cairo_surface_supports_mime_type", [SURFACE_T, t.string("full")], t.boolean);
34
- const cairoSurfaceMapToImage = bindCairo("cairo_surface_map_to_image", [SURFACE_T, RECTANGLE_INT_T], SURFACE_T);
35
- const cairoSurfaceUnmapImage = bindCairo("cairo_surface_unmap_image", [SURFACE_T, SURFACE_T], t.void);
36
37
  const cairoImageSurfaceCreate = bindCairo("cairo_image_surface_create", [t.int32, t.int32, t.int32], SURFACE_FULL_T);
37
38
  const cairoImageSurfaceCreateFromPng = bindCairo("cairo_image_surface_create_from_png", [t.string("full")], SURFACE_FULL_T);
38
39
  const cairoImageSurfaceGetWidth = bindCairo("cairo_image_surface_get_width", [SURFACE_T], t.int32);
@@ -59,10 +60,10 @@ const allocRectangle = (rect) => {
59
60
  return buffer;
60
61
  };
61
62
  const readRectangle = (buffer) => ({
62
- x: read(buffer, t.float64, 0),
63
- y: read(buffer, t.float64, 8),
64
- width: read(buffer, t.float64, 16),
65
- 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),
66
67
  });
67
68
  const createRecordingSurface = (content, extents) => (extents === undefined
68
69
  ? cairoRecordingSurfaceCreateUnbounded(content, 0)
@@ -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) {
@@ -188,29 +192,21 @@ class Surface {
188
192
  supportsMimeType(mimeType) {
189
193
  return cairoSurfaceSupportsMimeType(getHandle(this), mimeType);
190
194
  }
191
- /** Returns an image surface giving direct access to the pixels of `extents`; release it with `unmapImage`. */
192
- mapToImage(extents) {
193
- return wrapSurface(cairoSurfaceMapToImage(getHandle(this), getHandle(extents)));
194
- }
195
- /** Uploads the pixels of `image`, obtained from `mapToImage`, back to the surface and releases it. */
196
- unmapImage(image) {
197
- cairoSurfaceUnmapImage(getHandle(this), getHandle(image));
198
- }
199
195
  }
200
196
  /** A surface backed by an in-memory pixel buffer, the usual target for offscreen drawing. */
201
197
  class ImageSurface extends Surface {
202
198
  /** Creates an image surface of the given pixel `format` and size, the same as `new ImageSurface(...)`. */
203
199
  static create(format, width, height) {
204
- return wrapHandle(cairoImageSurfaceCreate(format, width, height), this);
200
+ return wrapHandle(checkSurface(cairoImageSurfaceCreate(format, width, height)), this);
205
201
  }
206
- /** Loads a PNG file into a new image surface; a missing or invalid file yields a surface in an error status. */
202
+ /** Loads a PNG file into a new image surface; throws when the file is missing or invalid. */
207
203
  static createFromPng(filename) {
208
- return wrapHandle(cairoImageSurfaceCreateFromPng(filename), this);
204
+ return wrapHandle(checkSurface(cairoImageSurfaceCreateFromPng(filename)), this);
209
205
  }
210
206
  /** Creates an image surface of the given pixel `format` and size. */
211
207
  constructor(format, width, height) {
212
208
  super();
213
- setHandle(this, cairoImageSurfaceCreate(format, width, height));
209
+ setHandle(this, checkSurface(cairoImageSurfaceCreate(format, width, height)));
214
210
  }
215
211
  /** Returns the width of the surface in pixels. */
216
212
  getWidth() {
@@ -240,7 +236,7 @@ class ImageSurface extends Surface {
240
236
  if (data === null) {
241
237
  return new Uint8Array(0);
242
238
  }
243
- return Uint8Array.from({ length: totalBytes }, (_, index) => read(data, t.uint8, index));
239
+ return Uint8Array.from({ length: totalBytes }, (_, index) => UINT8.read(data, index));
244
240
  }
245
241
  }
246
242
  /** A surface that records the drawing operations applied to it, for replaying them onto other surfaces. */
@@ -252,7 +248,7 @@ class RecordingSurface extends Surface {
252
248
  /** Creates a recording surface of the given `content`, bounded to `extents` or unbounded when omitted. */
253
249
  constructor(content, extents) {
254
250
  super();
255
- setHandle(this, createRecordingSurface(content, extents));
251
+ setHandle(this, checkSurface(createRecordingSurface(content, extents)));
256
252
  }
257
253
  /** Returns the area that has been drawn on so far. */
258
254
  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,WAAW,EACX,cAAc,EACd,SAAS,GACZ,MAAM,UAAU,CAAC;AAElB,MAAM,YAAY,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC;AAClE,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,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,KAAK,CAAC,CAAC;AAC5D,MAAM,yBAAyB,GAAG,SAAS,CAAC,8BAA8B,EAAE,YAAY,EAAE,cAAc,CAAC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B,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC5B,+BAA+B,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,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\";\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,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,KA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AC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,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 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,gB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C,KAAG,WAOxD,CAAC;AAEH,QAAA,MAAM,eAAe,GAAI,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