This commit updates nanovg's bgfx backend to adopt premultiplied alpha as the default blending mode just like the original nanovg. Both the fragment shader and the `glnvg__convertPaint()` function are updated to match the original nanovg counterpart.
However, the binary file of the fragment shader is built on Mac so DirectX support is missing.
This commit ports nanovg's helper functions for rendering stuff in framebuffer defined in `nanovg_gl_utils.h`. Also, a new `nvgState()` function is created for bgfx backend so it is possible to blend between framebuffers, which feature is long requested but not yet supported in original nanovg. The `nvgState()` function can be called between `nvgBeginFrame()` and `nvgEndFrame()`.
This commit gives custom `CAEAGLLayer` instance a chance to set the `opaque` property through the `style` property. Currently, the `GlContext` implementation for `CAEAGLLayer` always sets the layer's `opaque` property to `true` explicitly no matter what the original value is. Though setting the layer as opaque does help for performance, there are times this option should be turned off by decision. Now the `opaque` property is respected if setting in the `style` dictionary.
This commit fixes the bug that the bgfx does not respect the `devicePixelRatio` parameter passed to nanovg's `nvgBeginFrame()` function. The problem is caused by the `bgfx::setViewRect()` call defined in the `nvgRenderViewport()` function, as it should take size in consideration of the `devicePixelRatio` value.
However, this commit does not fix nanovg's example app because currently there is no easy way to pass the scale value to the `ExampleNanoVG::update()` method as it calls `nvgBeginFrame()`.
This commit moves the additional nanovg functions for bgfx to a separate header file, so it is possible to compile the original nanovg source files with bgfx in a custom build environment.