public void Render(LayerTree layer_tree) { if (layer_tree == null) { return; } SKSizeI frame_size = new SKSizeI((int)_physicalWidth, (int)_physicalHeight); if (frame_size.IsEmpty) { return; } layer_tree.set_frame_size(frame_size); var picture = layer_tree.Flatten(new SKRect(0, 0, frame_size.Width, frame_size.Height)); _canvas.DrawPicture(picture); }
public string ToImage(int width, int height, _Callback <SKImage> raw_image_callback) { if (raw_image_callback == null) { return("Image callback was invalid"); } if (m_layerTree == null) { return("Scene did not contain a layer tree."); } if (width == 0 || height == 0) { return("Image dimensions for scene were invalid."); } // We can't create an image on this task runner because we don't have a // graphics context. Even if we did, it would be slow anyway. Also, this // thread owns the sole reference to the layer tree. So we flatten the layer // tree into a picture and use that as the thread transport mechanism. var picture = m_layerTree.Flatten(new SKRect(0, 0, width, height)); if (picture == null) { // Already in Dart scope. return("Could not flatten scene into a layer tree."); } var image = SKImage.FromPicture(picture, new SKSizeI(width, height)); raw_image_callback(image); return(string.Empty); }