Moved D2D code out of CanvasImpl