1// Copyright 2013 The Flutter Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5part of engine; 6 7/// A class that can rasterize [LayerTree]s into a given [Surface]. 8class Rasterizer { 9 final Surface surface; 10 final CompositorContext context = CompositorContext(); 11 12 Rasterizer(this.surface); 13 14 /// Creates a new frame from this rasterizer's surface, draws the given 15 /// [LayerTree] into it, and then submits the frame. 16 void draw(LayerTree layerTree) { 17 final SurfaceFrame frame = surface.acquireFrame(ui.window.physicalSize); 18 final SkCanvas canvas = frame.canvas; 19 final Frame compositorFrame = context.acquireFrame(canvas); 20 21 canvas.clear(); 22 23 compositorFrame.raster(layerTree, ignoreRasterCache: true); 24 frame.submit(); 25 } 26} 27