mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-22 12:53:23 +03:00
Minimap viewport rectangle border
This commit is contained in:
parent
f691f11670
commit
5f99ee8c4e
@ -191,14 +191,29 @@ export const overlayRectangleRenderer = (regl: regl.ReglCommandConstructor) => {
|
||||
vec2 origin = (configSpaceToPhysicalViewSpace * vec3(configSpaceViewportOrigin, 1.0)).xy;
|
||||
vec2 size = (configSpaceToPhysicalViewSpace * vec3(configSpaceViewportSize, 0.0)).xy;
|
||||
|
||||
// TODO(jlfwong): Simplify this with clamp()
|
||||
if (gl_FragCoord.x > origin.x &&
|
||||
(physicalSize.y - gl_FragCoord.y) > origin.y &&
|
||||
gl_FragCoord.x < (origin.x + size.x) &&
|
||||
(physicalSize.y - gl_FragCoord.y) < (origin.y + size.y)) {
|
||||
gl_FragColor = vec4(1, 0, 0, 0.0);
|
||||
vec2 halfSize = physicalSize / 2.0;
|
||||
|
||||
float borderWidth = 2.0;
|
||||
|
||||
origin = floor(origin * halfSize) / halfSize + borderWidth * vec2(1.0, 1.0);
|
||||
size = floor(size * halfSize) / halfSize - 2.0 * borderWidth * vec2(1.0, 1.0);
|
||||
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
coord.y = physicalSize.y - coord.y;
|
||||
vec2 clamped = clamp(coord, origin, origin + size);
|
||||
vec2 gap = clamped - coord;
|
||||
float maxdist = max(abs(gap.x), abs(gap.y));
|
||||
|
||||
// TOOD(jlfwong): Could probably optimize this to use mix somehow.
|
||||
if (maxdist == 0.0) {
|
||||
// Inside viewport rectangle
|
||||
gl_FragColor = vec4(0, 0, 0, 0);
|
||||
} else if (maxdist < borderWidth) {
|
||||
// Inside viewport rectangle at border
|
||||
gl_FragColor = vec4(0.7, 0.7, 0.7, 0.8);
|
||||
} else {
|
||||
gl_FragColor = vec4(0, 0, 0.1, 0.5);
|
||||
// Outside viewport rectangle
|
||||
gl_FragColor = vec4(0.7, 0.7, 0.7, 0.5);
|
||||
}
|
||||
}
|
||||
`,
|
||||
@ -206,8 +221,10 @@ export const overlayRectangleRenderer = (regl: regl.ReglCommandConstructor) => {
|
||||
blend: {
|
||||
enable: true,
|
||||
func: {
|
||||
src: 'src alpha',
|
||||
dst: 'one minus src alpha'
|
||||
srcRGB: 'src alpha',
|
||||
srcAlpha: 'one',
|
||||
dstRGB: 'one minus src alpha',
|
||||
dstAlpha: 'one'
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -11,10 +11,17 @@ export enum FontSize {
|
||||
LABEL = 10
|
||||
}
|
||||
|
||||
export enum Colors {
|
||||
MEDIUM_GRAY = "#BDBDBD",
|
||||
LIGHT_GRAY = "#C4C4C4"
|
||||
}
|
||||
|
||||
|
||||
export namespace Sizes {
|
||||
export const MINIMAP_HEIGHT = 100
|
||||
export const TOOLTIP_WIDTH_MAX = 300
|
||||
export const TOOLTIP_HEIGHT_MAX = 75
|
||||
export const SEPARATOR_HEIGHT = 2
|
||||
}
|
||||
|
||||
export const style = StyleSheet.create({
|
||||
@ -55,12 +62,13 @@ export const style = StyleSheet.create({
|
||||
top: 0,
|
||||
height: Sizes.MINIMAP_HEIGHT,
|
||||
width: '100%',
|
||||
borderBottom: `${Sizes.SEPARATOR_HEIGHT}px solid ${Colors.MEDIUM_GRAY}`
|
||||
},
|
||||
panZoomView: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
top: Sizes.MINIMAP_HEIGHT,
|
||||
top: Sizes.MINIMAP_HEIGHT + Sizes.SEPARATOR_HEIGHT,
|
||||
width: '100%',
|
||||
height: `calc(100% - ${Sizes.MINIMAP_HEIGHT}px)`,
|
||||
height: `calc(100% - ${Sizes.MINIMAP_HEIGHT + Sizes.SEPARATOR_HEIGHT}px)`,
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue
Block a user