Changeset 248146 in webkit


Ignore:
Timestamp:
Aug 1, 2019 8:50:15 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

results.webkit.org: Force update cache when timeline updated
https://bugs.webkit.org/show_bug.cgi?id=200363

Patch by Zhifei Fang <zhifei_fang@apple.com> on 2019-08-01
Reviewed by Jonathan Bedard.

  • resultsdbpy/resultsdbpy/view/static/library/js/components/TimelineComponents.js:

(offscreenCachedRenderFactory): Add ability to force the redraw.
(Timeline.CanvasSeriesComponent): Force redraw when scales or dots are updated.
(Timeline.CanvasXAxisComponent): Force redraw when scales are updated. Add missing exporter for export scales update API

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r248144 r248146  
     12019-08-01  Zhifei Fang  <zhifei_fang@apple.com>
     2
     3        results.webkit.org: Force update cache when timeline updated
     4        https://bugs.webkit.org/show_bug.cgi?id=200363
     5
     6        Reviewed by Jonathan Bedard.
     7
     8        * resultsdbpy/resultsdbpy/view/static/library/js/components/TimelineComponents.js:
     9        (offscreenCachedRenderFactory): Add ability to force the redraw.
     10        (Timeline.CanvasSeriesComponent): Force redraw when scales or dots are updated.
     11        (Timeline.CanvasXAxisComponent): Force redraw when scales are updated. Add missing exporter for export scales update API
     12
    1132019-08-01  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Tools/resultsdbpy/resultsdbpy/view/static/library/js/components/TimelineComponents.js

    r248134 r248146  
    132132    // and copy the viewport area from of it
    133133    // It will trigger redrawCache when cache don't have enough space
    134     return (redrawCache, element, stateDiff, state) => {
     134    return (redrawCache, element, stateDiff, state, forceRedrawCache = false) => {
    135135        const width = typeof stateDiff.width === 'number' ? stateDiff.width : state.width;
    136136        if (width <= 0)
     
    142142        const context = element.getContext('2d');
    143143        let cachePosLeft = scrollLeft - cachedScrollLeft;
     144        let needToRedrawCache = forceRedrawCache;
    144145
    145146        if (element.logicWidth != width) {
    146147            // Setup the dpr in case of blur
    147148            setupCanvasWidthWithDpr(element, width);
    148 
    149             // We draw everything on cache
    150             redrawCache(offscreenCanvas, element, stateDiff, state, () => {
    151                 cachedScrollLeft = scrollLeft < padding ? scrollLeft : scrollLeft - padding;
    152                 cachePosLeft = scrollLeft - cachedScrollLeft;
    153                 if (cachePosLeft < 0)
    154                     cachePosLeft = 0;
    155                 context.clearRect(0, 0, element.width, element.height);
    156                 context.drawImage(offscreenCanvas, cachePosLeft * getDevicePixelRatio(), 0,    element.width, element.height, 0, 0, width * getDevicePixelRatio(), element.height);
    157             });
    158 
     149            needToRedrawCache = true;
    159150        } else if (cachePosLeft < 0 || cachePosLeft + width > totalWidth) {
    160151            if (scrollLeft < 0 )
    161152                return;
    162             redrawCache(offscreenCanvas, element, stateDiff, state,    () => {
     153            needToRedrawCache = true;
     154        }
     155
     156        if (needToRedrawCache) {
     157            // We draw everything on cache
     158            redrawCache(offscreenCanvas, element, stateDiff, state, () => {
    163159                cachedScrollLeft = scrollLeft < padding ? scrollLeft : scrollLeft - padding;
    164160                cachePosLeft = scrollLeft - cachedScrollLeft;
     
    368364        onStateUpdate: (element, stateDiff, state) => {
    369365            const context = element.getContext("2d");
     366            let forceRedrawCache = false;
    370367            if (stateDiff.scales || stateDiff.dots || typeof stateDiff.scrollLeft === 'number' || typeof stateDiff.width === 'number') {
    371368                console.assert(dots.length <= scales.length);
    372                 requestAnimationFrame(() => offscreenCachedRender(redrawCache, element, stateDiff, state));
     369                if (stateDiff.scales || stateDiff.dots) {
     370                    forceRedrawCache = true;
     371                }
     372                requestAnimationFrame(() => offscreenCachedRender(redrawCache, element, stateDiff, state, forceRedrawCache));
    373373            }
    374374        }
     
    712712        },
    713713        onStateUpdate: (element, stateDiff, state) => {
     714            let forceRedrawCache = false;
    714715            if (stateDiff.scales || typeof stateDiff.scrollLeft === 'number' || typeof stateDiff.width === 'number') {
    715                 if (stateDiff.scales)
     716                if (stateDiff.scales) {
    716717                    state.scalesMapLinkList = getScalesMapLinkList(stateDiff.scales);
    717                 requestAnimationFrame(() => offscreenCachedRender(redrawCache, element, stateDiff, state));
     718                    forceRedrawCache = true;
     719                }
     720                requestAnimationFrame(() => offscreenCachedRender(redrawCache, element, stateDiff, state, forceRedrawCache));
    718721            }
    719722        }
     
    723726        series: ListProviderReceiver((updateContainerWidth, onContainerScroll, onResize) => {
    724727            updateContainerWidth(scales.length * scaleWidth * getDevicePixelRatio());
     728            const updateData = (scales) => {
     729                updateContainerWidth(scales.length * scaleWidth * getDevicePixelRatio());
     730                canvasRef.setState({
     731                    scales: scales
     732                });
     733            }
     734            if (typeof option.exporter === "function")
     735                option.exporter(updateData);
    725736            onContainerScroll.action((e) => {
    726737                canvasRef.setState({scrollLeft: e.target.scrollLeft / getDevicePixelRatio()});
Note: See TracChangeset for help on using the changeset viewer.