Forum Libraries, Components, and Plugins

Rendering Image Layers

DavidLedgerDavidLedger AUMember ✭✭

Hello Again!

I'm rendering images in layers ontop of each other on an SKGLView. The draw calls work as expected most of the time in android but some of the time it seems like one is skipped. This is pretty bad because I'm differentially rendering to minimize the redrawing of layers and if one of the draw calls fails without warning then the result is exactly not what I want drawn.

Using the following:

        var transparency            = Color.FromRgba(0, 0, 0, 0).ToSKColor();
        mDrawPaint                  = new SKPaint();
        mDrawPaint.BlendMode        = SKBlendMode.SrcOver;
        mDrawPaint.ColorFilter      = SKColorFilter.CreateBlendMode(transparency, SKBlendMode.DstOver);

        mUndrawPaint                = new SKPaint();
        mUndrawPaint.BlendMode      = SKBlendMode.DstOut;
        mUndrawPaint.ColorFilter    = SKColorFilter.CreateBlendMode(transparency, SKBlendMode.DstOver);

The following is called per layer:

    public void Render(ref SKCanvas pSurface)
    {
        //This is render changed variable, don't move it to set, that is wrong
        if (_RenderChanged.Update(ref mActive))
        {
            if (mActive)
                pSurface.DrawImage(mImage, 0, 0, mDrawPaint);
            else
                pSurface.DrawImage(mImage, 0, 0, mUndrawPaint);
        }
}

On windows with CanvasView the system works perfectly, otherwise it skips layers. I have tried rendering through various sources and different image draw calls, all have the same skipping issue.

I think it is something todo with the way the buffer is handled but i'm not sure.

Best Answers

  • DavidLedgerDavidLedger AUMember ✭✭
    Accepted Answer

    I tried to do locking and whatnot but the problem persisted. I think its a problem that I need to work around because of the render pattern. I have implemented an SVG to path converter that solved the speed issue. I cannot use the canvas because of the speed hit.

    I have switched to rendering paths instead because this problem persisted despite my efforts. Thanks for the help. Canvas does fix the issue but the performance hit is too much.

Answers

  • DavidLedgerDavidLedger AUMember ✭✭
    Accepted Answer

    I tried to do locking and whatnot but the problem persisted. I think its a problem that I need to work around because of the render pattern. I have implemented an SVG to path converter that solved the speed issue. I cannot use the canvas because of the speed hit.

    I have switched to rendering paths instead because this problem persisted despite my efforts. Thanks for the help. Canvas does fix the issue but the performance hit is too much.

Sign In or Register to comment.