public void Prepare(PrerollContext context, Layer layer, SKMatrix ctm) { RasterCacheKey <Layer> cache_key = new RasterCacheKey <Layer>(layer, ctm); Entry entry = layer_cache_.First(x => x == cache_key).id(); // I used Linq, that aint going to be good for performance entry.access_count = GlobalMembers.ClampSize(entry.access_count + 1, 0, threshold_); entry.used_this_frame = true; if (!entry.image.is_valid) { entry.image = GlobalMembers.Rasterize(context.gr_context, ctm, context.dst_color_space, checkerboard_images_, layer.paint_bounds(), (SKCanvas canvas) => { Layer.PaintContext paintContext = new Layer.PaintContext(canvas, null, context.texture_registry, context.raster_cache, context.checkerboard_offscreen_layers); layer.Paint(paintContext); }); } }
public void Prepare(PrerollContext context, Layer layer, SKMatrix ctm) { RasterCacheKey <Layer> cache_key = new RasterCacheKey <Layer>(layer, ctm); Entry entry = layer_cache_.First(x => x == cache_key).id(); // I used Linq, that aint going to be good for performance //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: entry.access_count = ClampSize(entry.access_count + 1, 0, threshold_); entry.access_count = GlobalMembers.ClampSize(entry.access_count + 1, 0, threshold_); entry.used_this_frame = true; if (!entry.image.is_valid) { //C++ TO C# CONVERTER TODO TASK: Only lambda expressions having all locals passed by reference can be converted to C#: //ORIGINAL LINE: entry.image = Rasterize(context->gr_context, ctm, context->dst_color_space, checkerboard_images_, layer->paint_bounds(), [layer, context](SKCanvas* canvas) //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: entry.image = GlobalMembers.Rasterize(context.gr_context, ctm, context.dst_color_space, checkerboard_images_, layer.paint_bounds(), (SKCanvas canvas) => { Layer.PaintContext paintContext = new Layer.PaintContext(canvas, null, context.texture_registry, context.raster_cache, context.checkerboard_offscreen_layers); layer.Paint(paintContext); }); } }
// TODO(chinmaygarde): This method must submit the surfaces as soon as paint // tasks are done. However, given that there is no support currently for // Vulkan semaphores, we need to submit all the surfaces after an explicit // CPU wait. Once Vulkan semaphores are available, this method must return // void and the implementation must submit surfaces on its own as soon as the // specific canvas operations are done. public List <SceneUpdateContext.SurfaceProducerSurface> ExecutePaintTasks(CompositorContext.ScopedFrame frame) { TRACE_EVENT0("flutter", "SceneUpdateContext::ExecutePaintTasks"); List <SurfaceProducerSurface> surfaces_to_submit = new List <SurfaceProducerSurface>(); foreach (var task in paint_tasks_) { //FML_DCHECK(task.surface); SKCanvas canvas = task.surface.GetSkiaSurface().Canvas; Layer.PaintContext context = new Layer.PaintContext(canvas, null, frame.context().texture_registry(), frame.context().raster_cache(), false); canvas.RestoreToCount(1); canvas.Save(); canvas.Clear(task.background_color); canvas.Scale(task.scale_x, task.scale_y); canvas.Translate(-task.left, -task.top); foreach (Layer layer in task.layers) { layer.Paint(context); } surfaces_to_submit.Add(task.surface); } paint_tasks_.Clear(); return(surfaces_to_submit); }