A while back webkit (and thus Safari) began to support CSS canvas-backgrounds for elements (Source: http://www.webkit.org/blog/176/css-canvas-drawing/).
This could greatly simplify the creation of games and multimedia, in that you dont need to inject a canvas-tag into a DIV (for instance), but simply hook into the background of the DIV directly. Something like this perhaps:
<div id="gameview"
style="background: -webkit-canvas(myscreen); width: 320px; height: 480px;">
</div>
<script>
var target = document.getElementById("gameview");
var wd = target.clientWidth;
var hd = target.clientHeight;
var context = document.getCSSCanvasContext("2d", "myscreen", wd, hd);
/* draw stuff here */
</script>
I was wondering, are there any speed penalties involved in this? In theory i think drawing to a background canvas should be faster than drawing to a canvas tag, especially if the target element is empty.
Have anyone tested this for high-speed demos or games?
Regular seems to underperform compared to background canvas in my tests on chrome in linux debian, heres the code used ( also added to http://jsfiddle.net/hDPVr/ )
So the only thing that I did for testing is fillRect, but it’s still at least 10% better in some cases