예제 #1
0
        public bool is_valid => image_ != null; //?? I'm not sure if this is right


        //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
        //ORIGINAL LINE: void draw(SKCanvas& canvas, const SKPaint* paint = null) const
        public void draw(SKCanvas canvas, SKPaint paint = null)
        {
            var bounds = RasterCache.GetDeviceBounds(logical_rect_, canvas.TotalMatrix);

            canvas.ResetMatrix();
            canvas.DrawImage(image_, bounds.Left, bounds.Top, paint);
        }
예제 #2
0
        public bool is_valid => image_ != null; //?? I'm not sure if this is right
        //{
        //    return (bool)image_;
        //}

        //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
        //ORIGINAL LINE: void draw(SKCanvas& canvas, const SKPaint* paint = null) const
        public void draw(SKCanvas canvas, SKPaint paint = null)
        {
            //C++ TO C# CONVERTER TODO TASK: There is no equivalent in C# to 'static_assert':
            //  (...) static_assert(false, "missing name for " "SkAutoCanvasRestore") auto_restore(&canvas, true);
            var bounds = RasterCache.GetDeviceBounds(logical_rect_, canvas.TotalMatrix);

            //FML_DCHECK(bounds.Size == image_..dimensions());
            canvas.ResetMatrix();
            canvas.DrawImage(image_, bounds.Left, bounds.Top, paint);
        }
예제 #3
0
        internal static RasterCacheResult Rasterize(GRContext context, SKMatrix ctm, SKColorSpace dst_color_space, bool checkerboard, SKRect logical_rect, Action <SKCanvas> draw_function)
        {
            SKRectI cache_rect = RasterCache.GetDeviceBounds(logical_rect, ctm);

            SKImageInfo image_info = new SKImageInfo(cache_rect.Width, cache_rect.Height);

            SKSurface surface = context != null?SKSurface.CreateAsRenderTarget(context, new GRGlBackendTextureDesc()
            {
                Width = cache_rect.Width, Height = cache_rect.Height
            }) : SKSurface.Create(image_info);                                                                                                                                                                    //{ image_info.

            if (surface == null)
            {
                return(new RasterCacheResult());
            }

            SKCanvas canvas      = surface.Canvas;
            SKCanvas xformCanvas = canvas;

            //if (dst_color_space != null)
            //{
            //    xformCanvas = SkCreateColorSpaceXformCanvas(canvas, GlobalMembers.sk_ref_sp(dst_color_space));
            //    if (xformCanvas != null)
            //    {
            //        canvas = xformCanvas;
            //    }
            //}

            canvas.Clear(GlobalMembers.SK_ColorTRANSPARENT);
            canvas.Translate(-cache_rect.Left, -cache_rect.Top);
            canvas.Concat(ref ctm);
            draw_function(canvas);

            //if (checkerboard)
            //{
            //    DrawCheckerboard(canvas, logical_rect);
            //}

            return(new RasterCacheResult(surface.Snapshot(), logical_rect));
        }