⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286610 in webkit


Ignore:
Timestamp:
Dec 7, 2021, 12:51:03 PM (5 years ago)
Author:
Cameron McCormack
Message:

Puzzle feature detection followup
https://bugs.webkit.org/show_bug.cgi?id=233946

Unreviewed.

  • blog-files/wide-gamut-canvas/puzzle.html:
Location:
trunk/Websites/webkit.org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Websites/webkit.org/ChangeLog

    r286608 r286610  
     12021-12-07  Cameron McCormack  <heycam@apple.com>
     2
     3        Puzzle feature detection followup
     4        https://bugs.webkit.org/show_bug.cgi?id=233946
     5
     6        Unreviewed.
     7
     8        * blog-files/wide-gamut-canvas/puzzle.html:
     9
    1102021-12-07  Cameron McCormack  <heycam@apple.com>
    211
  • trunk/Websites/webkit.org/blog-files/wide-gamut-canvas/puzzle.html

    r286608 r286610  
    3232const TILE_CORNER_RADIUS = 8;
    3333
     34let supported = false;
    3435let width, height, board, blank;
    3536let canvas, ctx;
     
    6970}
    7071
     72function canvasSupportsDisplayP3() {
     73    let canvas = document.createElement("canvas");
     74    try {
     75        let context = canvas.getContext("2d", { colorSpace: "display-p3" });
     76        return context.getContextAttributes().colorSpace == "display-p3";
     77    } catch {
     78    }
     79    return false;
     80}
     81
    7182function init() {
     83    supported = canvasSupportsDisplayP3();
     84    if (!supported)
     85        document.body.className = "unsupported";
     86
    7287    canvas = placeholder;
    7388    width = image.naturalWidth;
     
    164179
    165180function updateCanvas() {
    166     let colorSpace = displayP3.checked ? "display-p3" : "srgb";
     181    let colorSpace = displayP3.checked && supported ? "display-p3" : "srgb";
    167182
    168183    let newCanvas = cachedCanvases[colorSpace];
     
    183198    canvas.style.height = `${height / scale}px`;
    184199
    185     try {
    186         ctx = canvas.getContext("2d", { colorSpace });
    187     } catch {
    188         ctx = canvas.getContext("2d");
    189         document.body.className = "unsupported";
    190     }
     200    ctx = canvas.getContext("2d", { colorSpace });
    191201
    192202    drawBoard();
Note: See TracChangeset for help on using the changeset viewer.