Пример #1
0
        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);
                });
            }
        }
Пример #2
0
        // Return true if the cache is generated.
        //
        // We may return false and not generate the cache if
        // 1. The picture is not worth rasterizing
        // 2. The matrix is singular
        // 3. The picture is accessed too few times
        public bool Prepare(GRContext context, SKPicture picture, SKMatrix transformation_matrix, SKColorSpace dst_color_space, bool is_complex, bool will_change)
        {
            if (!GlobalMembers.IsPictureWorthRasterizing(picture, will_change, is_complex))
            {
                // We only deal with pictures that are worthy of rasterization.
                return(false);
            }

            // Decompose the matrix (once) for all subsequent operations. We want to make
            // sure to avoid volumetric distortions while accounting for scaling.
            //MatrixDecomposition matrix = new MatrixDecomposition(transformation_matrix);

            //if (!matrix.IsValid())
            //{
            //    // The matrix was singular. No point in going further.
            //    return false;
            //}

            RasterCacheKey <UniqueEntry> cache_key = new RasterCacheKey <UniqueEntry>(new UniqueEntry(picture.UniqueId), transformation_matrix);

            Entry entry = picture_cache_.First(x => x.Equals(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.access_count < threshold_ || threshold_ == 0)
            {
                // Frame threshold has not yet been reached.
                return(false);
            }

            if (!entry.image.is_valid)
            {
                //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.image = RasterizePicture(picture, context, transformation_matrix, dst_color_space, checkerboard_images_);
                entry.image = GlobalMembers.RasterizePicture(picture, context, transformation_matrix, dst_color_space, checkerboard_images_);
            }
            return(true);
        }
Пример #3
0
        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);
                });
            }
        }