Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SKGLView much darker than SKCanvasView

My app's main screen is rendered via SKCanvasView. The colors accurately reflect the values I specified in code.

If I swap-in SKGLView (hardware-accelerated version), changing no other code, the result is 60% darker:

    <!--<skia:SKCanvasView PaintSurface="OnCanvasViewPaintSurface" />-->
    <skia:SKGLView PaintSurface="OnCanvasViewPaintSurface" />

Why is this happening and how do I fix it?

like image 858
Mud Avatar asked Sep 14 '17 22:09

Mud


1 Answers

The answer can be found here: https://github.com/mono/SkiaSharp/issues/299#issuecomment-331990904

I found the solution to the problem. There is a specific attribute that is set in the splash screen style, but is not unset (for some reason) when the style is changed.

In the splashscreen style, note this:

<item name="android:backgroundDimEnabled">true</item>

Docs: https://developer.xamarin.com/api/field/Android.Resource+Attribute.BackgroundDimEnabled

This is not unset when the style is switched. So, to fix this, just set it to false:

<item name="android:backgroundDimEnabled">false</item>

Here is a repository that demonstrates this: https://github.com/mattleibow/AndroidGLSurfaceViewTests

like image 105
Matthew Avatar answered Nov 08 '22 11:11

Matthew