mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-22 12:53:23 +03:00
Address review comments
* Switch to `bracketSpacing: false`. * Add prettier-ignore in one case.
This commit is contained in:
parent
1bcb88670b
commit
404aacfa46
@ -1,17 +1,17 @@
|
||||
import { h } from 'preact'
|
||||
import { StyleSheet, css } from 'aphrodite'
|
||||
import { ReloadableComponent, SerializedComponent } from './reloadable'
|
||||
import {h} from 'preact'
|
||||
import {StyleSheet, css} from 'aphrodite'
|
||||
import {ReloadableComponent, SerializedComponent} from './reloadable'
|
||||
|
||||
import { importFromBGFlameGraph } from './import/bg-flamegraph'
|
||||
import { importFromStackprof } from './import/stackprof'
|
||||
import { importFromChromeTimeline, importFromChromeCPUProfile } from './import/chrome'
|
||||
import { FlamechartRenderer } from './flamechart-renderer'
|
||||
import { CanvasContext } from './canvas-context'
|
||||
import {importFromBGFlameGraph} from './import/bg-flamegraph'
|
||||
import {importFromStackprof} from './import/stackprof'
|
||||
import {importFromChromeTimeline, importFromChromeCPUProfile} from './import/chrome'
|
||||
import {FlamechartRenderer} from './flamechart-renderer'
|
||||
import {CanvasContext} from './canvas-context'
|
||||
|
||||
import { Profile, Frame } from './profile'
|
||||
import { Flamechart } from './flamechart'
|
||||
import { FlamechartView } from './flamechart-view'
|
||||
import { FontFamily, FontSize, Colors } from './style'
|
||||
import {Profile, Frame} from './profile'
|
||||
import {Flamechart} from './flamechart'
|
||||
import {FlamechartView} from './flamechart-view'
|
||||
import {FontFamily, FontSize, Colors} from './style'
|
||||
|
||||
declare function require(x: string): any
|
||||
const exampleProfileURL = require('./sample/perf-vertx-stacks-01-collapsed-all.txt')
|
||||
@ -164,7 +164,7 @@ export class GLCanvas extends ReloadableComponent<GLCanvasProps, void> {
|
||||
|
||||
private maybeResize() {
|
||||
if (!this.canvas) return
|
||||
let { width, height } = this.canvas.getBoundingClientRect()
|
||||
let {width, height} = this.canvas.getBoundingClientRect()
|
||||
width = Math.floor(width) * window.devicePixelRatio
|
||||
height = Math.floor(height) * window.devicePixelRatio
|
||||
|
||||
@ -220,7 +220,7 @@ export class Application extends ReloadableComponent<{}, ApplicationState> {
|
||||
|
||||
rehydrate(serialized: SerializedComponent<ApplicationState>) {
|
||||
super.rehydrate(serialized)
|
||||
const { flamechart, sortedFlamechart } = serialized.state
|
||||
const {flamechart, sortedFlamechart} = serialized.state
|
||||
if (this.canvasContext && flamechart && sortedFlamechart) {
|
||||
this.setState({
|
||||
flamechartRenderer: new FlamechartRenderer(this.canvasContext, flamechart),
|
||||
@ -235,7 +235,7 @@ export class Application extends ReloadableComponent<{}, ApplicationState> {
|
||||
console.time('import')
|
||||
const profile = importProfile(contents, fileName)
|
||||
if (profile == null) {
|
||||
this.setState({ loading: false })
|
||||
this.setState({loading: false})
|
||||
// TODO(jlfwong): Make this a nicer overlay
|
||||
alert('Unrecognized format! See documentation about supported formats.')
|
||||
return
|
||||
@ -298,7 +298,7 @@ export class Application extends ReloadableComponent<{}, ApplicationState> {
|
||||
}
|
||||
|
||||
loadFromFile(file: File) {
|
||||
this.setState({ loading: true }, () => {
|
||||
this.setState({loading: true}, () => {
|
||||
requestAnimationFrame(() => {
|
||||
const reader = new FileReader()
|
||||
reader.addEventListener('loadend', () => {
|
||||
@ -310,7 +310,7 @@ export class Application extends ReloadableComponent<{}, ApplicationState> {
|
||||
}
|
||||
|
||||
loadExample = () => {
|
||||
this.setState({ loading: true })
|
||||
this.setState({loading: true})
|
||||
const filename = 'perf-vertx-stacks-01-collapsed-all.txt'
|
||||
fetch(exampleProfileURL)
|
||||
.then(resp => resp.text())
|
||||
@ -435,7 +435,7 @@ export class Application extends ReloadableComponent<{}, ApplicationState> {
|
||||
}
|
||||
|
||||
setSortOrder = (sortOrder: SortOrder) => {
|
||||
this.setState({ sortOrder })
|
||||
this.setState({sortOrder})
|
||||
}
|
||||
|
||||
private canvasContext: CanvasContext | null = null
|
||||
|
@ -13,9 +13,9 @@ import {
|
||||
TextureRenderer,
|
||||
TextureRendererProps,
|
||||
} from './texture-catched-renderer'
|
||||
import { StatsPanel } from './stats'
|
||||
import {StatsPanel} from './stats'
|
||||
|
||||
import { Vec2, Rect } from './math'
|
||||
import {Vec2, Rect} from './math'
|
||||
import {
|
||||
FlamechartColorPassRenderer,
|
||||
FlamechartColorPassRenderProps,
|
||||
@ -33,7 +33,7 @@ export class CanvasContext {
|
||||
private viewportRectangleRenderer: ViewportRectangleRenderer
|
||||
private textureRenderer: TextureRenderer
|
||||
private flamechartColorPassRenderer: FlamechartColorPassRenderer
|
||||
private setViewportScope: regl.Command<{ physicalBounds: Rect }>
|
||||
private setViewportScope: regl.Command<{physicalBounds: Rect}>
|
||||
private setScissor: regl.Command<{}>
|
||||
|
||||
constructor(canvas: HTMLCanvasElement) {
|
||||
@ -51,7 +51,7 @@ export class CanvasContext {
|
||||
this.viewportRectangleRenderer = new ViewportRectangleRenderer(this.gl)
|
||||
this.textureRenderer = new TextureRenderer(this.gl)
|
||||
this.flamechartColorPassRenderer = new FlamechartColorPassRenderer(this.gl)
|
||||
this.setScissor = this.gl({ scissor: { enable: true } })
|
||||
this.setScissor = this.gl({scissor: {enable: true}})
|
||||
this.setViewportScope = this.gl<SetViewportScopeProps>({
|
||||
context: {
|
||||
viewportX: (context: regl.Context, props: SetViewportScopeProps) => {
|
||||
@ -62,7 +62,7 @@ export class CanvasContext {
|
||||
},
|
||||
},
|
||||
viewport: (context, props) => {
|
||||
const { physicalBounds } = props
|
||||
const {physicalBounds} = props
|
||||
return {
|
||||
x: physicalBounds.left(),
|
||||
y:
|
||||
@ -74,7 +74,7 @@ export class CanvasContext {
|
||||
}
|
||||
},
|
||||
scissor: (context, props) => {
|
||||
const { physicalBounds } = props
|
||||
const {physicalBounds} = props
|
||||
return {
|
||||
enable: true,
|
||||
box: {
|
||||
@ -112,7 +112,7 @@ export class CanvasContext {
|
||||
|
||||
private onBeforeFrame = (context: regl.Context) => {
|
||||
this.setScissor(() => {
|
||||
this.gl.clear({ color: [0, 0, 0, 0] })
|
||||
this.gl.clear({color: [0, 0, 0, 0]})
|
||||
})
|
||||
|
||||
this.tickNeeded = false
|
||||
@ -173,11 +173,11 @@ export class CanvasContext {
|
||||
new Vec2(bounds.left * window.devicePixelRatio, bounds.top * window.devicePixelRatio),
|
||||
new Vec2(bounds.width * window.devicePixelRatio, bounds.height * window.devicePixelRatio),
|
||||
)
|
||||
this.setViewportScope({ physicalBounds }, cb)
|
||||
this.setViewportScope({physicalBounds}, cb)
|
||||
}
|
||||
|
||||
setViewport(physicalBounds: Rect, cb: (context: regl.Context) => void) {
|
||||
this.setViewportScope({ physicalBounds }, cb)
|
||||
this.setViewportScope({physicalBounds}, cb)
|
||||
}
|
||||
|
||||
getMaxTextureSize() {
|
||||
|
2
color.ts
2
color.ts
@ -1,4 +1,4 @@
|
||||
import { Frame } from './profile'
|
||||
import {Frame} from './profile'
|
||||
|
||||
export class Color {
|
||||
constructor(
|
||||
|
@ -1,5 +1,5 @@
|
||||
import regl from 'regl'
|
||||
import { Vec2, Rect, AffineTransform } from './math'
|
||||
import {Vec2, Rect, AffineTransform} from './math'
|
||||
|
||||
export interface FlamechartColorPassRenderProps {
|
||||
rectInfoTexture: regl.Texture
|
||||
@ -125,7 +125,7 @@ export class FlamechartColorPassRenderer {
|
||||
uniforms: {
|
||||
colorTexture: (context, props) => props.rectInfoTexture,
|
||||
uvTransform: (context, props) => {
|
||||
const { srcRect, rectInfoTexture } = props
|
||||
const {srcRect, rectInfoTexture} = props
|
||||
const physicalToUV = AffineTransform.withTranslation(new Vec2(0, 1))
|
||||
.times(AffineTransform.withScale(new Vec2(1, -1)))
|
||||
.times(
|
||||
@ -146,7 +146,7 @@ export class FlamechartColorPassRenderer {
|
||||
.flatten()
|
||||
},
|
||||
positionTransform: (context, props) => {
|
||||
const { dstRect } = props
|
||||
const {dstRect} = props
|
||||
const viewportSize = new Vec2(context.viewportWidth, context.viewportHeight)
|
||||
|
||||
const physicalToNDC = AffineTransform.withScale(new Vec2(1, -1)).times(
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { h, Component } from 'preact'
|
||||
import { css } from 'aphrodite'
|
||||
import { Flamechart } from './flamechart'
|
||||
import { Rect, Vec2, AffineTransform, clamp } from './math'
|
||||
import { FlamechartRenderer } from './flamechart-renderer'
|
||||
import { cachedMeasureTextWidth } from './utils'
|
||||
import { style, Sizes } from './flamechart-style'
|
||||
import { FontFamily, FontSize, Colors } from './style'
|
||||
import { CanvasContext } from './canvas-context'
|
||||
import { TextureCachedRenderer } from './texture-catched-renderer'
|
||||
import {h, Component} from 'preact'
|
||||
import {css} from 'aphrodite'
|
||||
import {Flamechart} from './flamechart'
|
||||
import {Rect, Vec2, AffineTransform, clamp} from './math'
|
||||
import {FlamechartRenderer} from './flamechart-renderer'
|
||||
import {cachedMeasureTextWidth} from './utils'
|
||||
import {style, Sizes} from './flamechart-style'
|
||||
import {FontFamily, FontSize, Colors} from './style'
|
||||
import {CanvasContext} from './canvas-context'
|
||||
import {TextureCachedRenderer} from './texture-catched-renderer'
|
||||
|
||||
const DEVICE_PIXEL_RATIO = window.devicePixelRatio
|
||||
|
||||
@ -208,7 +208,7 @@ export class FlamechartMinimapView extends Component<FlamechartMinimapViewProps,
|
||||
|
||||
private resizeOverlayCanvasIfNeeded() {
|
||||
if (!this.overlayCanvas) return
|
||||
let { width, height } = this.overlayCanvas.getBoundingClientRect()
|
||||
let {width, height} = this.overlayCanvas.getBoundingClientRect()
|
||||
{
|
||||
/*
|
||||
We render text at a higher resolution then scale down to
|
||||
|
@ -1,11 +1,11 @@
|
||||
import regl from 'regl'
|
||||
import { Flamechart } from './flamechart'
|
||||
import { RectangleBatch } from './rectangle-batch-renderer'
|
||||
import { CanvasContext } from './canvas-context'
|
||||
import { Vec2, Rect, AffineTransform } from './math'
|
||||
import { LRUCache } from './lru-cache'
|
||||
import { Color } from './color'
|
||||
import { getOrInsert } from './utils'
|
||||
import {Flamechart} from './flamechart'
|
||||
import {RectangleBatch} from './rectangle-batch-renderer'
|
||||
import {CanvasContext} from './canvas-context'
|
||||
import {Vec2, Rect, AffineTransform} from './math'
|
||||
import {LRUCache} from './lru-cache'
|
||||
import {Color} from './color'
|
||||
import {getOrInsert} from './utils'
|
||||
|
||||
const MAX_BATCH_SIZE = 10000
|
||||
|
||||
@ -23,7 +23,7 @@ class RowAtlas<K> {
|
||||
wrapS: 'clamp',
|
||||
wrapT: 'clamp',
|
||||
})
|
||||
this.framebuffer = canvasContext.gl.framebuffer({ color: [this.texture] })
|
||||
this.framebuffer = canvasContext.gl.framebuffer({color: [this.texture]})
|
||||
this.rowCache = new LRUCache(this.texture.height)
|
||||
this.renderToFramebuffer = canvasContext.gl({
|
||||
framebuffer: this.framebuffer,
|
||||
@ -261,7 +261,7 @@ export class FlamechartRenderer {
|
||||
// range than a tree of always-height-two might make this run faster
|
||||
this.layers.push(new RangeTreeInteriorNode(leafNodes))
|
||||
}
|
||||
this.rectInfoTexture = this.canvasContext.gl.texture({ width: 1, height: 1 })
|
||||
this.rectInfoTexture = this.canvasContext.gl.texture({width: 1, height: 1})
|
||||
this.framebuffer = this.canvasContext.gl.framebuffer({
|
||||
color: [this.rectInfoTexture],
|
||||
})
|
||||
@ -274,7 +274,7 @@ export class FlamechartRenderer {
|
||||
}
|
||||
|
||||
configSpaceBoundsForKey(key: FlamechartRowAtlasKey): Rect {
|
||||
const { stackDepth, zoomLevel, index } = key
|
||||
const {stackDepth, zoomLevel, index} = key
|
||||
const configSpaceContentWidth = this.flamechart.getTotalWeight()
|
||||
|
||||
const width = configSpaceContentWidth / Math.pow(2, zoomLevel)
|
||||
@ -283,9 +283,9 @@ export class FlamechartRenderer {
|
||||
}
|
||||
|
||||
render(props: FlamechartRendererProps) {
|
||||
const { configSpaceSrcRect, physicalSpaceDstRect } = props
|
||||
const {configSpaceSrcRect, physicalSpaceDstRect} = props
|
||||
|
||||
const atlasKeysToRender: { stackDepth: number; zoomLevel: number; index: number }[] = []
|
||||
const atlasKeysToRender: {stackDepth: number; zoomLevel: number; index: number}[] = []
|
||||
|
||||
// We want to render the lowest resolution we can while still guaranteeing that the
|
||||
// atlas line is higher resolution than its corresponding destination rectangle on
|
||||
@ -298,7 +298,7 @@ export class FlamechartRenderer {
|
||||
|
||||
let zoomLevel = 0
|
||||
while (true) {
|
||||
const configSpaceBounds = this.configSpaceBoundsForKey({ stackDepth: 0, zoomLevel, index: 0 })
|
||||
const configSpaceBounds = this.configSpaceBoundsForKey({stackDepth: 0, zoomLevel, index: 0})
|
||||
const physicalBounds = configToPhysical.transformRect(configSpaceBounds)
|
||||
if (physicalBounds.width() < this.rowAtlas.getResolution()) {
|
||||
break
|
||||
@ -320,7 +320,7 @@ export class FlamechartRenderer {
|
||||
|
||||
for (let stackDepth = top; stackDepth < bottom; stackDepth++) {
|
||||
for (let index = left; index <= right; index++) {
|
||||
const key = this.getOrInsertKey({ stackDepth, zoomLevel, index })
|
||||
const key = this.getOrInsertKey({stackDepth, zoomLevel, index})
|
||||
const configSpaceBounds = this.configSpaceBoundsForKey(key)
|
||||
if (!configSpaceBounds.hasIntersectionWith(configSpaceSrcRect)) continue
|
||||
atlasKeysToRender.push(key)
|
||||
@ -347,7 +347,7 @@ export class FlamechartRenderer {
|
||||
|
||||
this.framebuffer.resize(physicalSpaceDstRect.width(), physicalSpaceDstRect.height())
|
||||
this.framebuffer.use(context => {
|
||||
this.canvasContext.gl.clear({ color: [0, 0, 0, 0] })
|
||||
this.canvasContext.gl.clear({color: [0, 0, 0, 0]})
|
||||
const viewportRect = new Rect(
|
||||
Vec2.zero,
|
||||
new Vec2(context.viewportWidth, context.viewportHeight),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { StyleSheet } from 'aphrodite'
|
||||
import { FontFamily, FontSize, Colors } from './style'
|
||||
import {StyleSheet} from 'aphrodite'
|
||||
import {FontFamily, FontSize, Colors} from './style'
|
||||
|
||||
const HOVERTIP_PADDING = 2
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
import { h } from 'preact'
|
||||
import { css } from 'aphrodite'
|
||||
import { ReloadableComponent } from './reloadable'
|
||||
import {h} from 'preact'
|
||||
import {css} from 'aphrodite'
|
||||
import {ReloadableComponent} from './reloadable'
|
||||
|
||||
import { CallTreeNode } from './profile'
|
||||
import { Flamechart, FlamechartFrame } from './flamechart'
|
||||
import {CallTreeNode} from './profile'
|
||||
import {Flamechart, FlamechartFrame} from './flamechart'
|
||||
|
||||
import { Rect, Vec2, AffineTransform, clamp } from './math'
|
||||
import { cachedMeasureTextWidth } from './utils'
|
||||
import { FlamechartMinimapView } from './flamechart-minimap-view'
|
||||
import {Rect, Vec2, AffineTransform, clamp} from './math'
|
||||
import {cachedMeasureTextWidth} from './utils'
|
||||
import {FlamechartMinimapView} from './flamechart-minimap-view'
|
||||
|
||||
import { style, Sizes } from './flamechart-style'
|
||||
import { FontSize, FontFamily, Colors } from './style'
|
||||
import { CanvasContext } from './canvas-context'
|
||||
import { FlamechartRenderer } from './flamechart-renderer'
|
||||
import {style, Sizes} from './flamechart-style'
|
||||
import {FontSize, FontFamily, Colors} from './style'
|
||||
import {CanvasContext} from './canvas-context'
|
||||
import {FlamechartRenderer} from './flamechart-renderer'
|
||||
|
||||
interface FlamechartFrameLabel {
|
||||
configSpaceBounds: Rect
|
||||
@ -145,7 +145,7 @@ export class FlamechartPanZoomView extends ReloadableComponent<FlamechartPanZoom
|
||||
|
||||
private resizeOverlayCanvasIfNeeded() {
|
||||
if (!this.overlayCanvas) return
|
||||
let { width, height } = this.overlayCanvas.getBoundingClientRect()
|
||||
let {width, height} = this.overlayCanvas.getBoundingClientRect()
|
||||
{
|
||||
/*
|
||||
We render text at a higher resolution then scale down to
|
||||
@ -297,7 +297,7 @@ export class FlamechartPanZoomView extends ReloadableComponent<FlamechartPanZoom
|
||||
private updateConfigSpaceViewport(windowResized = false) {
|
||||
if (!this.container) return
|
||||
const bounds = this.container.getBoundingClientRect()
|
||||
const { width, height } = bounds
|
||||
const {width, height} = bounds
|
||||
|
||||
// Still initializing: don't resize yet
|
||||
if (width < 2 || height < 2) return
|
||||
@ -537,7 +537,7 @@ export class FlamechartPanZoomView extends ReloadableComponent<FlamechartPanZoom
|
||||
|
||||
onWindowKeyPress = (ev: KeyboardEvent) => {
|
||||
if (!this.container) return
|
||||
const { width, height } = this.container.getBoundingClientRect()
|
||||
const {width, height} = this.container.getBoundingClientRect()
|
||||
|
||||
if (ev.key === '=' || ev.key === '+') {
|
||||
this.zoom(new Vec2(width / 2, height / 2), 0.5)
|
||||
@ -681,10 +681,10 @@ export class FlamechartView extends ReloadableComponent<FlamechartViewProps, Fla
|
||||
renderTooltip() {
|
||||
if (!this.container) return null
|
||||
|
||||
const { hoveredNode, logicalSpaceMouse } = this.state
|
||||
const {hoveredNode, logicalSpaceMouse} = this.state
|
||||
if (!hoveredNode) return null
|
||||
|
||||
const { width, height } = this.container.getBoundingClientRect()
|
||||
const {width, height} = this.container.getBoundingClientRect()
|
||||
|
||||
const positionStyle: {
|
||||
left?: number
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Frame, CallTreeNode } from './profile'
|
||||
import {Frame, CallTreeNode} from './profile'
|
||||
|
||||
import { lastOf } from './utils'
|
||||
import {lastOf} from './utils'
|
||||
|
||||
export interface FlamechartFrame {
|
||||
node: CallTreeNode
|
||||
|
@ -1,6 +1,6 @@
|
||||
// https://github.com/brendangregg/FlameGraph#2-fold-stacks
|
||||
|
||||
import { Profile, FrameInfo } from '../profile'
|
||||
import {Profile, FrameInfo} from '../profile'
|
||||
|
||||
interface BGSample {
|
||||
stack: FrameInfo[]
|
||||
@ -11,7 +11,7 @@ function parseBGFoldedStacks(contents: string): BGSample[] {
|
||||
const samples: BGSample[] = []
|
||||
contents.replace(/^(.*) (\d+)$/gm, (match: string, stack: string, n: string) => {
|
||||
samples.push({
|
||||
stack: stack.split(';').map(name => ({ key: name, name: name })),
|
||||
stack: stack.split(';').map(name => ({key: name, name: name})),
|
||||
duration: parseInt(n, 10),
|
||||
})
|
||||
return match
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Profile, TimeFormatter, FrameInfo } from '../profile'
|
||||
import { getOrInsert, lastOf } from '../utils'
|
||||
import {Profile, TimeFormatter, FrameInfo} from '../profile'
|
||||
import {getOrInsert, lastOf} from '../utils'
|
||||
|
||||
interface TimelineEvent {
|
||||
pid: number
|
||||
@ -11,7 +11,7 @@ interface TimelineEvent {
|
||||
dur: number
|
||||
tdur: number
|
||||
tts: number
|
||||
args: { [key: string]: any }
|
||||
args: {[key: string]: any}
|
||||
}
|
||||
|
||||
interface PositionTickInfo {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// https://github.com/tmm1/stackprof
|
||||
|
||||
import { Profile, TimeFormatter, FrameInfo } from '../profile'
|
||||
import {Profile, TimeFormatter, FrameInfo} from '../profile'
|
||||
|
||||
interface StackprofFrame {
|
||||
name: string
|
||||
@ -9,7 +9,7 @@ interface StackprofFrame {
|
||||
}
|
||||
|
||||
export interface StackprofProfile {
|
||||
frames: { [number: string]: StackprofFrame }
|
||||
frames: {[number: string]: StackprofFrame}
|
||||
raw: number[]
|
||||
raw_timestamp_deltas: number[]
|
||||
}
|
||||
@ -18,7 +18,7 @@ export function importFromStackprof(stackprofProfile: StackprofProfile): Profile
|
||||
const duration = stackprofProfile.raw_timestamp_deltas.reduce((a, b) => a + b, 0)
|
||||
const profile = new Profile(duration)
|
||||
|
||||
const { frames, raw, raw_timestamp_deltas } = stackprofProfile
|
||||
const {frames, raw, raw_timestamp_deltas} = stackprofProfile
|
||||
let sampleIndex = 0
|
||||
for (let i = 0; i < raw.length; ) {
|
||||
const stackHeight = raw[i++]
|
||||
|
@ -139,7 +139,7 @@ export class LRUCache<K, V> {
|
||||
this.map.delete(this.list.pop()!.data)
|
||||
}
|
||||
const listNode = this.list.prepend(new ListNode(key))
|
||||
this.map.set(key, { value, listNode })
|
||||
this.map.set(key, {value, listNode})
|
||||
}
|
||||
|
||||
getOrInsert(key: K, f: (key: K) => V): V {
|
||||
|
17
math.ts
17
math.ts
@ -71,7 +71,7 @@ export class AffineTransform {
|
||||
) {}
|
||||
|
||||
withScale(s: Vec2) {
|
||||
let { m00, m01, m02, m10, m11, m12 } = this
|
||||
let {m00, m01, m02, m10, m11, m12} = this
|
||||
m00 = s.x
|
||||
m11 = s.y
|
||||
return new AffineTransform(m00, m01, m02, m10, m11, m12)
|
||||
@ -87,7 +87,7 @@ export class AffineTransform {
|
||||
}
|
||||
|
||||
withTranslation(t: Vec2) {
|
||||
let { m00, m01, m02, m10, m11, m12 } = this
|
||||
let {m00, m01, m02, m10, m11, m12} = this
|
||||
m02 = t.x
|
||||
m12 = t.y
|
||||
return new AffineTransform(m00, m01, m02, m10, m11, m12)
|
||||
@ -131,12 +131,12 @@ export class AffineTransform {
|
||||
}
|
||||
|
||||
timesScalar(s: number) {
|
||||
const { m00, m01, m02, m10, m11, m12 } = this
|
||||
const {m00, m01, m02, m10, m11, m12} = this
|
||||
return new AffineTransform(s * m00, s * m01, s * m02, s * m10, s * m11, s * m12)
|
||||
}
|
||||
|
||||
det() {
|
||||
const { m00, m01, m02, m10, m11, m12 } = this
|
||||
const {m00, m01, m02, m10, m11, m12} = this
|
||||
const m20 = 0
|
||||
const m21 = 0
|
||||
const m22 = 1
|
||||
@ -147,7 +147,7 @@ export class AffineTransform {
|
||||
}
|
||||
|
||||
adj() {
|
||||
const { m00, m01, m02, m10, m11, m12 } = this
|
||||
const {m00, m01, m02, m10, m11, m12} = this
|
||||
const m20 = 0
|
||||
const m21 = 0
|
||||
const m22 = 1
|
||||
@ -222,7 +222,12 @@ export class AffineTransform {
|
||||
|
||||
flatten(): [number, number, number, number, number, number, number, number, number] {
|
||||
// Flatten into GLSL format
|
||||
return [this.m00, this.m10, 0, this.m01, this.m11, 0, this.m02, this.m12, 1]
|
||||
// prettier-ignore
|
||||
return [
|
||||
this.m00, this.m10, 0,
|
||||
this.m01, this.m11, 0,
|
||||
this.m02, this.m12, 1,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import regl from 'regl'
|
||||
import { AffineTransform, Rect } from './math'
|
||||
import {AffineTransform, Rect} from './math'
|
||||
|
||||
export interface ViewportRectangleRendererProps {
|
||||
configSpaceToPhysicalViewSpace: AffineTransform
|
||||
@ -118,7 +118,7 @@ export class ViewportRectangleRenderer {
|
||||
}
|
||||
|
||||
resetStats() {
|
||||
return Object.assign(this.command.stats, { cpuTime: 0, gpuTime: 0, count: 0 })
|
||||
return Object.assign(this.command.stats, {cpuTime: 0, gpuTime: 0, count: 0})
|
||||
}
|
||||
stats() {
|
||||
return this.command.stats
|
||||
|
@ -1,4 +1,5 @@
|
||||
module.exports = {
|
||||
bracketSpacing: false,
|
||||
printWidth: 100,
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { lastOf, getOrInsert } from './utils'
|
||||
import {lastOf, getOrInsert} from './utils'
|
||||
const demangleCppModule = import('./demangle-cpp')
|
||||
|
||||
// Force eager loading of the module
|
||||
|
@ -1,6 +1,6 @@
|
||||
import regl from 'regl'
|
||||
import { Rect, Vec2, AffineTransform } from './math'
|
||||
import { Color } from './color'
|
||||
import {Rect, Vec2, AffineTransform} from './math'
|
||||
import {Color} from './color'
|
||||
|
||||
export class RectangleBatch {
|
||||
private rectCapacity = 1000
|
||||
@ -197,7 +197,7 @@ export class RectangleBatchRenderer {
|
||||
}
|
||||
|
||||
resetStats() {
|
||||
return Object.assign(this.command.stats, { cpuTime: 0, gpuTime: 0, count: 0 })
|
||||
return Object.assign(this.command.stats, {cpuTime: 0, gpuTime: 0, count: 0})
|
||||
}
|
||||
stats() {
|
||||
return this.command.stats
|
||||
|
12
regl.d.ts
vendored
12
regl.d.ts
vendored
@ -370,7 +370,7 @@ declare module 'regl' {
|
||||
| AttributeOptions
|
||||
| Buffer
|
||||
| BufferArgs
|
||||
| { constant: number | vec2 | vec3 | vec4 | mat3 | mat4 }
|
||||
| {constant: number | vec2 | vec3 | vec4 | mat3 | mat4}
|
||||
|
||||
interface Computed<P, T> {
|
||||
(context: Context, props: P, batchId: number): T
|
||||
@ -427,11 +427,11 @@ declare module 'regl' {
|
||||
/** Source code of fragment shader */
|
||||
frag?: string
|
||||
|
||||
context?: { [contextName: string]: MaybeComputed<P, any> }
|
||||
context?: {[contextName: string]: MaybeComputed<P, any>}
|
||||
|
||||
uniforms?: { [uniformName: string]: MaybeComputed<P, Uniform> }
|
||||
uniforms?: {[uniformName: string]: MaybeComputed<P, Uniform>}
|
||||
|
||||
attributes?: { [attributeName: string]: MaybeComputed<P, Attribute> }
|
||||
attributes?: {[attributeName: string]: MaybeComputed<P, Attribute>}
|
||||
|
||||
primitive?: DrawMode
|
||||
|
||||
@ -492,8 +492,8 @@ declare module 'regl' {
|
||||
enable?: boolean
|
||||
mask?: number
|
||||
func?: StencilFunction
|
||||
opFront?: { fail: StencilOp; zfail: StencilOp; pass: StencilOp }
|
||||
opBack?: { fail: StencilOp; zfail: StencilOp; pass: StencilOp }
|
||||
opFront?: {fail: StencilOp; zfail: StencilOp; pass: StencilOp}
|
||||
opBack?: {fail: StencilOp; zfail: StencilOp; pass: StencilOp}
|
||||
}
|
||||
>
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { Component } from 'preact'
|
||||
import {Component} from 'preact'
|
||||
|
||||
export interface SerializedComponent<S> {
|
||||
state: S
|
||||
serializedSubcomponents: { [key: string]: any }
|
||||
serializedSubcomponents: {[key: string]: any}
|
||||
}
|
||||
|
||||
export abstract class ReloadableComponent<P, S> extends Component<P, S> {
|
||||
serialize(): SerializedComponent<S> {
|
||||
const serializedSubcomponents: { [key: string]: any } = Object.create(null)
|
||||
const serializedSubcomponents: {[key: string]: any} = Object.create(null)
|
||||
|
||||
const subcomponents = this.subcomponents()
|
||||
for (const key in subcomponents) {
|
||||
@ -34,7 +34,7 @@ export abstract class ReloadableComponent<P, S> extends Component<P, S> {
|
||||
}
|
||||
})
|
||||
}
|
||||
subcomponents(): { [key: string]: any } {
|
||||
subcomponents(): {[key: string]: any} {
|
||||
return Object.create(null)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { h, render } from 'preact'
|
||||
import { Application } from './application'
|
||||
import {h, render} from 'preact'
|
||||
import {Application} from './application'
|
||||
|
||||
let app: Application | null = null
|
||||
const retained = (window as any)['__retained__'] as any
|
||||
|
@ -1,5 +1,5 @@
|
||||
import regl from 'regl'
|
||||
import { Vec2, Rect, AffineTransform } from './math'
|
||||
import {Vec2, Rect, AffineTransform} from './math'
|
||||
|
||||
export interface TextureRendererProps {
|
||||
texture: regl.Texture
|
||||
@ -55,7 +55,7 @@ export class TextureRenderer {
|
||||
uniforms: {
|
||||
texture: (context, props) => props.texture,
|
||||
uvTransform: (context, props) => {
|
||||
const { srcRect, texture } = props
|
||||
const {srcRect, texture} = props
|
||||
const physicalToUV = AffineTransform.withTranslation(new Vec2(0, 1))
|
||||
.times(AffineTransform.withScale(new Vec2(1, -1)))
|
||||
.times(
|
||||
@ -68,7 +68,7 @@ export class TextureRenderer {
|
||||
return AffineTransform.betweenRects(Rect.unit, uvRect).flatten()
|
||||
},
|
||||
positionTransform: (context, props) => {
|
||||
const { dstRect } = props
|
||||
const {dstRect} = props
|
||||
|
||||
const viewportSize = new Vec2(context.viewportWidth, context.viewportHeight)
|
||||
|
||||
@ -91,7 +91,7 @@ export class TextureRenderer {
|
||||
}
|
||||
|
||||
resetStats() {
|
||||
return Object.assign(this.command.stats, { cpuTime: 0, gpuTime: 0, count: 0 })
|
||||
return Object.assign(this.command.stats, {cpuTime: 0, gpuTime: 0, count: 0})
|
||||
}
|
||||
stats() {
|
||||
return this.command.stats
|
||||
@ -118,7 +118,7 @@ export class TextureCachedRenderer<T> {
|
||||
this.textureRenderer = options.textureRenderer
|
||||
|
||||
this.texture = gl.texture(1, 1)
|
||||
this.framebuffer = gl.framebuffer({ color: [this.texture] })
|
||||
this.framebuffer = gl.framebuffer({color: [this.texture]})
|
||||
this.withContext = gl({})
|
||||
}
|
||||
|
||||
@ -137,8 +137,8 @@ export class TextureCachedRenderer<T> {
|
||||
this.texture.height !== context.viewportHeight
|
||||
) {
|
||||
// TODO(jlfwong): Can probably just use this.framebuffer.resize
|
||||
this.texture({ width: context.viewportWidth, height: context.viewportHeight })
|
||||
this.framebuffer({ color: [this.texture] })
|
||||
this.texture({width: context.viewportWidth, height: context.viewportHeight})
|
||||
this.framebuffer({color: [this.texture]})
|
||||
needsRender = true
|
||||
} else if (this.lastRenderProps == null) {
|
||||
needsRender = true
|
||||
@ -160,7 +160,7 @@ export class TextureCachedRenderer<T> {
|
||||
},
|
||||
framebuffer: this.framebuffer,
|
||||
})(() => {
|
||||
this.gl.clear({ color: [0, 0, 0, 0] })
|
||||
this.gl.clear({color: [0, 0, 0, 0]})
|
||||
this.renderUncached(props)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user