aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-07-19 13:55:12 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-07-19 13:55:12 +0200
commit14c56cc6b6881c65b1a10692ffcb64276bf6bacd (patch)
tree0af2de7a20a2ec2cd1df3ef100c7d46309d5a298
parentf2eee8a53fc148e3c860d3667af7ba69ba0b19d2 (diff)
downloadd2tk-14c56cc6b6881c65b1a10692ffcb64276bf6bacd.zip
d2tk-14c56cc6b6881c65b1a10692ffcb64276bf6bacd.tar.gz
d2tk-14c56cc6b6881c65b1a10692ffcb64276bf6bacd.tar.bz2
d2tk-14c56cc6b6881c65b1a10692ffcb64276bf6bacd.tar.xz
Squashed 'nanovg/' changes from 1fd049e..75dbf61
75dbf61 omk: add support for ARGB image surfaces. git-subtree-dir: nanovg git-subtree-split: 75dbf615b2b7b3436ef43dc2c8bf5616fd3df3fb
-rw-r--r--src/nanovg.c5
-rw-r--r--src/nanovg.h5
-rw-r--r--src/nanovg_gl.h10
3 files changed, 20 insertions, 0 deletions
diff --git a/src/nanovg.c b/src/nanovg.c
index 1ab49f0..f82f76c 100644
--- a/src/nanovg.c
+++ b/src/nanovg.c
@@ -829,6 +829,11 @@ int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsi
return ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_RGBA, w, h, imageFlags, data);
}
+int nvgCreateImageARGB(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data)
+{
+ return ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_ARGB, w, h, imageFlags, data);
+}
+
void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data)
{
int w, h;
diff --git a/src/nanovg.h b/src/nanovg.h
index 2255d6a..e3d7ee1 100644
--- a/src/nanovg.h
+++ b/src/nanovg.h
@@ -379,6 +379,10 @@ int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int
// Returns handle to the image.
int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data);
+// Creates image from specified image data.
+// Returns handle to the image.
+int nvgCreateImageARGB(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data);
+
// Updates image data specified by image handle.
void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data);
@@ -618,6 +622,7 @@ int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, floa
enum NVGtexture {
NVG_TEXTURE_ALPHA = 0x01,
NVG_TEXTURE_RGBA = 0x02,
+ NVG_TEXTURE_ARGB = 0x03,
};
struct NVGscissor {
diff --git a/src/nanovg_gl.h b/src/nanovg_gl.h
index 5292181..75d51e9 100644
--- a/src/nanovg_gl.h
+++ b/src/nanovg_gl.h
@@ -753,6 +753,8 @@ static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, int im
if (type == NVG_TEXTURE_RGBA)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ else if (type == NVG_TEXTURE_ARGB)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, data);
else
#if defined(NANOVG_GLES2) || defined (NANOVG_GL2)
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
@@ -837,6 +839,8 @@ static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w
// No support for all of skip, need to update a whole row at a time.
if (tex->type == NVG_TEXTURE_RGBA)
data += y*tex->width*4;
+ else if (tex->type == NVG_TEXTURE_ARGB)
+ data += y*tex->width*4;
else
data += y*tex->width;
x = 0;
@@ -845,6 +849,8 @@ static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w
if (tex->type == NVG_TEXTURE_RGBA)
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ else if (tex->type == NVG_TEXTURE_ARGB)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_BGRA, GL_UNSIGNED_BYTE, data);
else
#if defined(NANOVG_GLES2) || defined(NANOVG_GL2)
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
@@ -948,11 +954,15 @@ static int glnvg__convertPaint(GLNVGcontext* gl, GLNVGfragUniforms* frag, NVGpai
#if NANOVG_GL_USE_UNIFORMBUFFER
if (tex->type == NVG_TEXTURE_RGBA)
frag->texType = (tex->flags & NVG_IMAGE_PREMULTIPLIED) ? 0 : 1;
+ else if (tex->type == NVG_TEXTURE_ARGB)
+ frag->texType = (tex->flags & NVG_IMAGE_PREMULTIPLIED) ? 0 : 1;
else
frag->texType = 2;
#else
if (tex->type == NVG_TEXTURE_RGBA)
frag->texType = (tex->flags & NVG_IMAGE_PREMULTIPLIED) ? 0.0f : 1.0f;
+ else if (tex->type == NVG_TEXTURE_ARGB)
+ frag->texType = (tex->flags & NVG_IMAGE_PREMULTIPLIED) ? 0.0f : 1.0f;
else
frag->texType = 2.0f;
#endif