Skip to content

Commit

Permalink
feat(offscreen): code style improvements + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaZN committed Dec 2, 2023
1 parent 5e0c288 commit 52bdb3d
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 184 deletions.
2 changes: 1 addition & 1 deletion src/chart/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default class ChartBootstrap {
{
// can be read frequently, see {redrawBackgroundArea} function
willReadFrequently: true,
offscreen: false,
offscreen: true,
},
);
this.backgroundCanvasModel = backgroundCanvasModel;
Expand Down
67 changes: 37 additions & 30 deletions src/chart/canvas/offscreen/canvas-ctx.mapper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// #region canvas commands encodings - see commands mappings to methods below
export const FONT = 0;
export const WIDTH = 1;
export const HEIGHT = 2;
Expand All @@ -7,7 +8,6 @@ export const LINE_WIDTH = 5;
export const LINE_CAP = 6;
export const SAVE = 7;
export const RESTORE = 8;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const MEASURE_TEXT = 9;
export const CLEAR_RECT = 10;
export const FILL_RECT = 11;
Expand All @@ -28,35 +28,42 @@ export const STROKE_RECT = 25;
export const SCALE = 26;
export const NOP = 27;
export const ARC = 28;
export const SET_LINE_DASH_FLAT = 29;

// Special command which indicates the end of canvas commands inside the buffer
export const END_OF_FILE = 0xdead;
// #endregion

// Map from command number to canvas context method name
export const num2Ctx = [
'font',
'width',
'height',
'fillStyle',
'strokeStyle',
'lineWidth',
'lineCap',
'save',
'restore',
'measureText',
'clearRect',
'fillRect',
'strokeText',
'setLineDash',
'fillText',
'rect',
'clip',
'quadraticCurveTo',
'bezierCurveTo',
'beginPath',
'moveTo',
'lineTo',
'stroke',
'fill',
'closePath',
'strokeRect',
'scale',
'nop',
'arc',
'font',
'width',
'height',
'fillStyle',
'strokeStyle',
'lineWidth',
'lineCap',
'save',
'restore',
'measureText',
'clearRect',
'fillRect',
'strokeText',
'setLineDash',
'fillText',
'rect',
'clip',
'quadraticCurveTo',
'bezierCurveTo',
'beginPath',
'moveTo',
'lineTo',
'stroke',
'fill',
'closePath',
'strokeRect',
'scale',
'nop',
'arc',
'setLineDashFlat',
];
Loading

0 comments on commit 52bdb3d

Please sign in to comment.