This commit fixes#300 and #306 that “control may reach end of non-void function” error occurs in `glnvg_convertBlendFuncFactor()`. The function now returns `GL_INVALID_ENUM` for invalid blend factor and if that happens, `glnvg__blendCompositeOperation()` uses default source-over composite operation.
This commit implements the `nvgGlobalCompositeOperation()` function to support blending between frames. All operations defined in HTML5 canvas API are supported. Also, it is possible to create custom composite operation by calling `nvgBlendFunc()` or `nvgBlendFuncSeparate()` functions.
This commit updates the `nvgBeginFrame()` function to forward the received `devicePixelRatio` parameter to the `renderViewport()` function so it is possible to configure the environemnt correctly when using `bgfx` backend.
The `NVGLUframebuffer` structure contains a `ctx` member but was actually never used. This commit takes advantage of the `ctx` property so there is no need to keep the reference of the context elsewhere after calling `nvgluCreateFramebuffer()`, or it would add difficulty for maintenance. As a result, the `nvgluDeleteFramebuffer()` function only needs to take one `NVGLUframebuffer` instance as the parameter.
It guards addPoint from "stealing" the point from the previous path if they're the same, which makes it break when you do something like this:
```
moveTo(50, 50)
moveTo(50, 50)
lineTo(100, 100)
```
Before the fix there's no line shown. With the second moveTo, there's a second path added, but without the 50,50 point, because it was already added with the first moveTo. This makes the second path only contain the point 100,100 so it doesn't draw at all.
After the fix, the point equality check is ignored for the first point in the path, so the second path gets the 50,50 point too and that makes it behave as expected.
This is only one solution to the duplicated moveTo problem and it's likely not the best one, but it's one that's easy to add and it seems to work just fine.
The framebuffer and renderbuffer did restore in `nvgluCreateFramebuffer()` on succeed. However, they are not restored if error occurs. This commit fixes it.