This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 64f27b70dc6f1ae231c627ac30beda08aef45a7b (commit) via f30503b333e5373c182ec8a7122edc8fea1140e3 (commit) from be0a281e8050b1bd51dfd575d6f9d3296c521b88 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/64f27b70dc6f1ae231c627ac30beda08aef45...
commit 64f27b70dc6f1ae231c627ac30beda08aef45a7b Author: Cyril Hrubis metan@ucw.cz Date: Wed May 9 00:48:00 2012 +0200
backends: Do not reset rotation flags on resize.
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c index ae0e8c6..3923619 100644 --- a/libs/backends/GP_SDL.c +++ b/libs/backends/GP_SDL.c @@ -111,11 +111,6 @@ int context_from_surface(GP_Context *context, SDL_Surface *surf) context->w = surf->w; context->h = surf->h;
- /* orientation */ - context->axes_swap = 0; - context->x_swap = 0; - context->y_swap = 0; - return 0; }
@@ -196,7 +191,7 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags, SDL_Quit(); return NULL; } - + backend.context = &context; }
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index 8f9b519..fb95a52 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -138,7 +138,6 @@ static int x11_set_attributes(struct GP_Backend *self, }
if (w != 0 || h != 0) { - GP_Context *context; XImage *img;
if (w == 0) @@ -154,20 +153,17 @@ static int x11_set_attributes(struct GP_Backend *self, w, h, 32, 0);
/* Allocate new context */ - context = GP_ContextAlloc(w, h, GP_PIXEL_xRGB8888); - if (context == NULL) { + if (GP_ContextResize(self->context, w, h)) { XDestroyImage(img); return 1; }
- /* Free old image and context */ - GP_ContextFree(self->context); + /* Free old image */ x11->img->data = NULL; XDestroyImage(x11->img);
/* Swap the pointers */ - self->context = context; img->data = (char*)self->context->pixels; x11->img = img;
http://repo.or.cz/w/gfxprim.git/commit/f30503b333e5373c182ec8a7122edc8fea114...
commit f30503b333e5373c182ec8a7122edc8fea1140e3 Author: Cyril Hrubis metan@ucw.cz Date: Wed May 9 00:47:42 2012 +0200
core: Add GP_ContextResize().
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index a6b76df..95a6863 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -106,6 +106,13 @@ void GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h, GP_PixelType type, void *pixels);
/* + * Resizes context->pixels array and changes metadata to match. + * + * Returns non-zero on failure (remalloc() has failed). + */ +int GP_ContextResize(GP_Context *context, GP_Size w, GP_Size h); + +/* * If passed the pixels are copied to newly created context, otherwise * the pixels are allocated but uninitalized. */ diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index 87a44d1..967edcb 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -70,12 +70,17 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flag) return new; }
+static uint32_t get_bpr(uint32_t bpp, uint32_t w) +{ + return (bpp * w) / 8 + !!((bpp * w) % 8); +} + GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) { GP_CHECK_VALID_PIXELTYPE(type); GP_Context *context = malloc(sizeof(GP_Context)); uint32_t bpp = GP_PixelSize(type); - uint32_t bpr = (bpp * w) / 8 + !!((bpp * w) % 8); + uint32_t bpr = get_bpr(bpp, w); void *pixels;
pixels = malloc(bpr * h); @@ -108,11 +113,29 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) return context; }
+int GP_ContextResize(GP_Context *context, GP_Size w, GP_Size h) +{ + uint32_t bpr = get_bpr(context->bpp, w); + void *pixels; + + pixels = realloc(context->pixels, bpr * h); + + if (pixels == NULL) + return 1; + + context->w = w; + context->h = h; + context->bytes_per_row = bpr; + context->pixels = pixels; + + return 0; +} + void GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h, GP_PixelType type, void *pixels) { uint32_t bpp = GP_PixelSize(type); - uint32_t bpr = (bpp * w) / 8 + !!((bpp * w) % 8); + uint32_t bpr = get_bpr(bpp, w);
context->pixels = pixels; context->bpp = bpp;
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Context.h | 7 +++++++ libs/backends/GP_SDL.c | 7 +------ libs/backends/GP_X11.c | 8 ++------ libs/core/GP_Context.c | 27 +++++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 14 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.