Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/7d5c449389162c3b11cecc0b4a969d50a693c8b1
...commit
http://git.netsurf-browser.org/netsurf.git/commit/7d5c449389162c3b11cecc0b4a969d50a693c8b1
...tree
http://git.netsurf-browser.org/netsurf.git/tree/7d5c449389162c3b11cecc0b4a969d50a693c8b1
The branch, master has been updated
via 7d5c449389162c3b11cecc0b4a969d50a693c8b1 (commit)
from 8e56cc3b1a0d9d18e35811a015cf42b57ede1025 (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 -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=7d5c449389162c3b11cecc0b4a969d50a693c8b1
commit 7d5c449389162c3b11cecc0b4a969d50a693c8b1
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
GTK: Simplify opaque bitmap handling.
Avoid creating new bitmaps and copying in set_opaque by always
using an RGBA format.
diff --git a/frontends/gtk/bitmap.c b/frontends/gtk/bitmap.c
index 595d5ea..bfd29e1 100644
--- a/frontends/gtk/bitmap.c
+++ b/frontends/gtk/bitmap.c
@@ -55,12 +55,11 @@ static void *bitmap_create(int width, int height, enum
gui_bitmap_flags flags)
gbitmap = calloc(1, sizeof(struct bitmap));
if (gbitmap != NULL) {
- if ((flags & BITMAP_OPAQUE) != 0) {
- gbitmap->surface =
cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
- } else {
- gbitmap->surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
+ if (flags & BITMAP_OPAQUE) {
+ gbitmap->opaque = true;
}
+ gbitmap->surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
if (cairo_surface_status(gbitmap->surface) !=
CAIRO_STATUS_SUCCESS) {
cairo_surface_destroy(gbitmap->surface);
free(gbitmap);
@@ -81,46 +80,8 @@ static void *bitmap_create(int width, int height, enum
gui_bitmap_flags flags)
static void bitmap_set_opaque(void *vbitmap, bool opaque)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
- cairo_format_t fmt;
- cairo_surface_t *nsurface = NULL;
- assert(gbitmap);
-
- fmt = cairo_image_surface_get_format(gbitmap->surface);
- if (fmt == CAIRO_FORMAT_RGB24) {
- if (opaque == false) {
- /* opaque to transparent */
- nsurface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
-
cairo_image_surface_get_width(gbitmap->surface),
-
cairo_image_surface_get_height(gbitmap->surface));
-
- }
-
- } else {
- if (opaque == true) {
- /* transparent to opaque */
- nsurface =
cairo_image_surface_create(CAIRO_FORMAT_RGB24,
-
cairo_image_surface_get_width(gbitmap->surface),
-
cairo_image_surface_get_height(gbitmap->surface));
-
- }
- }
-
- if (nsurface != NULL) {
- if (cairo_surface_status(nsurface) != CAIRO_STATUS_SUCCESS) {
- cairo_surface_destroy(nsurface);
- } else {
- memcpy(cairo_image_surface_get_data(nsurface),
- cairo_image_surface_get_data(gbitmap->surface),
- cairo_image_surface_get_stride(gbitmap->surface)
* cairo_image_surface_get_height(gbitmap->surface));
- cairo_surface_destroy(gbitmap->surface);
- gbitmap->surface = nsurface;
-
- cairo_surface_mark_dirty(gbitmap->surface);
-
- }
-
- }
+ gbitmap->opaque = opaque;
}
@@ -132,16 +93,8 @@ static void bitmap_set_opaque(void *vbitmap, bool opaque)
static bool bitmap_get_opaque(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
- cairo_format_t fmt;
-
- assert(gbitmap);
-
- fmt = cairo_image_surface_get_format(gbitmap->surface);
- if (fmt == CAIRO_FORMAT_RGB24) {
- return true;
- }
- return false;
+ return gbitmap->opaque;
}
diff --git a/frontends/gtk/bitmap.h b/frontends/gtk/bitmap.h
index d899966..80a0e7a 100644
--- a/frontends/gtk/bitmap.h
+++ b/frontends/gtk/bitmap.h
@@ -26,6 +26,7 @@ extern struct gui_bitmap_table *nsgtk_bitmap_table;
struct bitmap {
cairo_surface_t *surface; /* original cairo surface */
cairo_surface_t *scsurface; /* scaled surface */
+ bool opaque;
};
int nsgtk_bitmap_get_width(void *vbitmap);
-----------------------------------------------------------------------
Summary of changes:
frontends/gtk/bitmap.c | 57 +++++-------------------------------------------
frontends/gtk/bitmap.h | 1 +
2 files changed, 6 insertions(+), 52 deletions(-)
diff --git a/frontends/gtk/bitmap.c b/frontends/gtk/bitmap.c
index 595d5ea..bfd29e1 100644
--- a/frontends/gtk/bitmap.c
+++ b/frontends/gtk/bitmap.c
@@ -55,12 +55,11 @@ static void *bitmap_create(int width, int height, enum
gui_bitmap_flags flags)
gbitmap = calloc(1, sizeof(struct bitmap));
if (gbitmap != NULL) {
- if ((flags & BITMAP_OPAQUE) != 0) {
- gbitmap->surface =
cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
- } else {
- gbitmap->surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
+ if (flags & BITMAP_OPAQUE) {
+ gbitmap->opaque = true;
}
+ gbitmap->surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
if (cairo_surface_status(gbitmap->surface) !=
CAIRO_STATUS_SUCCESS) {
cairo_surface_destroy(gbitmap->surface);
free(gbitmap);
@@ -81,46 +80,8 @@ static void *bitmap_create(int width, int height, enum
gui_bitmap_flags flags)
static void bitmap_set_opaque(void *vbitmap, bool opaque)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
- cairo_format_t fmt;
- cairo_surface_t *nsurface = NULL;
- assert(gbitmap);
-
- fmt = cairo_image_surface_get_format(gbitmap->surface);
- if (fmt == CAIRO_FORMAT_RGB24) {
- if (opaque == false) {
- /* opaque to transparent */
- nsurface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
-
cairo_image_surface_get_width(gbitmap->surface),
-
cairo_image_surface_get_height(gbitmap->surface));
-
- }
-
- } else {
- if (opaque == true) {
- /* transparent to opaque */
- nsurface =
cairo_image_surface_create(CAIRO_FORMAT_RGB24,
-
cairo_image_surface_get_width(gbitmap->surface),
-
cairo_image_surface_get_height(gbitmap->surface));
-
- }
- }
-
- if (nsurface != NULL) {
- if (cairo_surface_status(nsurface) != CAIRO_STATUS_SUCCESS) {
- cairo_surface_destroy(nsurface);
- } else {
- memcpy(cairo_image_surface_get_data(nsurface),
- cairo_image_surface_get_data(gbitmap->surface),
- cairo_image_surface_get_stride(gbitmap->surface)
* cairo_image_surface_get_height(gbitmap->surface));
- cairo_surface_destroy(gbitmap->surface);
- gbitmap->surface = nsurface;
-
- cairo_surface_mark_dirty(gbitmap->surface);
-
- }
-
- }
+ gbitmap->opaque = opaque;
}
@@ -132,16 +93,8 @@ static void bitmap_set_opaque(void *vbitmap, bool opaque)
static bool bitmap_get_opaque(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
- cairo_format_t fmt;
-
- assert(gbitmap);
-
- fmt = cairo_image_surface_get_format(gbitmap->surface);
- if (fmt == CAIRO_FORMAT_RGB24) {
- return true;
- }
- return false;
+ return gbitmap->opaque;
}
diff --git a/frontends/gtk/bitmap.h b/frontends/gtk/bitmap.h
index d899966..80a0e7a 100644
--- a/frontends/gtk/bitmap.h
+++ b/frontends/gtk/bitmap.h
@@ -26,6 +26,7 @@ extern struct gui_bitmap_table *nsgtk_bitmap_table;
struct bitmap {
cairo_surface_t *surface; /* original cairo surface */
cairo_surface_t *scsurface; /* scaled surface */
+ bool opaque;
};
int nsgtk_bitmap_get_width(void *vbitmap);
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]