-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor refactoring in the e2e infra (#2123)
- Loading branch information
1 parent
9326caf
commit b92f764
Showing
9 changed files
with
131 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type { SkParagraph, Skia, SkCanvas } from "../../../../skia/types"; | ||
import type { EvalContext } from "../../setup"; | ||
|
||
import { SkiaObject } from "./SkiaObject"; | ||
|
||
export class ParagraphAsset<Ctx extends EvalContext> | ||
extends SkiaObject<Ctx, SkParagraph> | ||
implements SkParagraph | ||
{ | ||
constructor( | ||
Skia: Skia, | ||
fn: (Skia: Skia, ctx: Ctx) => SkParagraph, | ||
context: Ctx = {} as Ctx | ||
) { | ||
super(Skia, fn, context); | ||
} | ||
|
||
layout(width: number) { | ||
this.instance.layout(width); | ||
} | ||
paint(canvas: SkCanvas, x: number, y: number) { | ||
this.instance.paint(canvas, x, y); | ||
} | ||
getHeight() { | ||
return this.instance.getHeight(); | ||
} | ||
getMaxWidth() { | ||
return this.instance.getMaxWidth(); | ||
} | ||
getMinIntrinsicWidth() { | ||
return this.instance.getMinIntrinsicWidth(); | ||
} | ||
getMaxIntrinsicWidth() { | ||
return this.instance.getMaxIntrinsicWidth(); | ||
} | ||
getLongestLine() { | ||
return this.instance.getLongestLine(); | ||
} | ||
getGlyphPositionAtCoordinate(x: number, y: number) { | ||
return this.instance.getGlyphPositionAtCoordinate(x, y); | ||
} | ||
getRectsForRange(start: number, end: number) { | ||
return this.instance.getRectsForRange(start, end); | ||
} | ||
getLineMetrics() { | ||
return this.instance.getLineMetrics(); | ||
} | ||
getRectsForPlaceholders() { | ||
return this.instance.getRectsForPlaceholders(); | ||
} | ||
__typename__ = "Paragraph" as const; | ||
|
||
dispose(): void { | ||
this.instance.dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Because SkSVG doesn't exist on web, | ||
|
||
import type { SkSVG } from "../../../../skia/types"; | ||
|
||
// this instance is just to send the svg over the wire | ||
export class SVGAsset implements SkSVG { | ||
__typename__ = "SVG" as const; | ||
constructor( | ||
private _source: string, | ||
private _width: number, | ||
private _height: number | ||
) {} | ||
|
||
dispose() {} | ||
|
||
source() { | ||
return this._source; | ||
} | ||
|
||
width() { | ||
return this._width; | ||
} | ||
|
||
height() { | ||
return this._height; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { SkJSIInstance, Skia } from "../../../../skia/types"; | ||
import type { EvalContext } from "../../setup"; | ||
|
||
export abstract class SkiaObject< | ||
Ctx extends EvalContext, | ||
R extends SkJSIInstance<string> | ||
> { | ||
protected _source: string; | ||
protected instance: R; | ||
|
||
constructor( | ||
Skia: Skia, | ||
fn: (Skia: Skia, ctx: Ctx) => R, | ||
public _context: Ctx | ||
) { | ||
this._source = fn.toString(); | ||
this.instance = fn(Skia, _context); | ||
} | ||
|
||
get source() { | ||
return this._source; | ||
} | ||
|
||
get context() { | ||
return this._context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./Paragraph"; | ||
export * from "./SVG"; | ||
export * from "./SkiaObject"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters