Skip to content

Commit 1ffc273

Browse files
authored
Merge pull request #506 from Shopify/decouple
Fix Skia type implementation
2 parents 36e2a4e + bbf0332 commit 1ffc273

File tree

4 files changed

+5
-41
lines changed

4 files changed

+5
-41
lines changed

example/src/Examples/API/Data.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ for (let x = 0; x < 256 * 4; x++) {
2020
}
2121
}
2222
const data = Skia.Data.fromBytes(pixels);
23-
const img = Skia.MakeImage(
23+
const img = Skia.Image.MakeImage(
2424
{
2525
width: 256,
2626
height: 256,

package/src/skia/Skia.ts

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*global SkiaApi*/
2-
import type { SkiaApi as SkSkiaApi } from "./types";
2+
import type { Skia as SkSkiaApi } from "./types";
33

44
/**
55
* Declares the SkiaApi as an available object in the global scope
@@ -8,39 +8,4 @@ declare global {
88
var SkiaApi: SkSkiaApi;
99
}
1010

11-
/**
12-
* Declares the implemented API with overrides.
13-
*/
14-
export const Skia = {
15-
// Factories
16-
Typeface: SkiaApi.Typeface,
17-
MaskFilter: SkiaApi.MaskFilter,
18-
RuntimeEffect: SkiaApi.RuntimeEffect,
19-
Shader: SkiaApi.Shader,
20-
ImageFilter: SkiaApi.ImageFilter,
21-
PathEffect: SkiaApi.PathEffect,
22-
Data: SkiaApi.Data,
23-
SVG: SkiaApi.SVG,
24-
FontMgr: SkiaApi.FontMgr,
25-
TextBlob: SkiaApi.TextBlob,
26-
// Constructors
27-
Matrix: SkiaApi.Matrix,
28-
Font: SkiaApi.Font,
29-
Point: SkiaApi.Point,
30-
XYWHRect: SkiaApi.XYWHRect,
31-
RRectXY: SkiaApi.RRectXY,
32-
RuntimeShaderBuilder: SkiaApi.RuntimeShaderBuilder,
33-
Paint: SkiaApi.Paint,
34-
PictureRecorder: SkiaApi.PictureRecorder,
35-
Picture: SkiaApi.Picture,
36-
Path: SkiaApi.Path,
37-
ColorFilter: SkiaApi.ColorFilter,
38-
ContourMeasureIter: SkiaApi.ContourMeasureIter,
39-
Color: SkiaApi.Color,
40-
RSXform: SkiaApi.RSXform,
41-
// For the following methods the factory symmetry is broken to be comptatible with CanvasKit
42-
MakeSurface: SkiaApi.Surface.Make,
43-
MakeImageFromEncoded: SkiaApi.Image.MakeImageFromEncoded,
44-
MakeImage: SkiaApi.Image.MakeImage,
45-
MakeVertices: SkiaApi.MakeVertices,
46-
};
11+
export const Skia = SkiaApi;

package/src/skia/core/Image.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ import { useRawData } from "./Data";
77
* Returns a Skia Image object
88
* */
99
export const useImage = (source: DataSource, onError?: (err: Error) => void) =>
10-
useRawData(source, Skia.MakeImageFromEncoded, onError);
10+
useRawData(source, Skia.Image.MakeImageFromEncoded, onError);

package/src/skia/types/Skia.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ import type {
3232
/**
3333
* Declares the interface for the native Skia API
3434
*/
35-
export interface SkiaApi {
35+
export interface Skia {
3636
Point: (x: number, y: number) => SkPoint;
3737
XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;
3838
RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;
3939
RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;
4040
RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;
4141
Color: (color: Color) => SkColor;
42-
parseColorString: (color: string) => SkColor | undefined;
4342
ContourMeasureIter: (
4443
path: SkPath,
4544
forceClosed: boolean,

0 commit comments

Comments
 (0)