Changeset 286610 in webkit
- Timestamp:
- Dec 7, 2021, 12:51:03 PM (5 years ago)
- Location:
- trunk/Websites/webkit.org
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
blog-files/wide-gamut-canvas/puzzle.html (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Websites/webkit.org/ChangeLog
r286608 r286610 1 2021-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 1 10 2021-12-07 Cameron McCormack <heycam@apple.com> 2 11 -
trunk/Websites/webkit.org/blog-files/wide-gamut-canvas/puzzle.html
r286608 r286610 32 32 const TILE_CORNER_RADIUS = 8; 33 33 34 let supported = false; 34 35 let width, height, board, blank; 35 36 let canvas, ctx; … … 69 70 } 70 71 72 function 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 71 82 function init() { 83 supported = canvasSupportsDisplayP3(); 84 if (!supported) 85 document.body.className = "unsupported"; 86 72 87 canvas = placeholder; 73 88 width = image.naturalWidth; … … 164 179 165 180 function updateCanvas() { 166 let colorSpace = displayP3.checked ? "display-p3" : "srgb";181 let colorSpace = displayP3.checked && supported ? "display-p3" : "srgb"; 167 182 168 183 let newCanvas = cachedCanvases[colorSpace]; … … 183 198 canvas.style.height = `${height / scale}px`; 184 199 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 }); 191 201 192 202 drawBoard();
Note:
See TracChangeset
for help on using the changeset viewer.