问题
Is there a setting for the canvas context that will prevent its renderer from using hardware acceleration? I want to render without it, but don't want to ask the user to disable it from their chrome browser since that is counter-intuitive and doesn't provide a seamless workflow experience.
回答1:
Short Answer:
No, but it is at least being considered by those developing Chromium. MDN: CanvasContext2D In the page you'll find an internal method called demote
.
Long Answer:
There's nothing standaradized currently, and the only method available from a 2D context to perform this (demote
) is Chrome-Context (chromium) only.
Per MDN:
CanvasRenderingContext2D.demote() This causes a context that is currently using a hardware-accelerated backend to fallback to a software one. All state should be preserved.
It's apparent they've considered it, but I wouldn't expect it to be adopted any time soon as it is probably not a prioritized topic of discussion/pain-point. Furthermore, unfortunately since it's a Chrome specific implementation and we're dealing with altering the way the Browser itself behaves, there isn't a way to patch this functionality into other Browsers through polyfilling or shimming.
Conclusion:
The technical answer is maybe. It depends on the Browser you're targeting supporting a non-standardized feature that won't be standardized soon(or possibly ever), and your willingness to not support any other Browser. That being said, the pragmatic answer is no
Hope this helps!
来源:https://stackoverflow.com/questions/55503156/canvas-context-property-to-prevent-hardware-accelerated-rendering