netsurf: branch master updated. release/3.3-94-g8f41764
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8f41764268032d4286ede...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8f41764268032d4286ede2d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8f41764268032d4286ede2d27...
The branch, master has been updated
via 8f41764268032d4286ede2d27f1bf106effc99f8 (commit)
from 10f621441f29c1f4e8b612e57f3619debc2b6808 (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=8f41764268032d4286e...
commit 8f41764268032d4286ede2d27f1bf106effc99f8
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Remove unecessary includes from RISC OS bitmap header.
The RISC OS bitmap header was including several headers it simply did
not require. This removed those includes and also cleans up the
documentation comments to completely cover the exported interface.
diff --git a/riscos/bitmap.c b/riscos/bitmap.c
index c232f20..6e1b9cc 100644
--- a/riscos/bitmap.c
+++ b/riscos/bitmap.c
@@ -103,14 +103,7 @@ static bool bitmap_initialise(struct bitmap *bitmap)
}
-/**
- * Create a bitmap.
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \param state the state to create the bitmap in.
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
+/* exported interface documented in riscos/bitmap.h */
void *riscos_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
@@ -129,15 +122,7 @@ void *riscos_bitmap_create(int width, int height, unsigned int state)
}
-/**
- * Return a pointer to the pixel data in a bitmap.
- *
- * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
- * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- */
+/* exported interface documented in riscos/bitmap.h */
unsigned char *riscos_bitmap_get_buffer(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -175,12 +160,7 @@ static void bitmap_set_opaque(void *vbitmap, bool opaque)
}
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
+/* exported interface documented in riscos/bitmap.h */
size_t riscos_bitmap_get_rowstride(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -237,11 +217,7 @@ static bool bitmap_test_opaque(void *vbitmap)
}
-/**
- * Gets whether a bitmap should be plotted opaque
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- */
+/* exported interface documented in riscos/bitmap.h */
bool riscos_bitmap_get_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -250,11 +226,7 @@ bool riscos_bitmap_get_opaque(void *vbitmap)
}
-/**
- * Free a bitmap.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- */
+/* exported interface documented in riscos/bitmap.h */
void riscos_bitmap_destroy(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -270,14 +242,7 @@ void riscos_bitmap_destroy(void *vbitmap)
}
-/**
- * Save a bitmap in the platform's native format.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \param path pathname for file
- * \param flags modify the behaviour of the save
- * \return true on success, false on error and error reported
- */
+/* exported interface documented in riscos/bitmap.h */
bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -443,11 +408,7 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
}
-/**
- * The bitmap image has changed, so flush any persistent cache.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- */
+/* exported interface documented in riscos/bitmap.h */
void riscos_bitmap_modified(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -455,6 +416,7 @@ void riscos_bitmap_modified(void *vbitmap)
}
+/* exported interface documented in riscos/bitmap.h */
int riscos_bitmap_get_width(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -462,6 +424,7 @@ int riscos_bitmap_get_width(void *vbitmap)
}
+/* exported interface documented in riscos/bitmap.h */
int riscos_bitmap_get_height(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -482,13 +445,10 @@ static size_t bitmap_get_bpp(void *vbitmap)
return 4;
}
-/**
- * Overlay a sprite onto the given bitmap
- *
- * \param bitmap bitmap object
- * \param s 8bpp sprite to be overlayed onto bitmap
- */
-void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
+
+/* exported interface documented in riscos/bitmap.h */
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap,
+ const osspriteop_header *s)
{
const os_colour *palette;
const byte *sp, *mp;
diff --git a/riscos/bitmap.h b/riscos/bitmap.h
index 1ae50fd..36eaea6 100644
--- a/riscos/bitmap.h
+++ b/riscos/bitmap.h
@@ -19,36 +19,113 @@
#ifndef _NETSURF_RISCOS_BITMAP_H_
#define _NETSURF_RISCOS_BITMAP_H_
+struct osspriteop_area;
+struct osspriteop_header;
+
/** bitmap operations table */
struct gui_bitmap_table *riscos_bitmap_table;
-#include <stdbool.h>
-#include "oslib/osspriteop.h"
-#include "image/bitmap.h"
-
/** save with full alpha channel (if not opaque) */
-#define BITMAP_SAVE_FULL_ALPHA (1 << 0)
-
-struct osspriteop_area;
+#define BITMAP_SAVE_FULL_ALPHA (1 << 0)
+/**
+ * RISC OS wimp toolkit bitmap.
+ */
struct bitmap {
- int width;
- int height;
+ int width; /**< width of bitmap */
+ int height; /**< height of bitmap */
- unsigned int state;
+ unsigned int state; /**< The bitmap attributes (opaque/dirty etc.) */
- osspriteop_area *sprite_area; /** Uncompressed data, or NULL */
+ struct osspriteop_area *sprite_area; /**< Uncompressed data, or NULL */
};
-void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s);
-void riscos_bitmap_destroy(void *vbitmap);
+
+/**
+ * Overlay a sprite onto the given bitmap
+ *
+ * \param bitmap bitmap object
+ * \param s 8bpp sprite to be overlayed onto bitmap
+ */
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const struct osspriteop_header *s);
+
+
+/**
+ * Create a bitmap.
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state the state to create the bitmap in.
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
void *riscos_bitmap_create(int width, int height, unsigned int state);
+
+
+/**
+ * Free a bitmap.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ */
+void riscos_bitmap_destroy(void *vbitmap);
+
+/**
+ * Return a pointer to the pixel data in a bitmap.
+ *
+ * The pixel data is packed as BITMAP_FORMAT, possibly with padding at
+ * the end of rows. The width of a row in bytes is given by
+ * riscos_bitmap_get_rowstride().
+ *
+ * \param vbitmap A bitmap as returned by riscos_bitmap_create()
+ * \return pointer to the pixel buffer
+ */
unsigned char *riscos_bitmap_get_buffer(void *vbitmap);
+
+/**
+ * The bitmap image has changed, so flush any persistent cache.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ */
void riscos_bitmap_modified(void *vbitmap);
+
+/**
+ * Get the width of a bitmap.
+ *
+ * \param vbitmap A bitmap, as returned by bitmap_create()
+ * \return The bitmaps width in pixels.
+ */
int riscos_bitmap_get_width(void *vbitmap);
+
+/**
+ * Get the height of a bitmap.
+ *
+ * \param vbitmap A bitmap, as returned by bitmap_create()
+ * \return The bitmaps height in pixels.
+ */
int riscos_bitmap_get_height(void *vbitmap);
+
+/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param vbitmap A bitmap, as returned by riscos_bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
size_t riscos_bitmap_get_rowstride(void *vbitmap);
+
+/**
+ * Gets whether a bitmap should be plotted opaque
+ *
+ * \param vbitmap A bitmap, as returned by riscos_bitmap_create()
+ */
bool riscos_bitmap_get_opaque(void *vbitmap);
+
+/**
+ * Save a bitmap in the platform's native format.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ * \param path pathname for file
+ * \param flags modify the behaviour of the save
+ * \return true on success, false on error and error reported
+ */
bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags);
#endif
-----------------------------------------------------------------------
Summary of changes:
riscos/bitmap.c | 66 +++++++----------------------------
riscos/bitmap.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 103 insertions(+), 66 deletions(-)
diff --git a/riscos/bitmap.c b/riscos/bitmap.c
index c232f20..6e1b9cc 100644
--- a/riscos/bitmap.c
+++ b/riscos/bitmap.c
@@ -103,14 +103,7 @@ static bool bitmap_initialise(struct bitmap *bitmap)
}
-/**
- * Create a bitmap.
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \param state the state to create the bitmap in.
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
+/* exported interface documented in riscos/bitmap.h */
void *riscos_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
@@ -129,15 +122,7 @@ void *riscos_bitmap_create(int width, int height, unsigned int state)
}
-/**
- * Return a pointer to the pixel data in a bitmap.
- *
- * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
- * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- */
+/* exported interface documented in riscos/bitmap.h */
unsigned char *riscos_bitmap_get_buffer(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -175,12 +160,7 @@ static void bitmap_set_opaque(void *vbitmap, bool opaque)
}
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
+/* exported interface documented in riscos/bitmap.h */
size_t riscos_bitmap_get_rowstride(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -237,11 +217,7 @@ static bool bitmap_test_opaque(void *vbitmap)
}
-/**
- * Gets whether a bitmap should be plotted opaque
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- */
+/* exported interface documented in riscos/bitmap.h */
bool riscos_bitmap_get_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -250,11 +226,7 @@ bool riscos_bitmap_get_opaque(void *vbitmap)
}
-/**
- * Free a bitmap.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- */
+/* exported interface documented in riscos/bitmap.h */
void riscos_bitmap_destroy(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -270,14 +242,7 @@ void riscos_bitmap_destroy(void *vbitmap)
}
-/**
- * Save a bitmap in the platform's native format.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \param path pathname for file
- * \param flags modify the behaviour of the save
- * \return true on success, false on error and error reported
- */
+/* exported interface documented in riscos/bitmap.h */
bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -443,11 +408,7 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
}
-/**
- * The bitmap image has changed, so flush any persistent cache.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- */
+/* exported interface documented in riscos/bitmap.h */
void riscos_bitmap_modified(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -455,6 +416,7 @@ void riscos_bitmap_modified(void *vbitmap)
}
+/* exported interface documented in riscos/bitmap.h */
int riscos_bitmap_get_width(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -462,6 +424,7 @@ int riscos_bitmap_get_width(void *vbitmap)
}
+/* exported interface documented in riscos/bitmap.h */
int riscos_bitmap_get_height(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -482,13 +445,10 @@ static size_t bitmap_get_bpp(void *vbitmap)
return 4;
}
-/**
- * Overlay a sprite onto the given bitmap
- *
- * \param bitmap bitmap object
- * \param s 8bpp sprite to be overlayed onto bitmap
- */
-void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
+
+/* exported interface documented in riscos/bitmap.h */
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap,
+ const osspriteop_header *s)
{
const os_colour *palette;
const byte *sp, *mp;
diff --git a/riscos/bitmap.h b/riscos/bitmap.h
index 1ae50fd..36eaea6 100644
--- a/riscos/bitmap.h
+++ b/riscos/bitmap.h
@@ -19,36 +19,113 @@
#ifndef _NETSURF_RISCOS_BITMAP_H_
#define _NETSURF_RISCOS_BITMAP_H_
+struct osspriteop_area;
+struct osspriteop_header;
+
/** bitmap operations table */
struct gui_bitmap_table *riscos_bitmap_table;
-#include <stdbool.h>
-#include "oslib/osspriteop.h"
-#include "image/bitmap.h"
-
/** save with full alpha channel (if not opaque) */
-#define BITMAP_SAVE_FULL_ALPHA (1 << 0)
-
-struct osspriteop_area;
+#define BITMAP_SAVE_FULL_ALPHA (1 << 0)
+/**
+ * RISC OS wimp toolkit bitmap.
+ */
struct bitmap {
- int width;
- int height;
+ int width; /**< width of bitmap */
+ int height; /**< height of bitmap */
- unsigned int state;
+ unsigned int state; /**< The bitmap attributes (opaque/dirty etc.) */
- osspriteop_area *sprite_area; /** Uncompressed data, or NULL */
+ struct osspriteop_area *sprite_area; /**< Uncompressed data, or NULL */
};
-void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s);
-void riscos_bitmap_destroy(void *vbitmap);
+
+/**
+ * Overlay a sprite onto the given bitmap
+ *
+ * \param bitmap bitmap object
+ * \param s 8bpp sprite to be overlayed onto bitmap
+ */
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const struct osspriteop_header *s);
+
+
+/**
+ * Create a bitmap.
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state the state to create the bitmap in.
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
void *riscos_bitmap_create(int width, int height, unsigned int state);
+
+
+/**
+ * Free a bitmap.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ */
+void riscos_bitmap_destroy(void *vbitmap);
+
+/**
+ * Return a pointer to the pixel data in a bitmap.
+ *
+ * The pixel data is packed as BITMAP_FORMAT, possibly with padding at
+ * the end of rows. The width of a row in bytes is given by
+ * riscos_bitmap_get_rowstride().
+ *
+ * \param vbitmap A bitmap as returned by riscos_bitmap_create()
+ * \return pointer to the pixel buffer
+ */
unsigned char *riscos_bitmap_get_buffer(void *vbitmap);
+
+/**
+ * The bitmap image has changed, so flush any persistent cache.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ */
void riscos_bitmap_modified(void *vbitmap);
+
+/**
+ * Get the width of a bitmap.
+ *
+ * \param vbitmap A bitmap, as returned by bitmap_create()
+ * \return The bitmaps width in pixels.
+ */
int riscos_bitmap_get_width(void *vbitmap);
+
+/**
+ * Get the height of a bitmap.
+ *
+ * \param vbitmap A bitmap, as returned by bitmap_create()
+ * \return The bitmaps height in pixels.
+ */
int riscos_bitmap_get_height(void *vbitmap);
+
+/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param vbitmap A bitmap, as returned by riscos_bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
size_t riscos_bitmap_get_rowstride(void *vbitmap);
+
+/**
+ * Gets whether a bitmap should be plotted opaque
+ *
+ * \param vbitmap A bitmap, as returned by riscos_bitmap_create()
+ */
bool riscos_bitmap_get_opaque(void *vbitmap);
+
+/**
+ * Save a bitmap in the platform's native format.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ * \param path pathname for file
+ * \param flags modify the behaviour of the save
+ * \return true on success, false on error and error reported
+ */
bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags);
#endif
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-93-g10f6214
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/10f621441f29c1f4e8b61...
...commit http://git.netsurf-browser.org/netsurf.git/commit/10f621441f29c1f4e8b612e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/10f621441f29c1f4e8b612e57...
The branch, master has been updated
via 10f621441f29c1f4e8b612e57f3619debc2b6808 (commit)
from 2465fc4e6b8476fff1e081536e6145e4ce811ee5 (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=10f621441f29c1f4e8b...
commit 10f621441f29c1f4e8b612e57f3619debc2b6808
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Fix bounding on windows frontend window scrolling
diff --git a/windows/window.c b/windows/window.c
index fae9247..ece8b34 100644
--- a/windows/window.c
+++ b/windows/window.c
@@ -797,8 +797,27 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
return;
}
- w->requestscrollx = sx - w->scrollx;
- w->requestscrolly = sy - w->scrolly;
+ /*LOG(("scroll sx,sy:%d,%d x,y:%d,%d w.h:%d,%d",sx,sy,w->scrollx,w->scrolly, width,height));*/
+
+ /* The resulting gui window scroll must remain withn the
+ * windows bounding box.
+ */
+ if (sx < 0) {
+ w->requestscrollx = -w->scrollx;
+ } else if (sx > (width - w->width)) {
+ w->requestscrollx = (width - w->width) - w->scrollx;
+ } else {
+ w->requestscrollx = sx - w->scrollx;
+ }
+ if (sy < 0) {
+ w->requestscrolly = -w->scrolly;
+ } else if (sy > (height - w->height)) {
+ w->requestscrolly = (height - w->height) - w->scrolly;
+ } else {
+ w->requestscrolly = sy - w->scrolly;
+ }
+
+ /*LOG(("requestscroll x,y:%d,%d", w->requestscrollx, w->requestscrolly));*/
/* set the vertical scroll offset */
si.cbSize = sizeof(si);
@@ -809,7 +828,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.nPos = max(w->scrolly + w->requestscrolly, 0);
si.nPos = min(si.nPos, height - w->height);
SetScrollInfo(w->drawingarea, SB_VERT, &si, TRUE);
- LOG(("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));
+ /*LOG(("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));*/
/* set the horizontal scroll offset */
si.cbSize = sizeof(si);
@@ -820,7 +839,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.nPos = max(w->scrollx + w->requestscrollx, 0);
si.nPos = min(si.nPos, width - w->width);
SetScrollInfo(w->drawingarea, SB_HORZ, &si, TRUE);
- LOG(("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));
+ /*LOG(("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));*/
/* Set caret position */
GetCaretPos(&p);
@@ -834,6 +853,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
r.left = 0;
r.right = w->width + 1;
ScrollWindowEx(w->drawingarea, - w->requestscrollx, - w->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE);
+ /*LOG(("ScrollWindowEx %d, %d", - w->requestscrollx, - w->requestscrolly));*/
w->scrolly += w->requestscrolly;
w->scrollx += w->requestscrollx;
w->requestscrollx = 0;
-----------------------------------------------------------------------
Summary of changes:
windows/window.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/windows/window.c b/windows/window.c
index fae9247..ece8b34 100644
--- a/windows/window.c
+++ b/windows/window.c
@@ -797,8 +797,27 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
return;
}
- w->requestscrollx = sx - w->scrollx;
- w->requestscrolly = sy - w->scrolly;
+ /*LOG(("scroll sx,sy:%d,%d x,y:%d,%d w.h:%d,%d",sx,sy,w->scrollx,w->scrolly, width,height));*/
+
+ /* The resulting gui window scroll must remain withn the
+ * windows bounding box.
+ */
+ if (sx < 0) {
+ w->requestscrollx = -w->scrollx;
+ } else if (sx > (width - w->width)) {
+ w->requestscrollx = (width - w->width) - w->scrollx;
+ } else {
+ w->requestscrollx = sx - w->scrollx;
+ }
+ if (sy < 0) {
+ w->requestscrolly = -w->scrolly;
+ } else if (sy > (height - w->height)) {
+ w->requestscrolly = (height - w->height) - w->scrolly;
+ } else {
+ w->requestscrolly = sy - w->scrolly;
+ }
+
+ /*LOG(("requestscroll x,y:%d,%d", w->requestscrollx, w->requestscrolly));*/
/* set the vertical scroll offset */
si.cbSize = sizeof(si);
@@ -809,7 +828,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.nPos = max(w->scrolly + w->requestscrolly, 0);
si.nPos = min(si.nPos, height - w->height);
SetScrollInfo(w->drawingarea, SB_VERT, &si, TRUE);
- LOG(("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));
+ /*LOG(("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));*/
/* set the horizontal scroll offset */
si.cbSize = sizeof(si);
@@ -820,7 +839,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.nPos = max(w->scrollx + w->requestscrollx, 0);
si.nPos = min(si.nPos, width - w->width);
SetScrollInfo(w->drawingarea, SB_HORZ, &si, TRUE);
- LOG(("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));
+ /*LOG(("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));*/
/* Set caret position */
GetCaretPos(&p);
@@ -834,6 +853,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
r.left = 0;
r.right = w->width + 1;
ScrollWindowEx(w->drawingarea, - w->requestscrollx, - w->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE);
+ /*LOG(("ScrollWindowEx %d, %d", - w->requestscrollx, - w->requestscrolly));*/
w->scrolly += w->requestscrolly;
w->scrollx += w->requestscrollx;
w->requestscrollx = 0;
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-92-g2465fc4
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2465fc4e6b8476fff1e08...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2465fc4e6b8476fff1e0815...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2465fc4e6b8476fff1e081536...
The branch, master has been updated
via 2465fc4e6b8476fff1e081536e6145e4ce811ee5 (commit)
from 89a3f250d257b1f4ae018e2057377243d98226e1 (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=2465fc4e6b8476fff1e...
commit 2465fc4e6b8476fff1e081536e6145e4ce811ee5
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
move the mandantory library config for libcss and libdom to core makefile
diff --git a/Makefile b/Makefile
index 077d194..107e61c 100644
--- a/Makefile
+++ b/Makefile
@@ -498,8 +498,10 @@ $(eval $(call feature_switch,HARU_PDF,PDF export (haru),-DWITH_PDF_EXPORT,-lhpdf
$(eval $(call feature_switch,LIBICONV_PLUG,glibc internal iconv,-DLIBICONV_PLUG,,-ULIBICONV_PLUG,-liconv))
# Common libraries with pkgconfig
-$(eval $(call pkg_config_find_and_add,libutf8proc,utf8proc))
+$(eval $(call pkg_config_find_and_add,libcss,CSS))
+$(eval $(call pkg_config_find_and_add,libdom,DOM))
$(eval $(call pkg_config_find_and_add,libnsutils,nsutils))
+$(eval $(call pkg_config_find_and_add,libutf8proc,utf8proc))
# Common libraries without pkg-config support
LDFLAGS += -lz
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index 9c7b8f5..10e759b 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -46,10 +46,10 @@ else
CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include
CFLAGS += $(shell $(PKG_CONFIG) --cflags libcurl openssl)
- CFLAGS += $(shell $(PKG_CONFIG) --cflags tre libdom libcss)
+ CFLAGS += $(shell $(PKG_CONFIG) --cflags tre)
LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs tre libdom libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs tre)
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
ifeq ($(SUBTARGET),os3)
diff --git a/atari/Makefile.target b/atari/Makefile.target
index a09681b..2b488e5 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -63,11 +63,10 @@ CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall -Dnsatari \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L \
- $(shell $(PKG_CONFIG) --cflags libhubbub libcss openssl ) \
+ $(shell $(PKG_CONFIG) --cflags openssl ) \
$(shell $(PKG_CONFIG) --cflags libcurl )
LDFLAGS += -lcflib -lcurl
-LDFLAGS += -lcss -lparserutils -ldom -lwapcaplet -lhubbub
LDFLAGS += -lssl -lcrypto
LDFLAGS += -lz -lcares -lHermes -lgem -lm
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 815243c..1442199 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -5,15 +5,12 @@
POSTEXES += NetSurf.app
LDFLAGS += -L/usr/lib
-LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub libcss libdom)
LDFLAGS += -L/usr/X11/lib
LDFLAGS += -lm -lcurl
LDFLAGS += -lssl -lcrypto
CFLAGS += -Dnscocoa -D_BSD_SOURCE -D_POSIX_C_SOURCE -std=c99 -g -Os
-CFLAGS += $(shell $(PKG_CONFIG) --cflags libhubbub libcss libdom)
-
# shut up zconf.h and zlib.h
#CFLAGS += -D_LARGEFILE64_SOURCE=1
@@ -36,7 +33,7 @@ CFLAGS += -include cocoa/Prefix.pch
# VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c)
# TODO: this needs fixing properly everywhere
-VERSION_FULL := "3.0 (Dev)"
+VERSION_FULL := "3.4 (Dev)"
VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index edc0591..d652c8a 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -47,7 +47,7 @@ CFLAGS += -std=c99 -g -Dsmall \
-D_DEFAULT_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L \
- $(shell $(PKG_CONFIG) --cflags libnsfb libhubbub libcss openssl)
+ $(shell $(PKG_CONFIG) --cflags libnsfb openssl)
LDFLAGS += -lm -Wl,--whole-archive $(shell $(PKG_CONFIG) --libs libnsfb) -Wl,--no-whole-archive
@@ -56,14 +56,13 @@ ifeq ($(HOST),mint)
CFLAGS += $(shell curl-config --cflags)
LDFLAGS += $(shell curl-config --libs)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub openssl libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
LDFLAGS += -L/usr/lib/ -lz -liconv
LDFLAGS += -lm
else
CFLAGS += $(shell $(PKG_CONFIG) --cflags libcurl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl libdom openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl openssl)
endif
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index 904c4d5..d03f4f9 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -61,9 +61,6 @@ GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk -g \
-DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\"
# non optional pkg-configed libs
-$(eval $(call pkg_config_find_and_add,libcss,CSS))
-$(eval $(call pkg_config_find_and_add,libdom,DOM))
-$(eval $(call pkg_config_find_and_add,libhubbub,Hubbub))
$(eval $(call pkg_config_find_and_add,openssl,OpenSSL))
$(eval $(call pkg_config_find_and_add,libcurl,Curl ))
$(eval $(call pkg_config_find_and_add,gtk+-$(NETSURF_GTK_MAJOR).0,GTK-$(NETSURF_GTK_MAJOR)))
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index 7517463..e07af90 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -8,7 +8,7 @@
# ----------------------------------------------------------------------------
-LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl libdom libcss)
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl)
LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
@@ -43,7 +43,7 @@ CFLAGS += -std=c99 -Dmonkey -Dnsmonkey -g \
-D_NETBSD_SOURCE \
-DMONKEY_RESPATH=\"$(NETSURF_MONKEY_RESOURCES)\" \
$(shell $(PKG_CONFIG) --cflags glib-2.0) \
- $(shell $(PKG_CONFIG) --cflags libdom libcurl) \
+ $(shell $(PKG_CONFIG) --cflags libcurl) \
$(shell $(PKG_CONFIG) --cflags openssl)
LDFLAGS += -lm $(shell $(PKG_CONFIG) --cflags --libs glib-2.0)
diff --git a/riscos/Makefile.target b/riscos/Makefile.target
index de848cf..b2eb892 100644
--- a/riscos/Makefile.target
+++ b/riscos/Makefile.target
@@ -12,7 +12,6 @@ ifeq ($(HOST),riscos)
LDFLAGS += -lssl -lcrypto -ldom -lhubbub -lcss -lparserutils -lwapcaplet
else
LDFLAGS += $(shell $(PKG_CONFIG) --libs libcares libcurl openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libdom libcss)
endif
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
diff --git a/windows/Makefile.target b/windows/Makefile.target
index 4d6fa07..a8c3282 100644
--- a/windows/Makefile.target
+++ b/windows/Makefile.target
@@ -21,13 +21,8 @@ ifneq ($(PKG_CONFIG),)
$(eval $(call pkg_config_find_and_add,zlib,ZLib))
$(eval $(call pkg_config_find_and_add,libcurl,Curl))
$(eval $(call pkg_config_find_and_add,libcares,Cares))
- $(eval $(call pkg_config_find_and_add,libwapcaplet,Wapcaplet))
- $(eval $(call pkg_config_find_and_add,libparserutils,Parserutils))
- $(eval $(call pkg_config_find_and_add,libhubbub,Hubbub))
- $(eval $(call pkg_config_find_and_add,libdom,DOM))
- $(eval $(call pkg_config_find_and_add,libcss,CSS))
else
- LDFLAGS += -lhubbub -lcss -lparserutils -lwapcaplet -lcurl -lz
+ LDFLAGS += -lcurl -lz
endif
LDFLAGS += -lssl -lcrypto -lregex -lgdi32 -lcomctl32 -lws2_32 -lmsimg32 -mwindows
-----------------------------------------------------------------------
Summary of changes:
Makefile | 4 +++-
amiga/Makefile.target | 4 ++--
atari/Makefile.target | 3 +--
cocoa/Makefile.target | 5 +----
framebuffer/Makefile.target | 7 +++----
gtk/Makefile.target | 3 ---
monkey/Makefile.target | 4 ++--
riscos/Makefile.target | 1 -
windows/Makefile.target | 7 +------
9 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/Makefile b/Makefile
index 077d194..107e61c 100644
--- a/Makefile
+++ b/Makefile
@@ -498,8 +498,10 @@ $(eval $(call feature_switch,HARU_PDF,PDF export (haru),-DWITH_PDF_EXPORT,-lhpdf
$(eval $(call feature_switch,LIBICONV_PLUG,glibc internal iconv,-DLIBICONV_PLUG,,-ULIBICONV_PLUG,-liconv))
# Common libraries with pkgconfig
-$(eval $(call pkg_config_find_and_add,libutf8proc,utf8proc))
+$(eval $(call pkg_config_find_and_add,libcss,CSS))
+$(eval $(call pkg_config_find_and_add,libdom,DOM))
$(eval $(call pkg_config_find_and_add,libnsutils,nsutils))
+$(eval $(call pkg_config_find_and_add,libutf8proc,utf8proc))
# Common libraries without pkg-config support
LDFLAGS += -lz
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index 9c7b8f5..10e759b 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -46,10 +46,10 @@ else
CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include
CFLAGS += $(shell $(PKG_CONFIG) --cflags libcurl openssl)
- CFLAGS += $(shell $(PKG_CONFIG) --cflags tre libdom libcss)
+ CFLAGS += $(shell $(PKG_CONFIG) --cflags tre)
LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs tre libdom libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs tre)
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
ifeq ($(SUBTARGET),os3)
diff --git a/atari/Makefile.target b/atari/Makefile.target
index a09681b..2b488e5 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -63,11 +63,10 @@ CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall -Dnsatari \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L \
- $(shell $(PKG_CONFIG) --cflags libhubbub libcss openssl ) \
+ $(shell $(PKG_CONFIG) --cflags openssl ) \
$(shell $(PKG_CONFIG) --cflags libcurl )
LDFLAGS += -lcflib -lcurl
-LDFLAGS += -lcss -lparserutils -ldom -lwapcaplet -lhubbub
LDFLAGS += -lssl -lcrypto
LDFLAGS += -lz -lcares -lHermes -lgem -lm
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 815243c..1442199 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -5,15 +5,12 @@
POSTEXES += NetSurf.app
LDFLAGS += -L/usr/lib
-LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub libcss libdom)
LDFLAGS += -L/usr/X11/lib
LDFLAGS += -lm -lcurl
LDFLAGS += -lssl -lcrypto
CFLAGS += -Dnscocoa -D_BSD_SOURCE -D_POSIX_C_SOURCE -std=c99 -g -Os
-CFLAGS += $(shell $(PKG_CONFIG) --cflags libhubbub libcss libdom)
-
# shut up zconf.h and zlib.h
#CFLAGS += -D_LARGEFILE64_SOURCE=1
@@ -36,7 +33,7 @@ CFLAGS += -include cocoa/Prefix.pch
# VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c)
# TODO: this needs fixing properly everywhere
-VERSION_FULL := "3.0 (Dev)"
+VERSION_FULL := "3.4 (Dev)"
VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index edc0591..d652c8a 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -47,7 +47,7 @@ CFLAGS += -std=c99 -g -Dsmall \
-D_DEFAULT_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L \
- $(shell $(PKG_CONFIG) --cflags libnsfb libhubbub libcss openssl)
+ $(shell $(PKG_CONFIG) --cflags libnsfb openssl)
LDFLAGS += -lm -Wl,--whole-archive $(shell $(PKG_CONFIG) --libs libnsfb) -Wl,--no-whole-archive
@@ -56,14 +56,13 @@ ifeq ($(HOST),mint)
CFLAGS += $(shell curl-config --cflags)
LDFLAGS += $(shell curl-config --libs)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub openssl libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
LDFLAGS += -L/usr/lib/ -lz -liconv
LDFLAGS += -lm
else
CFLAGS += $(shell $(PKG_CONFIG) --cflags libcurl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl libdom openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl openssl)
endif
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index 904c4d5..d03f4f9 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -61,9 +61,6 @@ GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk -g \
-DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\"
# non optional pkg-configed libs
-$(eval $(call pkg_config_find_and_add,libcss,CSS))
-$(eval $(call pkg_config_find_and_add,libdom,DOM))
-$(eval $(call pkg_config_find_and_add,libhubbub,Hubbub))
$(eval $(call pkg_config_find_and_add,openssl,OpenSSL))
$(eval $(call pkg_config_find_and_add,libcurl,Curl ))
$(eval $(call pkg_config_find_and_add,gtk+-$(NETSURF_GTK_MAJOR).0,GTK-$(NETSURF_GTK_MAJOR)))
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index 7517463..e07af90 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -8,7 +8,7 @@
# ----------------------------------------------------------------------------
-LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl libdom libcss)
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl)
LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
@@ -43,7 +43,7 @@ CFLAGS += -std=c99 -Dmonkey -Dnsmonkey -g \
-D_NETBSD_SOURCE \
-DMONKEY_RESPATH=\"$(NETSURF_MONKEY_RESOURCES)\" \
$(shell $(PKG_CONFIG) --cflags glib-2.0) \
- $(shell $(PKG_CONFIG) --cflags libdom libcurl) \
+ $(shell $(PKG_CONFIG) --cflags libcurl) \
$(shell $(PKG_CONFIG) --cflags openssl)
LDFLAGS += -lm $(shell $(PKG_CONFIG) --cflags --libs glib-2.0)
diff --git a/riscos/Makefile.target b/riscos/Makefile.target
index de848cf..b2eb892 100644
--- a/riscos/Makefile.target
+++ b/riscos/Makefile.target
@@ -12,7 +12,6 @@ ifeq ($(HOST),riscos)
LDFLAGS += -lssl -lcrypto -ldom -lhubbub -lcss -lparserutils -lwapcaplet
else
LDFLAGS += $(shell $(PKG_CONFIG) --libs libcares libcurl openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libdom libcss)
endif
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
diff --git a/windows/Makefile.target b/windows/Makefile.target
index 4d6fa07..a8c3282 100644
--- a/windows/Makefile.target
+++ b/windows/Makefile.target
@@ -21,13 +21,8 @@ ifneq ($(PKG_CONFIG),)
$(eval $(call pkg_config_find_and_add,zlib,ZLib))
$(eval $(call pkg_config_find_and_add,libcurl,Curl))
$(eval $(call pkg_config_find_and_add,libcares,Cares))
- $(eval $(call pkg_config_find_and_add,libwapcaplet,Wapcaplet))
- $(eval $(call pkg_config_find_and_add,libparserutils,Parserutils))
- $(eval $(call pkg_config_find_and_add,libhubbub,Hubbub))
- $(eval $(call pkg_config_find_and_add,libdom,DOM))
- $(eval $(call pkg_config_find_and_add,libcss,CSS))
else
- LDFLAGS += -lhubbub -lcss -lparserutils -lwapcaplet -lcurl -lz
+ LDFLAGS += -lcurl -lz
endif
LDFLAGS += -lssl -lcrypto -lregex -lgdi32 -lcomctl32 -lws2_32 -lmsimg32 -mwindows
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-91-g89a3f25
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/89a3f250d257b1f4ae018...
...commit http://git.netsurf-browser.org/netsurf.git/commit/89a3f250d257b1f4ae018e2...
...tree http://git.netsurf-browser.org/netsurf.git/tree/89a3f250d257b1f4ae018e205...
The branch, master has been updated
via 89a3f250d257b1f4ae018e2057377243d98226e1 (commit)
via 7ec917eed28fa973438f0d1d8d3e3a45649f6875 (commit)
via 82c1ed9f4a6d164eaab9ccb98311fe1a5e8e07e8 (commit)
from 402d74013765509c687609f42960071a8fda0ff5 (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=89a3f250d257b1f4ae0...
commit 89a3f250d257b1f4ae018e2057377243d98226e1
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Ensure GTK source viewer reports errors appropriately.
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 51f0424..661902b 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -1158,7 +1158,13 @@ MULTIHANDLER(fullscreen)
MULTIHANDLER(viewsource)
{
- nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level));
+ nserror ret;
+
+ ret = nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level));
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
+
return TRUE;
}
diff --git a/gtk/viewsource.c b/gtk/viewsource.c
index abc9f94..62e5959 100644
--- a/gtk/viewsource.c
+++ b/gtk/viewsource.c
@@ -28,7 +28,7 @@
#include "gtk/viewdata.h"
#include "gtk/viewsource.h"
-void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
+nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
{
nserror ret;
struct hlcache_handle *hlcontent;
@@ -41,11 +41,11 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
hlcontent = browser_window_get_content(bw);
if (hlcontent == NULL) {
- return;
+ return NSERROR_BAD_PARAMETER;
}
if (content_get_type(hlcontent) != CONTENT_HTML) {
- return;
+ return NSERROR_BAD_CONTENT;
}
source_data = content_get_source_data(hlcontent, &source_size);
@@ -54,11 +54,15 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
if (ret != NSERROR_OK) {
filename = strdup(messages_get("SaveSource"));
if (filename == NULL) {
- return;
+ return NSERROR_NOMEM;
}
}
title = malloc(strlen(nsurl_access(browser_window_get_url(bw))) + SLEN("Source of - NetSurf") + 1);
+ if (title == NULL) {
+ free(filename);
+ return NSERROR_NOMEM;
+ }
sprintf(title, "Source of %s - NetSurf", nsurl_access(browser_window_get_url(bw)));
ret = utf8_from_enc(source_data,
@@ -72,4 +76,6 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
free(filename);
free(title);
+
+ return ret;
}
diff --git a/gtk/viewsource.h b/gtk/viewsource.h
index fe85b30..bba8788 100644
--- a/gtk/viewsource.h
+++ b/gtk/viewsource.h
@@ -19,7 +19,7 @@
#ifndef _NETSURF_GTK_VIEWSOURCE_H_
#define _NETSURF_GTK_VIEWSOURCE_H_
-void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw);
+nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw);
#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7ec917eed28fa973438...
commit 7ec917eed28fa973438f0d1d8d3e3a45649f6875
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
ensure memory is freed on error path in gtk viewdata
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 37e5d13..bde87a7 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -489,7 +489,11 @@ window_init_fname(const char *title,
fclose(f);
+ /* window init takes ownership of the ndata if there is no error */
ret = window_init(title, leafname, ndata, ndata_len);
+ if (ret != NSERROR_OK) {
+ free(ndata);
+ }
return ret;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=82c1ed9f4a6d164eaab...
commit 82c1ed9f4a6d164eaab9ccb98311fe1a5e8e07e8
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Ensure gtk XDG editor handling never uses an unintialised value.
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 460d58b..37e5d13 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -827,7 +827,8 @@ editor_init_fname(const char *title,
{
char **xdg_data_vec;
int veci;
- char *def_app_desktop; /* desktop file of default app for mimetype */
+ /* desktop file of default app for mimetype */
+ char *def_app_desktop = NULL;
char *exec_cmd;
char **argv;
-----------------------------------------------------------------------
Summary of changes:
gtk/scaffolding.c | 8 +++++++-
gtk/viewdata.c | 7 ++++++-
gtk/viewsource.c | 14 ++++++++++----
gtk/viewsource.h | 2 +-
4 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 51f0424..661902b 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -1158,7 +1158,13 @@ MULTIHANDLER(fullscreen)
MULTIHANDLER(viewsource)
{
- nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level));
+ nserror ret;
+
+ ret = nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level));
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
+
return TRUE;
}
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 460d58b..bde87a7 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -489,7 +489,11 @@ window_init_fname(const char *title,
fclose(f);
+ /* window init takes ownership of the ndata if there is no error */
ret = window_init(title, leafname, ndata, ndata_len);
+ if (ret != NSERROR_OK) {
+ free(ndata);
+ }
return ret;
}
@@ -827,7 +831,8 @@ editor_init_fname(const char *title,
{
char **xdg_data_vec;
int veci;
- char *def_app_desktop; /* desktop file of default app for mimetype */
+ /* desktop file of default app for mimetype */
+ char *def_app_desktop = NULL;
char *exec_cmd;
char **argv;
diff --git a/gtk/viewsource.c b/gtk/viewsource.c
index abc9f94..62e5959 100644
--- a/gtk/viewsource.c
+++ b/gtk/viewsource.c
@@ -28,7 +28,7 @@
#include "gtk/viewdata.h"
#include "gtk/viewsource.h"
-void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
+nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
{
nserror ret;
struct hlcache_handle *hlcontent;
@@ -41,11 +41,11 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
hlcontent = browser_window_get_content(bw);
if (hlcontent == NULL) {
- return;
+ return NSERROR_BAD_PARAMETER;
}
if (content_get_type(hlcontent) != CONTENT_HTML) {
- return;
+ return NSERROR_BAD_CONTENT;
}
source_data = content_get_source_data(hlcontent, &source_size);
@@ -54,11 +54,15 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
if (ret != NSERROR_OK) {
filename = strdup(messages_get("SaveSource"));
if (filename == NULL) {
- return;
+ return NSERROR_NOMEM;
}
}
title = malloc(strlen(nsurl_access(browser_window_get_url(bw))) + SLEN("Source of - NetSurf") + 1);
+ if (title == NULL) {
+ free(filename);
+ return NSERROR_NOMEM;
+ }
sprintf(title, "Source of %s - NetSurf", nsurl_access(browser_window_get_url(bw)));
ret = utf8_from_enc(source_data,
@@ -72,4 +76,6 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
free(filename);
free(title);
+
+ return ret;
}
diff --git a/gtk/viewsource.h b/gtk/viewsource.h
index fe85b30..bba8788 100644
--- a/gtk/viewsource.h
+++ b/gtk/viewsource.h
@@ -19,7 +19,7 @@
#ifndef _NETSURF_GTK_VIEWSOURCE_H_
#define _NETSURF_GTK_VIEWSOURCE_H_
-void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw);
+nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw);
#endif
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-88-g402d740
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/402d74013765509c68760...
...commit http://git.netsurf-browser.org/netsurf.git/commit/402d74013765509c687609f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/402d74013765509c687609f42...
The branch, master has been updated
via 402d74013765509c687609f42960071a8fda0ff5 (commit)
from e36907c5e11cbbe39d45dead0c9763d86f08185e (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=402d74013765509c687...
commit 402d74013765509c687609f42960071a8fda0ff5
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix missing comma in beos operations table
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 7f7d2b1..9a4ee52 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -281,7 +281,8 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *vbitmap) {
+void bitmap_modified(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
@@ -291,12 +292,14 @@ void bitmap_modified(void *vbitmap) {
nsbeos_bitmap_free_pretiles(bitmap);
}
-int bitmap_get_width(void *vbitmap){
+int bitmap_get_width(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
return bitmap->primary->Bounds().Width() + 1;
}
-int bitmap_get_height(void *vbitmap){
+int bitmap_get_height(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
return bitmap->primary->Bounds().Height() + 1;
}
diff --git a/beos/bitmap.h b/beos/bitmap.h
index b16eae5..8c47ce9 100644
--- a/beos/bitmap.h
+++ b/beos/bitmap.h
@@ -24,11 +24,13 @@ extern "C" {
#include "image/bitmap.h"
}
+extern struct gui_bitmap_table *beos_bitmap_table;
+
BBitmap *nsbeos_bitmap_get_primary(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_x(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_y(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_xy(struct bitmap*);
-extern struct gui_bitmap_table *beos_bitmap_table;
+void bitmap_modified(void *vbitmap);
#endif /* NS_BEOS_BITMAP_H */
diff --git a/beos/gui.cpp b/beos/gui.cpp
index e479cc2..7c5d9e0 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -1061,7 +1061,7 @@ int gui_init_replicant(int argc, char** argv)
beos_window_table,
beos_download_table,
&beos_clipboard_table,
- &beos_fetch_table
+ &beos_fetch_table,
NULL, /* use POSIX file */
NULL, /* default utf8 */
NULL, /* default search */
-----------------------------------------------------------------------
Summary of changes:
beos/bitmap.cpp | 9 ++++++---
beos/bitmap.h | 4 +++-
beos/gui.cpp | 2 +-
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 7f7d2b1..9a4ee52 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -281,7 +281,8 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *vbitmap) {
+void bitmap_modified(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
@@ -291,12 +292,14 @@ void bitmap_modified(void *vbitmap) {
nsbeos_bitmap_free_pretiles(bitmap);
}
-int bitmap_get_width(void *vbitmap){
+int bitmap_get_width(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
return bitmap->primary->Bounds().Width() + 1;
}
-int bitmap_get_height(void *vbitmap){
+int bitmap_get_height(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
return bitmap->primary->Bounds().Height() + 1;
}
diff --git a/beos/bitmap.h b/beos/bitmap.h
index b16eae5..8c47ce9 100644
--- a/beos/bitmap.h
+++ b/beos/bitmap.h
@@ -24,11 +24,13 @@ extern "C" {
#include "image/bitmap.h"
}
+extern struct gui_bitmap_table *beos_bitmap_table;
+
BBitmap *nsbeos_bitmap_get_primary(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_x(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_y(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_xy(struct bitmap*);
-extern struct gui_bitmap_table *beos_bitmap_table;
+void bitmap_modified(void *vbitmap);
#endif /* NS_BEOS_BITMAP_H */
diff --git a/beos/gui.cpp b/beos/gui.cpp
index e479cc2..7c5d9e0 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -1061,7 +1061,7 @@ int gui_init_replicant(int argc, char** argv)
beos_window_table,
beos_download_table,
&beos_clipboard_table,
- &beos_fetch_table
+ &beos_fetch_table,
NULL, /* use POSIX file */
NULL, /* default utf8 */
NULL, /* default search */
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-87-ge36907c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e36907c5e11cbbe39d45d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e36907c5e11cbbe39d45dea...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e36907c5e11cbbe39d45dead0...
The branch, master has been updated
via e36907c5e11cbbe39d45dead0c9763d86f08185e (commit)
via 881cb6394b8b511fa3b1d96be9520de581faed86 (commit)
from 2e961c47ce50c3d185d9372c51caaa9a4a216b20 (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=e36907c5e11cbbe39d4...
commit e36907c5e11cbbe39d45dead0c9763d86f08185e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add missing extern from struct declaration.
diff --git a/beos/bitmap.h b/beos/bitmap.h
index a9bb694..b16eae5 100644
--- a/beos/bitmap.h
+++ b/beos/bitmap.h
@@ -29,6 +29,6 @@ BBitmap *nsbeos_bitmap_get_pretile_x(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_y(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_xy(struct bitmap*);
-struct gui_bitmap_table *beos_bitmap_table;
+extern struct gui_bitmap_table *beos_bitmap_table;
#endif /* NS_BEOS_BITMAP_H */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=881cb6394b8b511fa3b...
commit 881cb6394b8b511fa3b1d96be9520de581faed86
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Add image handlers into doxygen generation path
diff --git a/Docs/Doxyfile b/Docs/Doxyfile
index 72f24dc..c2a8bba 100644
--- a/Docs/Doxyfile
+++ b/Docs/Doxyfile
@@ -680,7 +680,8 @@ INPUT = windows \
javascript \
javascript/jsapi \
utils \
- utils/http
+ utils/http \
+ image
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-----------------------------------------------------------------------
Summary of changes:
Docs/Doxyfile | 3 ++-
beos/bitmap.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Docs/Doxyfile b/Docs/Doxyfile
index 72f24dc..c2a8bba 100644
--- a/Docs/Doxyfile
+++ b/Docs/Doxyfile
@@ -680,7 +680,8 @@ INPUT = windows \
javascript \
javascript/jsapi \
utils \
- utils/http
+ utils/http \
+ image
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
diff --git a/beos/bitmap.h b/beos/bitmap.h
index a9bb694..b16eae5 100644
--- a/beos/bitmap.h
+++ b/beos/bitmap.h
@@ -29,6 +29,6 @@ BBitmap *nsbeos_bitmap_get_pretile_x(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_y(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_xy(struct bitmap*);
-struct gui_bitmap_table *beos_bitmap_table;
+extern struct gui_bitmap_table *beos_bitmap_table;
#endif /* NS_BEOS_BITMAP_H */
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-85-g2e961c4
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2e961c47ce50c3d185d93...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2e961c47ce50c3d185d9372...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2e961c47ce50c3d185d9372c5...
The branch, master has been updated
via 2e961c47ce50c3d185d9372c51caaa9a4a216b20 (commit)
via 1629c57b9b6a778af3374ee32f136adda089fb09 (commit)
via ef1a8f3b0f5bd8e148eefbbdacc8c209ed6d614b (commit)
from 8dc2a8f0b21a7c430da450a4051cf056f09b5a78 (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=2e961c47ce50c3d185d...
commit 2e961c47ce50c3d185d9372c51caaa9a4a216b20
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
change rsvg image handler to use bitmap operation table
diff --git a/image/rsvg.c b/image/rsvg.c
index 3fdfd34..3dd27fe 100644
--- a/image/rsvg.c
+++ b/image/rsvg.c
@@ -37,13 +37,14 @@
#include <librsvg/rsvg-cairo.h>
#endif
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
+#include "content/content_protected.h"
+#include "desktop/plotters.h"
+#include "desktop/gui_internal.h"
+#include "image/bitmap.h"
#include "image/rsvg.h"
typedef struct rsvg_content {
@@ -177,7 +178,7 @@ static bool rsvg_convert(struct content *c)
c->width = rsvgsize.width;
c->height = rsvgsize.height;
- if ((d->bitmap = bitmap_create(c->width, c->height,
+ if ((d->bitmap = guit->bitmap->create(c->width, c->height,
BITMAP_NEW)) == NULL) {
LOG(("Failed to create bitmap for rsvg render."));
msg_data.error = messages_get("NoMemory");
@@ -186,10 +187,10 @@ static bool rsvg_convert(struct content *c)
}
if ((d->cs = cairo_image_surface_create_for_data(
- (unsigned char *)bitmap_get_buffer(d->bitmap),
+ (unsigned char *)guit->bitmap->get_buffer(d->bitmap),
CAIRO_FORMAT_ARGB32,
c->width, c->height,
- bitmap_get_rowstride(d->bitmap))) == NULL) {
+ guit->bitmap->get_rowstride(d->bitmap))) == NULL) {
LOG(("Failed to create Cairo image surface for rsvg render."));
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -204,11 +205,11 @@ static bool rsvg_convert(struct content *c)
}
rsvg_handle_render_cairo(d->rsvgh, d->ct);
- rsvg_argb_to_abgr(bitmap_get_buffer(d->bitmap),
+ rsvg_argb_to_abgr(guit->bitmap->get_buffer(d->bitmap),
c->width, c->height,
- bitmap_get_rowstride(d->bitmap));
+ guit->bitmap->get_rowstride(d->bitmap));
- bitmap_modified(d->bitmap);
+ guit->bitmap->modified(d->bitmap);
content_set_ready(c);
content_set_done(c);
/* Done: update status bar */
@@ -238,7 +239,7 @@ static void rsvg_destroy(struct content *c)
{
rsvg_content *d = (rsvg_content *) c;
- if (d->bitmap != NULL) bitmap_destroy(d->bitmap);
+ if (d->bitmap != NULL) guit->bitmap->destroy(d->bitmap);
if (d->rsvgh != NULL) g_object_unref(d->rsvgh);
if (d->ct != NULL) cairo_destroy(d->ct);
if (d->cs != NULL) cairo_surface_destroy(d->cs);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=1629c57b9b6a778af33...
commit 1629c57b9b6a778af3374ee32f136adda089fb09
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fixup risc os sprite image handler to use bitmap operation table
diff --git a/image/nssprite.c b/image/nssprite.c
index 5f05c94..9ec0b9f 100644
--- a/image/nssprite.c
+++ b/image/nssprite.c
@@ -21,18 +21,18 @@
*
*/
-#include <assert.h>
-#include <string.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <librosprite.h>
-#include "utils/config.h"
+
+#include "utils/log.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
+#include "desktop/gui_internal.h"
#include "desktop/plotters.h"
+
#include "image/bitmap.h"
#include "image/nssprite.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
typedef struct nssprite_content {
struct content base;
@@ -113,13 +113,13 @@ static bool nssprite_convert(struct content *c)
struct rosprite* sprite = sprite_area->sprites[0];
- nssprite->bitmap = bitmap_create(sprite->width, sprite->height, BITMAP_NEW);
+ nssprite->bitmap = guit->bitmap->create(sprite->width, sprite->height, BITMAP_NEW);
if (!nssprite->bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
- uint32_t* imagebuf = (uint32_t *)bitmap_get_buffer(nssprite->bitmap);
+ uint32_t* imagebuf = (uint32_t *)guit->bitmap->get_buffer(nssprite->bitmap);
if (!imagebuf) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -153,7 +153,7 @@ static bool nssprite_convert(struct content *c)
free(title);
}
- bitmap_modified(nssprite->bitmap);
+ guit->bitmap->modified(nssprite->bitmap);
content_set_ready(c);
content_set_done(c);
@@ -174,7 +174,7 @@ static void nssprite_destroy(struct content *c)
if (nssprite->sprite_area != NULL)
rosprite_destroy_sprite_area(nssprite->sprite_area);
if (nssprite->bitmap != NULL)
- bitmap_destroy(nssprite->bitmap);
+ guit->bitmap->destroy(nssprite->bitmap);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ef1a8f3b0f5bd8e148e...
commit ef1a8f3b0f5bd8e148eefbbdacc8c209ed6d614b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix forward reference in cocoa bitmap handling
diff --git a/cocoa/bitmap.m b/cocoa/bitmap.m
index 45ea1e0..52777bc 100644
--- a/cocoa/bitmap.m
+++ b/cocoa/bitmap.m
@@ -94,6 +94,27 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
[bmp setOpaque: opaque ? YES : NO];
}
+unsigned char *bitmap_get_buffer(void *bitmap)
+{
+ NSCParameterAssert( NULL != bitmap );
+ NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
+ return [bmp bitmapData];
+}
+
+size_t bitmap_get_rowstride(void *bitmap)
+{
+ NSCParameterAssert( NULL != bitmap );
+ NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
+ return [bmp bytesPerRow];
+}
+
+size_t bitmap_get_bpp(void *bitmap)
+{
+ NSCParameterAssert( NULL != bitmap );
+ NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
+ return [bmp bitsPerPixel] / 8;
+}
+
bool bitmap_test_opaque(void *bitmap)
{
NSCParameterAssert( bitmap_get_bpp( bitmap ) == BYTES_PER_PIXEL );
@@ -116,27 +137,6 @@ bool bitmap_test_opaque(void *bitmap)
return true;
}
-unsigned char *bitmap_get_buffer(void *bitmap)
-{
- NSCParameterAssert( NULL != bitmap );
- NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
- return [bmp bitmapData];
-}
-
-size_t bitmap_get_rowstride(void *bitmap)
-{
- NSCParameterAssert( NULL != bitmap );
- NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
- return [bmp bytesPerRow];
-}
-
-size_t bitmap_get_bpp(void *bitmap)
-{
- NSCParameterAssert( NULL != bitmap );
- NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
- return [bmp bitsPerPixel] / 8;
-}
-
bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
NSCParameterAssert( NULL != bitmap );
-----------------------------------------------------------------------
Summary of changes:
cocoa/bitmap.m | 42 +++++++++++++++++++++---------------------
image/nssprite.c | 20 ++++++++++----------
image/rsvg.c | 21 +++++++++++----------
3 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/cocoa/bitmap.m b/cocoa/bitmap.m
index 45ea1e0..52777bc 100644
--- a/cocoa/bitmap.m
+++ b/cocoa/bitmap.m
@@ -94,6 +94,27 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
[bmp setOpaque: opaque ? YES : NO];
}
+unsigned char *bitmap_get_buffer(void *bitmap)
+{
+ NSCParameterAssert( NULL != bitmap );
+ NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
+ return [bmp bitmapData];
+}
+
+size_t bitmap_get_rowstride(void *bitmap)
+{
+ NSCParameterAssert( NULL != bitmap );
+ NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
+ return [bmp bytesPerRow];
+}
+
+size_t bitmap_get_bpp(void *bitmap)
+{
+ NSCParameterAssert( NULL != bitmap );
+ NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
+ return [bmp bitsPerPixel] / 8;
+}
+
bool bitmap_test_opaque(void *bitmap)
{
NSCParameterAssert( bitmap_get_bpp( bitmap ) == BYTES_PER_PIXEL );
@@ -116,27 +137,6 @@ bool bitmap_test_opaque(void *bitmap)
return true;
}
-unsigned char *bitmap_get_buffer(void *bitmap)
-{
- NSCParameterAssert( NULL != bitmap );
- NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
- return [bmp bitmapData];
-}
-
-size_t bitmap_get_rowstride(void *bitmap)
-{
- NSCParameterAssert( NULL != bitmap );
- NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
- return [bmp bytesPerRow];
-}
-
-size_t bitmap_get_bpp(void *bitmap)
-{
- NSCParameterAssert( NULL != bitmap );
- NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
- return [bmp bitsPerPixel] / 8;
-}
-
bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
NSCParameterAssert( NULL != bitmap );
diff --git a/image/nssprite.c b/image/nssprite.c
index 5f05c94..9ec0b9f 100644
--- a/image/nssprite.c
+++ b/image/nssprite.c
@@ -21,18 +21,18 @@
*
*/
-#include <assert.h>
-#include <string.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <librosprite.h>
-#include "utils/config.h"
+
+#include "utils/log.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
+#include "desktop/gui_internal.h"
#include "desktop/plotters.h"
+
#include "image/bitmap.h"
#include "image/nssprite.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
typedef struct nssprite_content {
struct content base;
@@ -113,13 +113,13 @@ static bool nssprite_convert(struct content *c)
struct rosprite* sprite = sprite_area->sprites[0];
- nssprite->bitmap = bitmap_create(sprite->width, sprite->height, BITMAP_NEW);
+ nssprite->bitmap = guit->bitmap->create(sprite->width, sprite->height, BITMAP_NEW);
if (!nssprite->bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
- uint32_t* imagebuf = (uint32_t *)bitmap_get_buffer(nssprite->bitmap);
+ uint32_t* imagebuf = (uint32_t *)guit->bitmap->get_buffer(nssprite->bitmap);
if (!imagebuf) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -153,7 +153,7 @@ static bool nssprite_convert(struct content *c)
free(title);
}
- bitmap_modified(nssprite->bitmap);
+ guit->bitmap->modified(nssprite->bitmap);
content_set_ready(c);
content_set_done(c);
@@ -174,7 +174,7 @@ static void nssprite_destroy(struct content *c)
if (nssprite->sprite_area != NULL)
rosprite_destroy_sprite_area(nssprite->sprite_area);
if (nssprite->bitmap != NULL)
- bitmap_destroy(nssprite->bitmap);
+ guit->bitmap->destroy(nssprite->bitmap);
}
diff --git a/image/rsvg.c b/image/rsvg.c
index 3fdfd34..3dd27fe 100644
--- a/image/rsvg.c
+++ b/image/rsvg.c
@@ -37,13 +37,14 @@
#include <librsvg/rsvg-cairo.h>
#endif
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
+#include "content/content_protected.h"
+#include "desktop/plotters.h"
+#include "desktop/gui_internal.h"
+#include "image/bitmap.h"
#include "image/rsvg.h"
typedef struct rsvg_content {
@@ -177,7 +178,7 @@ static bool rsvg_convert(struct content *c)
c->width = rsvgsize.width;
c->height = rsvgsize.height;
- if ((d->bitmap = bitmap_create(c->width, c->height,
+ if ((d->bitmap = guit->bitmap->create(c->width, c->height,
BITMAP_NEW)) == NULL) {
LOG(("Failed to create bitmap for rsvg render."));
msg_data.error = messages_get("NoMemory");
@@ -186,10 +187,10 @@ static bool rsvg_convert(struct content *c)
}
if ((d->cs = cairo_image_surface_create_for_data(
- (unsigned char *)bitmap_get_buffer(d->bitmap),
+ (unsigned char *)guit->bitmap->get_buffer(d->bitmap),
CAIRO_FORMAT_ARGB32,
c->width, c->height,
- bitmap_get_rowstride(d->bitmap))) == NULL) {
+ guit->bitmap->get_rowstride(d->bitmap))) == NULL) {
LOG(("Failed to create Cairo image surface for rsvg render."));
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -204,11 +205,11 @@ static bool rsvg_convert(struct content *c)
}
rsvg_handle_render_cairo(d->rsvgh, d->ct);
- rsvg_argb_to_abgr(bitmap_get_buffer(d->bitmap),
+ rsvg_argb_to_abgr(guit->bitmap->get_buffer(d->bitmap),
c->width, c->height,
- bitmap_get_rowstride(d->bitmap));
+ guit->bitmap->get_rowstride(d->bitmap));
- bitmap_modified(d->bitmap);
+ guit->bitmap->modified(d->bitmap);
content_set_ready(c);
content_set_done(c);
/* Done: update status bar */
@@ -238,7 +239,7 @@ static void rsvg_destroy(struct content *c)
{
rsvg_content *d = (rsvg_content *) c;
- if (d->bitmap != NULL) bitmap_destroy(d->bitmap);
+ if (d->bitmap != NULL) guit->bitmap->destroy(d->bitmap);
if (d->rsvgh != NULL) g_object_unref(d->rsvgh);
if (d->ct != NULL) cairo_destroy(d->ct);
if (d->cs != NULL) cairo_surface_destroy(d->cs);
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-82-g8dc2a8f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8dc2a8f0b21a7c430da45...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8dc2a8f0b21a7c430da450a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8dc2a8f0b21a7c430da450a40...
The branch, master has been updated
via 8dc2a8f0b21a7c430da450a4051cf056f09b5a78 (commit)
via 839f15fc72166eb63be4f2afc4588d253e88c9f4 (commit)
via fb0bd7994491da2a7fa6913c5b5666ed49c6e153 (commit)
via 3c61db33ffc94ee194dd0111a332762199334d37 (commit)
via ad18ef5db99eb38075e6e49246b097a8ba727ab8 (commit)
via 5c7e8618d5e5f2eb0b37dd937fb5669eeba407d0 (commit)
via 9679561eca26bf792764002465bc0548c5d694bf (commit)
via cc11912da1e2881803828330f85b0fe177b570b6 (commit)
via c02f552e8704f52e1a9ab92b21cb7d23211d98ab (commit)
via f37e52c39475e6efd3740c5ae1ec4f290662928f (commit)
from 7a28131e4953934150967eb7886bc06678e249e8 (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=8dc2a8f0b21a7c430da...
commit 8dc2a8f0b21a7c430da450a4051cf056f09b5a78
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
convert cocoa frontend to bitmap operation table
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index d76aee1..ac26c9c 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -24,6 +24,7 @@
#import "cocoa/SearchWindowController.h"
#import "cocoa/selection.h"
#import "cocoa/fetch.h"
+#import "cocoa/bitmap.h"
#import "utils/filename.h"
#import "utils/log.h"
@@ -220,7 +221,8 @@ int main( int argc, char **argv )
.clipboard = cocoa_clipboard_table,
.download = cocoa_download_table,
.fetch = cocoa_fetch_table,
- .search = cocoa_search_table,
+ .search = cocoa_search_table,
+ .bitmap = cocoa_bitmap_table,
};
cocoa_autorelease();
diff --git a/cocoa/bitmap.h b/cocoa/bitmap.h
index 78526e4..dc463b8 100644
--- a/cocoa/bitmap.h
+++ b/cocoa/bitmap.h
@@ -21,4 +21,6 @@
CGImageRef cocoa_get_cgimage( void *bitmap );
-#endif
\ No newline at end of file
+struct gui_bitmap_table *cocoa_bitmap_table;
+
+#endif
diff --git a/cocoa/bitmap.m b/cocoa/bitmap.m
index 45b1d3b..45ea1e0 100644
--- a/cocoa/bitmap.m
+++ b/cocoa/bitmap.m
@@ -215,3 +215,19 @@ static CGImageRef cocoa_prepare_bitmap( void *bitmap )
return result;
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *cocoa_bitmap_table = &bitmap_table;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=839f15fc72166eb63be...
commit 839f15fc72166eb63be4f2afc4588d253e88c9f4
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
convert beos to bitmap operation table
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 1524aed..7f7d2b1 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -401,3 +401,20 @@ nsbeos_bitmap_get_pretile_xy(struct bitmap* bitmap)
}
return bitmap->pretile_xy;
}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *beos_bitmap_table = &bitmap_table;
diff --git a/beos/bitmap.h b/beos/bitmap.h
index 6ec6621..a9bb694 100644
--- a/beos/bitmap.h
+++ b/beos/bitmap.h
@@ -29,6 +29,6 @@ BBitmap *nsbeos_bitmap_get_pretile_x(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_y(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_xy(struct bitmap*);
-
+struct gui_bitmap_table *beos_bitmap_table;
#endif /* NS_BEOS_BITMAP_H */
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 9486382..e479cc2 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -79,6 +79,7 @@ extern "C" {
#include "beos/schedule.h"
#include "beos/fetch_rsrc.h"
#include "beos/scaffolding.h"
+#include "beos/bitmap.h"
static void *myrealloc(void *ptr, size_t len, void *pw);
@@ -995,7 +996,13 @@ int main(int argc, char** argv)
beos_window_table,
beos_download_table,
&beos_clipboard_table,
- &beos_fetch_table
+ &beos_fetch_table,
+ NULL, /* use POSIX file */
+ NULL, /* default utf8 */
+ NULL, /* default search */
+ NULL, /* default web search */
+ NULL, /* default low level cache persistant storage */
+ beos_bitmap_table
};
ret = netsurf_register(&beos_table);
@@ -1055,6 +1062,12 @@ int gui_init_replicant(int argc, char** argv)
beos_download_table,
&beos_clipboard_table,
&beos_fetch_table
+ NULL, /* use POSIX file */
+ NULL, /* default utf8 */
+ NULL, /* default search */
+ NULL, /* default web search */
+ NULL, /* default low level cache persistant storage */
+ beos_bitmap_table
};
ret = netsurf_register(&beos_table);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=fb0bd7994491da2a7fa...
commit fb0bd7994491da2a7fa6913c5b5666ed49c6e153
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
update amiga frontend to use bitmap operation table
diff --git a/amiga/bitmap.c b/amiga/bitmap.c
index 633d8d0..67e7b15 100644
--- a/amiga/bitmap.c
+++ b/amiga/bitmap.c
@@ -35,6 +35,7 @@
#include "utils/messages.h"
#include "desktop/mouse.h"
#include "desktop/gui_window.h"
+#include "image/bitmap.h"
#include "amiga/gui.h"
#include "amiga/bitmap.h"
@@ -42,16 +43,8 @@
#include "amiga/misc.h"
#include "amiga/rtg.h"
-/**
- * Create a bitmap.
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-
-void *bitmap_create(int width, int height, unsigned int state)
+/* exported function documented in amiga/bitmap.h */
+void *amiga_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
@@ -70,31 +63,15 @@ void *bitmap_create(int width, int height, unsigned int state)
}
-/**
- * Return a pointer to the pixel data in a bitmap.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- *
- * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
- * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
- */
-
-unsigned char *bitmap_get_buffer(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+unsigned char *amiga_bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
return bm->pixdata;
}
-
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
-
-size_t bitmap_get_rowstride(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+size_t amiga_bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -109,13 +86,8 @@ size_t bitmap_get_rowstride(void *bitmap)
}
-/**
- * Free a bitmap.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-
-void bitmap_destroy(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+void amiga_bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -142,16 +114,8 @@ void bitmap_destroy(void *bitmap)
}
-/**
- * Save a bitmap in the platform's native format.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \param path pathname for file
- * \param flags flags controlling how the bitmap is saved.
- * \return true on success, false on error and error reported
- */
-
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+/* exported function documented in amiga/bitmap.h */
+bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags)
{
int err = 0;
Object *dto = NULL;
@@ -171,12 +135,9 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
}
-/**
- * The bitmap image has changed, so flush any persistant cache.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-void bitmap_modified(void *bitmap) {
+/* exported function documented in amiga/bitmap.h */
+void amiga_bitmap_modified(void *bitmap)
+{
struct bitmap *bm = bitmap;
if((bm->nativebm) && (bm->dto == NULL))
@@ -189,13 +150,9 @@ void bitmap_modified(void *bitmap) {
bm->native_mask = NULL;
}
-/**
- * Sets whether a bitmap should be plotted opaque
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \param opaque whether the bitmap should be plotted opaque
- */
-void bitmap_set_opaque(void *bitmap, bool opaque)
+
+/* exported function documented in amiga/bitmap.h */
+void amiga_bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
assert(bitmap);
@@ -203,13 +160,8 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
}
-/**
- * Tests whether a bitmap has an opaque alpha channel
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return whether the bitmap is opaque
- */
-bool bitmap_test_opaque(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+bool amiga_bitmap_test_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
uint32 p = bm->width * bm->height;
@@ -227,19 +179,18 @@ bool bitmap_test_opaque(void *bitmap)
}
-/**
- * Gets whether a bitmap should be plotted opaque
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-bool bitmap_get_opaque(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+bool amiga_bitmap_get_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
assert(bitmap);
return bm->opaque;
}
-int bitmap_get_width(void *bitmap)
+/**
+ * get width of a bitmap.
+ */
+static int bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -253,7 +204,10 @@ int bitmap_get_width(void *bitmap)
}
}
-int bitmap_get_height(void *bitmap)
+/**
+ * get height of a bitmap.
+ */
+static int bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -274,8 +228,7 @@ int bitmap_get_height(void *bitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return bytes per pixel
*/
-
-size_t bitmap_get_bpp(void *vbitmap)
+static size_t bitmap_get_bpp(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
@@ -318,7 +271,7 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
bmhd->bmh_Width = (UWORD)bitmap_get_width(bitmap);
bmhd->bmh_Height = (UWORD)bitmap_get_height(bitmap);
bmhd->bmh_Depth = (UBYTE)bitmap_get_bpp(bitmap) * 8;
- if(!bitmap_get_opaque(bitmap)) bmhd->bmh_Masking = mskHasAlpha;
+ if(!amiga_bitmap_get_opaque(bitmap)) bmhd->bmh_Masking = mskHasAlpha;
}
SetDTAttrs(dto,NULL,NULL,
@@ -330,8 +283,8 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
PDTA_SourceMode,PMODE_V43,
TAG_DONE);
- IDoMethod(dto, PDTM_WRITEPIXELARRAY, bitmap_get_buffer(bitmap),
- PBPAFMT_RGBA, bitmap_get_rowstride(bitmap), 0, 0,
+ IDoMethod(dto, PDTM_WRITEPIXELARRAY, amiga_bitmap_get_buffer(bitmap),
+ PBPAFMT_RGBA, amiga_bitmap_get_rowstride(bitmap), 0, 0,
bitmap_get_width(bitmap), bitmap_get_height(bitmap));
}
@@ -353,13 +306,13 @@ struct bitmap *ami_bitmap_from_datatype(char *filename)
if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE))
{
- bm = bitmap_create(bmh->bmh_Width, bmh->bmh_Height, 0);
+ bm = amiga_bitmap_create(bmh->bmh_Width, bmh->bmh_Height, 0);
- IDoMethod(dto, PDTM_READPIXELARRAY, bitmap_get_buffer(bm),
- PBPAFMT_RGBA, bitmap_get_rowstride(bm), 0, 0,
+ IDoMethod(dto, PDTM_READPIXELARRAY, amiga_bitmap_get_buffer(bm),
+ PBPAFMT_RGBA, amiga_bitmap_get_rowstride(bm), 0, 0,
bmh->bmh_Width, bmh->bmh_Height);
- bitmap_set_opaque(bm, bitmap_test_opaque(bm));
+ amiga_bitmap_set_opaque(bm, amiga_bitmap_test_opaque(bm));
}
DisposeDTObject(dto);
}
@@ -477,7 +430,7 @@ PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width,
int y, x, bpr;
if((height != bitmap->height) || (width != bitmap->width)) return NULL;
- if(bitmap_get_opaque(bitmap) == true) return NULL;
+ if(amiga_bitmap_get_opaque(bitmap) == true) return NULL;
if(bitmap->native_mask) return bitmap->native_mask;
bm_width = GetBitMapAttr(n_bm, BMA_WIDTH);
@@ -552,3 +505,19 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
}
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = amiga_bitmap_create,
+ .destroy = amiga_bitmap_destroy,
+ .set_opaque = amiga_bitmap_set_opaque,
+ .get_opaque = amiga_bitmap_get_opaque,
+ .test_opaque = amiga_bitmap_test_opaque,
+ .get_buffer = amiga_bitmap_get_buffer,
+ .get_rowstride = amiga_bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = amiga_bitmap_save,
+ .modified = amiga_bitmap_modified,
+};
+
+struct gui_bitmap_table *amiga_bitmap_table = &bitmap_table;
diff --git a/amiga/bitmap.h b/amiga/bitmap.h
index 6657d2f..63969ec 100755
--- a/amiga/bitmap.h
+++ b/amiga/bitmap.h
@@ -18,7 +18,6 @@
#ifndef AMIGA_BITMAP_H
#define AMIGA_BITMAP_H
-#include "image/bitmap.h"
#include <exec/types.h>
#include <proto/graphics.h>
@@ -28,6 +27,8 @@
#define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8
#define AMI_BITMAP_FORCE_OVERWRITE 0xFF
+struct gui_bitmap_table *amiga_bitmap_table;
+
struct bitmap {
int width;
int height;
@@ -55,4 +56,81 @@ struct bitmap *ami_bitmap_from_datatype(char *filename);
void ami_bitmap_argb_to_rgba(struct bitmap *bm);
#endif
+/**
+ * Create a bitmap.
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+void *amiga_bitmap_create(int width, int height, unsigned int state);
+
+/**
+ * Return a pointer to the pixel data in a bitmap.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return pointer to the pixel buffer
+ *
+ * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
+ * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
+ */
+unsigned char *amiga_bitmap_get_buffer(void *bitmap);
+
+/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
+size_t amiga_bitmap_get_rowstride(void *bitmap);
+
+/**
+ * Free a bitmap.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+void amiga_bitmap_destroy(void *bitmap);
+
+/**
+ * Save a bitmap in the platform's native format.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \param path pathname for file
+ * \param flags flags controlling how the bitmap is saved.
+ * \return true on success, false on error and error reported
+ */
+bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags);
+
+/**
+ * The bitmap image has changed, so flush any persistant cache.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+void amiga_bitmap_modified(void *bitmap);
+
+/**
+ * Sets whether a bitmap should be plotted opaque
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \param opaque whether the bitmap should be plotted opaque
+ */
+void amiga_bitmap_set_opaque(void *bitmap, bool opaque);
+
+/**
+ * Tests whether a bitmap has an opaque alpha channel
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return whether the bitmap is opaque
+ */
+bool amiga_bitmap_test_opaque(void *bitmap);
+
+/**
+ * Gets whether a bitmap should be plotted opaque
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+bool amiga_bitmap_get_opaque(void *bitmap);
+
+
#endif
diff --git a/amiga/dt_anim.c b/amiga/dt_anim.c
index f69af31..723bd13 100644
--- a/amiga/dt_anim.c
+++ b/amiga/dt_anim.c
@@ -23,16 +23,6 @@
#ifdef WITH_AMIGA_DATATYPES
#include "amiga/os3support.h"
-#include "amiga/filetype.h"
-#include "amiga/datatypes.h"
-#include "amiga/misc.h"
-#include "amiga/plotters.h"
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-
#include <proto/datatypes.h>
#include <proto/dos.h>
#include <proto/exec.h>
@@ -44,6 +34,18 @@
#endif
#include <intuition/classusr.h>
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "content/content_protected.h"
+#include "desktop/plotters.h"
+#include "image/bitmap.h"
+
+#include "amiga/bitmap.h"
+#include "amiga/filetype.h"
+#include "amiga/datatypes.h"
+#include "amiga/misc.h"
+#include "amiga/plotters.h"
+
typedef struct amiga_dt_anim_content {
struct content base;
@@ -183,14 +185,14 @@ bool amiga_dt_anim_convert(struct content *c)
width = (int)bmh->bmh_Width;
height = (int)bmh->bmh_Height;
- plugin->bitmap = bitmap_create(width, height, bm_flags);
+ plugin->bitmap = amiga_bitmap_create(width, height, bm_flags);
if (!plugin->bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
- bm_buffer = bitmap_get_buffer(plugin->bitmap);
+ bm_buffer = amiga_bitmap_get_buffer(plugin->bitmap);
adt_frame.MethodID = ADTM_LOADFRAME;
adt_frame.alf_TimeStamp = 0;
@@ -229,7 +231,7 @@ bool amiga_dt_anim_convert(struct content *c)
content__set_title(c, title);
*/
- bitmap_modified(plugin->bitmap);
+ amiga_bitmap_modified(plugin->bitmap);
content_set_ready(c);
content_set_done(c);
@@ -245,7 +247,7 @@ void amiga_dt_anim_destroy(struct content *c)
LOG(("amiga_dt_anim_destroy"));
if (plugin->bitmap != NULL)
- bitmap_destroy(plugin->bitmap);
+ amiga_bitmap_destroy(plugin->bitmap);
DisposeDTObject(plugin->dto);
diff --git a/amiga/dt_picture.c b/amiga/dt_picture.c
index 15fc30e..b5c3ba5 100644
--- a/amiga/dt_picture.c
+++ b/amiga/dt_picture.c
@@ -23,22 +23,25 @@
#ifdef WITH_AMIGA_DATATYPES
#include "amiga/os3support.h"
-#include "amiga/bitmap.h"
-#include "amiga/filetype.h"
-#include "amiga/datatypes.h"
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
-#include "image/image_cache.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-
+#include <stdbool.h>
#include <proto/datatypes.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <datatypes/pictureclass.h>
#include <intuition/classusr.h>
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "content/content_protected.h"
+#include "desktop/plotters.h"
+#include "image/bitmap.h"
+#include "image/image_cache.h"
+
+#include "amiga/bitmap.h"
+#include "amiga/filetype.h"
+#include "amiga/datatypes.h"
+
+
static nserror amiga_dt_picture_create(const content_handler *handler,
lwc_string *imime_type, const http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
@@ -179,20 +182,21 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
if((dto = amiga_dt_picture_newdtobject(adt)))
{
- bitmap = bitmap_create(c->width, c->height, BITMAP_NEW);
+ bitmap = amiga_bitmap_create(c->width, c->height, BITMAP_NEW);
if (!bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return NULL;
}
- bm_buffer = bitmap_get_buffer(bitmap);
+ bm_buffer = amiga_bitmap_get_buffer(bitmap);
IDoMethod(dto, PDTM_READPIXELARRAY,
- bm_buffer, PBPAFMT_RGBA, bitmap_get_rowstride(bitmap),
+ bm_buffer, PBPAFMT_RGBA,
+ amiga_bitmap_get_rowstride(bitmap),
0, 0, c->width, c->height);
- bitmap_set_opaque(bitmap, bitmap_test_opaque(bitmap));
+ amiga_bitmap_set_opaque(bitmap, amiga_bitmap_test_opaque(bitmap));
DisposeDTObject(dto);
adt->dto = NULL;
diff --git a/amiga/file.c b/amiga/file.c
index e7f1fd3..307fbfc 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -188,7 +188,7 @@ void ami_file_save(int type, char *fname, struct Window *win,
if((bm = content_get_bitmap(object))) {
bm->url = (char *)nsurl_access(hlcache_handle_get_url(object));
bm->title = (char *)content_get_title(object);
- bitmap_save(bm, fname, 0);
+ amiga_bitmap_save(bm, fname, 0);
}
#ifdef WITH_NS_SVG
else if(ami_mime_compare(object, "svg") == true) {
diff --git a/amiga/gui.c b/amiga/gui.c
index dd06771..3df4d54 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -828,8 +828,8 @@ static void ami_gui_commandline(int *argc, char **argv)
p++;
} while(*p != NULL);
- char *new_argv = malloc(sizeof(char *) * new_argc);
- char **new_argvp = &new_argv;
+ const char *new_argv = malloc(sizeof(char *) * new_argc);
+ const char **new_argvp = &new_argv;
*new_argvp = messages_get("NetSurf");
p = (char **)rarray[A_NSOPTS];
@@ -3082,7 +3082,7 @@ static void ami_gui_cache_favicon(nsurl *url, struct bitmap *favicon)
STRPTR filename = NULL;
if ((filename = ami_gui_get_cache_favicon_name(url, false))) {
- if(favicon) bitmap_save(favicon, filename, AMI_BITMAP_FORCE_OVERWRITE);
+ if(favicon) amiga_bitmap_save(favicon, filename, AMI_BITMAP_FORCE_OVERWRITE);
FreeVec(filename);
}
}
@@ -5410,6 +5410,7 @@ int main(int argc, char** argv)
.search = amiga_search_table,
.search_web = &amiga_search_web_table,
.llcache = filesystem_llcache_table,
+ .bitmap = amiga_bitmap_table,
};
#ifdef __amigaos4__
diff --git a/amiga/icon.c b/amiga/icon.c
index dfbf84c..042e1a8 100644
--- a/amiga/icon.c
+++ b/amiga/icon.c
@@ -26,6 +26,7 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <proto/exec.h>
#include <proto/icon.h>
@@ -36,10 +37,6 @@
#endif
#include <workbench/icon.h>
-#include "amiga/os3support.h"
-#include "amiga/bitmap.h"
-#include "amiga/icon.h"
-#include "amiga/misc.h"
#include "desktop/plotters.h"
#include "image/bitmap.h"
#include "content/content_protected.h"
@@ -48,6 +45,11 @@
#include "utils/utils.h"
#include "utils/file.h"
+#include "amiga/os3support.h"
+#include "amiga/bitmap.h"
+#include "amiga/icon.h"
+#include "amiga/misc.h"
+
#define THUMBNAIL_WIDTH 100 /* Icon sizes for thumbnails, usually the same as */
#define THUMBNAIL_HEIGHT 86 /* WIDTH/HEIGHT in desktop/thumbnail.c */
@@ -182,14 +184,14 @@ bool amiga_icon_convert(struct content *c)
return false;
}
- icon_c->bitmap = bitmap_create(width, height, BITMAP_NEW);
+ icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NEW);
if (!icon_c->bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
if(dobj) FreeDiskObject(dobj);
return false;
}
- imagebuf = (ULONG *) bitmap_get_buffer(icon_c->bitmap);
+ imagebuf = (ULONG *) amiga_bitmap_get_buffer(icon_c->bitmap);
if (!imagebuf) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -229,7 +231,7 @@ bool amiga_icon_convert(struct content *c)
c->width = width;
c->height = height;
- bitmap_modified(icon_c->bitmap);
+ amiga_bitmap_modified(icon_c->bitmap);
content_set_ready(c);
content_set_done(c);
content_set_status(c, "");
@@ -252,7 +254,7 @@ void amiga_icon_destroy(struct content *c)
amiga_icon_content *icon_c = (amiga_icon_content *)c;
if (icon_c->bitmap != NULL)
- bitmap_destroy(icon_c->bitmap);
+ amiga_bitmap_destroy(icon_c->bitmap);
}
diff --git a/amiga/plotters.c b/amiga/plotters.c
index 899ec49..4c86f31 100644
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -510,7 +510,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
(nsoption_bool(direct_render) == false), 1)) {
uint32 comptype = COMPOSITE_Src_Over_Dest;
uint32 compflags = COMPFLAG_IgnoreDestAlpha;
- if(bitmap_get_opaque(bitmap)) {
+ if(amiga_bitmap_get_opaque(bitmap)) {
compflags |= COMPFLAG_SrcAlphaOverride;
comptype = COMPOSITE_Src;
}
diff --git a/amiga/theme.c b/amiga/theme.c
index b75f6ed..4d6107a 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -176,7 +176,7 @@ void ami_theme_throbber_setup(void)
void ami_theme_throbber_free(void)
{
- bitmap_destroy(throbber_nsbm);
+ amiga_bitmap_destroy(throbber_nsbm);
throbber = NULL;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3c61db33ffc94ee194d...
commit 3c61db33ffc94ee194dd0111a332762199334d37
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Convert atari frontend to use bitmap operation table
diff --git a/atari/bitmap.c b/atari/bitmap.c
index 3bca82e..52e515f 100755
--- a/atari/bitmap.c
+++ b/atari/bitmap.c
@@ -68,20 +68,6 @@ int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out )
/**
* Create a bitmap.
*
- * \param w width of image in pixels
- * \param h width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-
-void *bitmap_create(int w, int h, unsigned int state)
-{
- return bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, state, NULL );
-}
-
-/**
- * Create a bitmap.
- *
* \param w width of image in pixels
* \param h height of image in pixels
* \param bpp number of BYTES per pixel
@@ -90,7 +76,7 @@ void *bitmap_create(int w, int h, unsigned int state)
* \param pixdata NULL or an memory address to use as the bitmap pixdata
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata )
+static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata )
{
struct bitmap * bitmap;
@@ -128,7 +114,37 @@ void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int st
return bitmap;
}
-void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp )
+
+/* exported interface documented in atari/bitmap.h */
+void *atari_bitmap_create(int w, int h, unsigned int state)
+{
+ return atari_bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, state, NULL );
+}
+
+/**
+ * The bitmap image has changed, so flush any persistant cache.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+static void bitmap_modified(void *bitmap)
+{
+ struct bitmap *bm = bitmap;
+ if( bm->resized != NULL ) {
+ atari_bitmap_destroy( bm->resized );
+ bm->resized = NULL;
+ }
+ if( bm->converted ){
+ if( bm->pixdata != bm->native.fd_addr ){
+ free( bm->native.fd_addr );
+ }
+ bm->native.fd_addr = NULL;
+ bm->converted = false;
+ }
+}
+
+
+/* exported interface documented in atari/bitmap.h */
+void *atari_bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp )
{
struct bitmap * bitmap = bmp;
int newsize = rowstride * h;
@@ -163,46 +179,6 @@ void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int stat
return( bitmap );
}
-void bitmap_to_mfdb(void * bitmap, MFDB * out)
-{
- struct bitmap * bm;
- uint8_t * tmp;
- size_t dststride, oldstride;
-
- bm = bitmap;
- assert( out != NULL );
- assert( bm->pixdata != NULL );
-
- oldstride = bitmap_get_rowstride( bm );
- dststride = MFDB_STRIDE( bm->width );
-
- if( oldstride != dststride * bm->bpp )
- {
- assert( oldstride <= dststride );
- /* we need to convert the img to new rowstride */
- tmp = bm->pixdata;
- bm->pixdata = calloc(1, dststride * bm->bpp * bm->height );
- if( tmp == NULL ){
- bm->pixdata = tmp;
- out->fd_addr = NULL;
- return;
- }
- bm->rowstride = dststride * bm->bpp;
- int i=0;
- for( i=0; i<bm->height; i++) {
- memcpy( (bm->pixdata+i*bm->rowstride), (tmp + i*oldstride), oldstride);
- }
- free( tmp );
- }
- out->fd_w = dststride;
- out->fd_h = bm->height;
- out->fd_wdwidth = dststride >> 4;
- out->fd_addr = bm->pixdata;
- out->fd_stand = 0;
- out->fd_nplanes = (short)bm->bpp;
- out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
-}
-
/**
* Return a pointer to the pixel data in a bitmap.
@@ -213,8 +189,7 @@ void bitmap_to_mfdb(void * bitmap, MFDB * out)
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-
-unsigned char * bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -226,7 +201,9 @@ unsigned char * bitmap_get_buffer(void *bitmap)
return bm->pixdata;
}
-size_t bitmap_buffer_size( void * bitmap )
+
+/* exported interface documented in atari/bitmap.h */
+size_t atari_bitmap_buffer_size(void *bitmap)
{
struct bitmap * bm = bitmap;
if( bm == NULL )
@@ -235,14 +212,8 @@ size_t bitmap_buffer_size( void * bitmap )
}
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
-
-size_t bitmap_get_rowstride(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+size_t atari_bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -254,13 +225,8 @@ size_t bitmap_get_rowstride(void *bitmap)
}
-/**
- * Free a bitmap.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-
-void bitmap_destroy(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+void atari_bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -270,10 +236,11 @@ void bitmap_destroy(void *bitmap)
}
if( bm->resized != NULL ) {
- bitmap_destroy(bm->resized);
+ atari_bitmap_destroy(bm->resized);
}
- if( bm->converted && ( bm->native.fd_addr != bm->pixdata ) )
+ if( bm->converted && ( bm->native.fd_addr != bm->pixdata ) ) {
free( bm->native.fd_addr );
+ }
free(bm->pixdata);
free(bm);
}
@@ -288,32 +255,11 @@ void bitmap_destroy(void *bitmap)
* \return true on success, false on error and error reported
*/
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
-/**
- * The bitmap image has changed, so flush any persistant cache.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-void bitmap_modified(void *bitmap)
-{
- struct bitmap *bm = bitmap;
- if( bm->resized != NULL ) {
- bitmap_destroy( bm->resized );
- bm->resized = NULL;
- }
- if( bm->converted ){
- if( bm->pixdata != bm->native.fd_addr ){
- free( bm->native.fd_addr );
- }
- bm->native.fd_addr = NULL;
- bm->converted = false;
- }
-
-}
/**
* Sets whether a bitmap should be plotted opaque
@@ -321,7 +267,7 @@ void bitmap_modified(void *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
@@ -341,7 +287,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
int tst;
struct bitmap *bm = bitmap;
@@ -368,12 +314,8 @@ bool bitmap_test_opaque(void *bitmap)
}
-/**
- * Gets whether a bitmap should be plotted opaque
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-bool bitmap_get_opaque(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+bool atari_bitmap_get_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -385,7 +327,9 @@ bool bitmap_get_opaque(void *bitmap)
return bm->opaque;
}
-int bitmap_get_width(void *bitmap)
+
+/* exported interface documented in atari/bitmap.h */
+int atari_bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -397,7 +341,9 @@ int bitmap_get_width(void *bitmap)
return(bm->width);
}
-int bitmap_get_height(void *bitmap)
+
+/* exported interface documented in atari/bitmap.h */
+int atari_bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -410,27 +356,26 @@ int bitmap_get_height(void *bitmap)
/**
-*
-* Gets the number of BYTES per pixel.
-*
-*/
-size_t bitmap_get_bpp(void *bitmap)
+ * Gets the number of BYTES per pixel.
+ */
+static size_t bitmap_get_bpp(void *bitmap)
{
struct bitmap *bm = bitmap;
return bm->bpp;
}
-bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
+/* exported interface documented in atari/bitmap.h */
+bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
HermesFormat *fmt, int nw, int nh)
{
unsigned int state = 0;
short bpp = bitmap_get_bpp( img );
- int stride = bitmap_get_rowstride( img );
+ int stride = atari_bitmap_get_rowstride( img );
int err;
if( img->resized != NULL ) {
if( img->resized->width != nw || img->resized->height != nh ) {
- bitmap_destroy( img->resized );
+ atari_bitmap_destroy( img->resized );
img->resized = NULL;
} else {
/* the bitmap is already resized */
@@ -442,7 +387,7 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
if (img->opaque == true) {
state |= BITMAP_OPAQUE;
}
- img->resized = bitmap_create_ex( nw, nh, bpp, nw*bpp, state, NULL );
+ img->resized = atari_bitmap_create_ex( nw, nh, bpp, nw*bpp, state, NULL );
if( img->resized == NULL ) {
printf("W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
assert(img->resized);
@@ -460,18 +405,19 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
err = Hermes_ConverterCopy( hermes_h,
img->pixdata,
- 0, /* x src coord of top left in pixel coords */
- 0, /* y src coord of top left in pixel coords */
- bitmap_get_width( img ), bitmap_get_height( img ),
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ atari_bitmap_get_width( img ),
+ atari_bitmap_get_height( img ),
stride, /* stride as bytes */
img->resized->pixdata,
- 0, /* x dst coord of top left in pixel coords */
- 0, /* y dst coord of top left in pixel coords */
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
nw, nh,
- bitmap_get_rowstride(img->resized) /* stride as bytes */
+ atari_bitmap_get_rowstride(img->resized) /* stride as bytes */
);
if( err == 0 ) {
- bitmap_destroy( img->resized );
+ atari_bitmap_destroy( img->resized );
img->resized = NULL;
return(false);
}
@@ -479,6 +425,23 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
return(true);
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = atari_bitmap_create,
+ .destroy = atari_bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = atari_bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = atari_bitmap_get_rowstride,
+ .get_width = atari_bitmap_get_width,
+ .get_height = atari_bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *atari_bitmap_table = &bitmap_table;
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/atari/bitmap.h b/atari/bitmap.h
index ed80938..b0fa180 100755
--- a/atari/bitmap.h
+++ b/atari/bitmap.h
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Atari bitmap handling implementation.
+ */
+
#ifndef NS_ATARI_BITMAP_H
#define NS_ATARI_BITMAP_H
@@ -24,33 +29,33 @@
#define NS_BMP_DEFAULT_BPP 4
-/* Flags for init_mfdb function: */
-#define MFDB_FLAG_STAND 0x01
-#define MFDB_FLAG_ZEROMEM 0x02
-#define MFDB_FLAG_NOALLOC 0x04
+/* Flags for init_mfdb function: */
+#define MFDB_FLAG_STAND 0x01
+#define MFDB_FLAG_ZEROMEM 0x02
+#define MFDB_FLAG_NOALLOC 0x04
-#define BITMAP_SHRINK 0
-#define BITMAP_GROW 1024 /* Don't realloc when bitmap size shrinks */
-#define BITMAP_CLEAR 2048 /* Zero bitmap memory */
+#define BITMAP_SHRINK 0
+#define BITMAP_GROW 1024 /* Don't realloc when bitmap size shrinks */
+#define BITMAP_CLEAR 2048 /* Zero bitmap memory */
-/*
- calculates MFDB compatible rowstride (in number of bits)
-*/
+/**
+ * Calculates MFDB compatible rowstride (in number of bits)
+ */
#define MFDB_STRIDE( w ) (((w & 15) != 0) ? (w | 15)+1 : w)
-/*
-Calculate size of an mfdb,
-
- params:
-
- bpp: Bits per pixel,
- stride: Word aligned rowstride (width) as returned by MFDB_STRIDE,
- h: Height in pixels
+/**
+ * Calculate size of an mfdb,
+ *
+ * \param bpp Bits per pixel.
+ * \param stride Word aligned rowstride (width) as returned by MFDB_STRIDE,
+ * \param h Height in pixels.
*/
#define MFDB_SIZE( bpp, stride, h ) ( ((stride >> 3) * h) * bpp )
+struct gui_bitmap_table *atari_bitmap_table;
+
struct bitmap {
int width;
int height;
@@ -63,20 +68,70 @@ struct bitmap {
bool converted;
};
-void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata );
-void bitmap_to_mfdb(void * bitmap, MFDB * out);
-void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp );
-size_t bitmap_buffer_size( void * bitmap ) ;
-bool bitmap_resize(struct bitmap * img, HermesHandle hermes_h,
- HermesFormat *fmt, int nw, int nh);
-/*
- setup an MFDB struct and allocate memory for it when it is needed.
- If bpp == 0, this function assumes that the MFDB shall point to the screen
- and will not allocate any memory (mfdb.fd_addr == 0).
- The function will return 0 when the memory allocation fails
- ( out of memory), otherwise it returns the size of the mfdb.fd_addr
- as number of bytes.
-*/
+
+
+/**
+ * setup an MFDB struct and allocate memory for it when it is needed.
+ *
+ * If bpp == 0, this function assumes that the MFDB shall point to the
+ * screen and will not allocate any memory (mfdb.fd_addr == 0).
+ *
+ * \return 0 when the memory allocation fails (out of memory),
+ * otherwise it returns the size of the mfdb.fd_addr as number
+ * of bytes.
+ */
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out );
+/**
+ * Create a bitmap.
+ *
+ * \param w width of image in pixels
+ * \param h width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+void *atari_bitmap_create(int w, int h, unsigned int state);
+
+/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
+size_t atari_bitmap_get_rowstride(void *bitmap);
+
+/**
+ * Free a bitmap.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+void atari_bitmap_destroy(void *bitmap);
+
+/**
+ * Get bitmap width
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+int atari_bitmap_get_width(void *bitmap);
+
+/**
+ * Get bitmap height
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+int atari_bitmap_get_height(void *bitmap);
+
+/**
+ * Gets whether a bitmap should be plotted opaque
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+bool atari_bitmap_get_opaque(void *bitmap);
+
+size_t atari_bitmap_buffer_size(void *bitmap);
+
+bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h, HermesFormat *fmt, int nw, int nh);
+
+void *atari_bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp );
+
#endif
diff --git a/atari/gui.c b/atari/gui.c
index 3cd22e6..daf342a 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -77,6 +77,7 @@
#include "atari/download.h"
#include "atari/file.h"
#include "atari/filetype.h"
+#include "atari/bitmap.h"
#include "cflib.h"
static bool atari_quit = false;
@@ -1130,7 +1131,8 @@ int main(int argc, char** argv)
.file = atari_file_table,
.utf8 = atari_utf8_table,
.search = atari_search_table,
- .llcache = filesystem_llcache_table
+ .llcache = filesystem_llcache_table,
+ .bitmap = atari_bitmap_table
};
ret = netsurf_register(&atari_table);
diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c
index b88505d..c4d7748 100755
--- a/atari/plot/font_freetype.c
+++ b/atari/plot/font_freetype.c
@@ -94,23 +94,23 @@ fantasy.ttf => Fantasy
#define CACHE_MIN_SIZE (100 * 1024)
#define BOLD_WEIGHT 700
-extern unsigned long atari_plot_flags;
-extern int atari_plot_vdi_handle;
-
-static FT_Library library;
-static FTC_Manager ft_cmanager;
-static FTC_CMapCache ft_cmap_cache ;
-static FTC_ImageCache ft_image_cache;
-
-int ft_load_type;
-
-/* cache manager faceID data to create freetype faceid on demand */
-typedef struct ftc_faceid_s {
- char *fontfile; /* path to font */
- int index; /* index of font */
- int cidx; /* character map index for unicode */
-} ftc_faceid_t;
-
+extern unsigned long atari_plot_flags;
+extern int atari_plot_vdi_handle;
+
+static FT_Library library;
+static FTC_Manager ft_cmanager;
+static FTC_CMapCache ft_cmap_cache ;
+static FTC_ImageCache ft_image_cache;
+
+int ft_load_type;
+
+/* cache manager faceID data to create freetype faceid on demand */
+typedef struct ftc_faceid_s {
+ char *fontfile; /* path to font */
+ int index; /* index of font */
+ int cidx; /* character map index for unicode */
+} ftc_faceid_t;
+
static int dtor( FONT_PLOTTER self );
static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle,
const char * str, size_t length, int * width );
@@ -608,10 +608,10 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
#ifdef WITH_8BPP_SUPPORT
if( app.nplanes > 8 ){
#endif
- RGB1000 out;
+ RGB1000 out; /* struct with RGB shorts */
rgb_to_vdi1000( (unsigned char*)&c, &out);
vs_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR,
- (unsigned short*)&out);
+ (short*)&out);
#ifdef WITH_8BPP_SUPPORT
} else {
c = RGB_TO_VDI(c);
@@ -625,10 +625,10 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
clip.g_w = (clipping.x1 - clipping.x0)+1;
clip.g_h = (clipping.y1 - clipping.y0)+1;
- fontbmp = bitmap_realloc( clip.g_w, clip.g_h,
+ fontbmp = atari_bitmap_realloc( clip.g_w, clip.g_h,
4, clip.g_w << 2,
BITMAP_GROW, fontbmp );
- fontbmp_stride = bitmap_get_rowstride(fontbmp);
+ fontbmp_stride = atari_bitmap_get_rowstride(fontbmp);
fontbmp_allocated_height = clip.g_h;
fontbmp_allocated_width = clip.g_w;
@@ -684,7 +684,7 @@ int ctor_font_plotter_freetype( FONT_PLOTTER self )
LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
if( !init ) {
ft_font_init();
- fontbmp = bitmap_create(48, 48, 0);
+ fontbmp = atari_bitmap_create(48, 48, 0);
fontbmp->opaque = false;
init = true;
}
@@ -696,7 +696,7 @@ static int dtor( FONT_PLOTTER self )
{
ft_font_finalise();
if( fontbmp != NULL ) {
- bitmap_destroy( fontbmp );
+ atari_bitmap_destroy( fontbmp );
fontbmp = NULL;
}
if( tmp.fd_addr != NULL ){
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 0a8619f..427444d 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -95,7 +95,7 @@ int ctor_font_plotter_internal( FONT_PLOTTER self )
LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
if( !init ) {
vdih = self->vdi_handle;
- fontbmp = bitmap_create(48, 48, 0);
+ fontbmp = atari_bitmap_create(48, 48, 0);
fontbmp->opaque = false;
}
init = true;
@@ -164,8 +164,8 @@ static void draw_glyph1(FONT_PLOTTER self, GRECT *inloc, uint8_t *chrp, int pitc
uint32_t * linebuf;
GRECT loc = *inloc;
- fontbmp = bitmap_realloc( loc.g_w, loc.g_h, fontbmp->bpp, loc.g_w * fontbmp->bpp, BITMAP_GROW, fontbmp );
- bmpstride = bitmap_get_rowstride(fontbmp);
+ fontbmp = atari_bitmap_realloc( loc.g_w, loc.g_h, fontbmp->bpp, loc.g_w * fontbmp->bpp, BITMAP_GROW, fontbmp );
+ bmpstride = atari_bitmap_get_rowstride(fontbmp);
for( yloop = 0; yloop < loc.g_h; yloop++) {
uint32_t pixmask = 1 ;
linebuf = (uint32_t *)(fontbmp->pixdata + (bmpstride * yloop));
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 1b949d2..523ce44 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -164,11 +164,11 @@ struct s_vdi_sysinfo vdi_sysinfo;
static int atari_plot_bpp_virt;
static struct s_view view;
-static HermesHandle hermes_pal_h; /* hermes palette handle */
+//static HermesHandle hermes_pal_h; /* hermes palette handle */
static HermesHandle hermes_cnv_h; /* hermes converter instance handle */
static HermesHandle hermes_res_h;
-static short prev_vdi_clip[4];
+//static short prev_vdi_clip[4];
static struct bitmap snapshot;
VdiHdl atari_plot_vdi_handle = -1;
@@ -195,10 +195,9 @@ inline static void vsl_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- //unsigned short c[4];
- RGB1000 c;
+ RGB1000 c; /* a struct with three (RGB) shorts */
rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color(vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vs_color(vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
vsl_color(vdih, OFFSET_CUSTOM_COLOR);
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -222,9 +221,9 @@ inline static void vsf_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- RGB1000 c;
+ RGB1000 c; /* a struct with three (RGB) shorts */
rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
vsf_color( vdih, OFFSET_CUSTOM_COLOR );
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -383,15 +382,17 @@ bool plot_copy_rect(GRECT src, GRECT dst)
/**
* Fill the screen info structure.
*
+ * \param vdhi The handle
+ * \param[out] info The infor structure to fill.
*/
-static struct s_vdi_sysinfo * read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
+static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
- unsigned long cookie_EdDI=0;
+ unsigned long cookie_EdDI=0; /** \todo this long is being cast to a pointer */
short out[300];
memset( info, 0, sizeof(struct s_vdi_sysinfo) );
info->vdi_handle = vdih;
- if ( tos_getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND ) {
+ if ( tos_getcookie(C_EdDI, (long *)&cookie_EdDI) == C_NOTFOUND ) {
info->EdDiVersion = 0;
} else {
info->EdDiVersion = EdDI_version( (void *)cookie_EdDI );
@@ -668,20 +669,20 @@ static void dump_vdi_info(short vdih)
printf(" short scr_h: %d\n", temp.scr_h);
printf(" short scr_bpp: %d\n", temp.scr_bpp);
printf(" int colors: %d\n", temp.colors);
- printf(" ulong hicolors: %d\n", temp.hicolors);
+ printf(" ulong hicolors: %lu\n", temp.hicolors);
printf(" short pixelsize: %d\n", temp.pixelsize);
printf(" unsigned short pitch: %d\n", temp.pitch);
printf(" unsigned short vdiformat: %d\n", temp.vdiformat);
printf(" unsigned short clut: %d\n", temp.clut);
printf(" void * screen: 0x0%p\n", temp.screen);
- printf(" unsigned long screensize: %d\n", temp.screensize);
- printf(" unsigned long mask_r: 0x0%08x\n", temp.mask_r);
- printf(" unsigned long mask_g: 0x0%08x\n", temp.mask_g);
- printf(" unsigned long mask_b: 0x0%08x\n", temp.mask_b);
- printf(" unsigned long mask_a: 0x0%08x\n", temp.mask_a);
+ printf(" unsigned long screensize: %lu\n", temp.screensize);
+ printf(" unsigned long mask_r: 0x0%08lx\n", temp.mask_r);
+ printf(" unsigned long mask_g: 0x0%08lx\n", temp.mask_g);
+ printf(" unsigned long mask_b: 0x0%08lx\n", temp.mask_b);
+ printf(" unsigned long mask_a: 0x0%08lx\n", temp.mask_a);
printf(" short maxintin: %d\n", temp.maxintin);
printf(" short maxpolycoords: %d\n", temp.maxpolycoords);
- printf(" unsigned long EdDiVersion: 0x0%03x\n", temp.EdDiVersion);
+ printf(" unsigned long EdDiVersion: 0x0%03lx\n", temp.EdDiVersion);
printf(" unsigned short rasterscale: 0x%2x\n", temp.rasterscale);
printf("};\n");
}
@@ -800,9 +801,9 @@ static struct bitmap * snapshot_create(int x, int y, int w, int h)
/* allocate buffer for result bitmap: */
if(buf_scr_compat == NULL ) {
- buf_scr_compat = bitmap_create(w, h, 0);
+ buf_scr_compat = atari_bitmap_create(w, h, 0);
} else {
- buf_scr_compat = bitmap_realloc( w, h,
+ buf_scr_compat = atari_bitmap_realloc( w, h,
buf_scr_compat->bpp,
w *buf_scr_compat->bpp,
BITMAP_GROW,
@@ -825,7 +826,7 @@ static struct bitmap * snapshot_create(int x, int y, int w, int h)
0, /* x dst coord of top left in pixel coords */
0, /* y dst coord of top left in pixel coords */
w, h,
- bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
+ atari_bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
);
assert( err != 0 );
return( (struct bitmap * )buf_scr_compat );
@@ -879,13 +880,13 @@ static void snapshot_suspend(void)
#endif
if(buf_scr_compat != NULL ) {
- size_t bs = bitmap_buffer_size(buf_scr_compat );
+ size_t bs = atari_bitmap_buffer_size(buf_scr_compat );
if( bs > CONV_KEEP_LIMIT ) {
int w = 0;
int h = 1;
w = (CONV_KEEP_LIMIT /buf_scr_compat->bpp);
assert( CONV_KEEP_LIMIT == w*buf_scr_compat->bpp );
- buf_scr_compat = bitmap_realloc( w, h,
+ buf_scr_compat = atari_bitmap_realloc( w, h,
buf_scr_compat->bpp,
CONV_KEEP_LIMIT, BITMAP_SHRINK,buf_scr_compat
);
@@ -901,7 +902,7 @@ static void snapshot_destroy(void)
free(buf_scr.fd_addr);
if( buf_scr_compat != NULL) {
- bitmap_destroy(buf_scr_compat);
+ atari_bitmap_destroy(buf_scr_compat);
}
buf_scr.fd_addr = NULL;
@@ -938,7 +939,7 @@ inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip)
uint32_t * imgrow;
int img_x, img_y, img_stride;
- img_stride= bitmap_get_rowstride(img);
+ img_stride= atari_bitmap_get_rowstride(img);
for( img_y = 0; img_y < clip->g_h; img_y++) {
imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
@@ -963,8 +964,8 @@ inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg,
int img_x, img_y, bg_x, bg_y, img_stride, bg_stride;
bg_clip = bg_clip;
- img_stride= bitmap_get_rowstride(img);
- bg_stride = bitmap_get_rowstride(bg);
+ img_stride = atari_bitmap_get_rowstride(img);
+ bg_stride = atari_bitmap_get_rowstride(bg);
for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
@@ -1018,7 +1019,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
int bw, bh;
struct bitmap * scrbuf = NULL;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = bitmap_get_opaque( img );
+ bool opaque = atari_bitmap_get_opaque( img );
if( opaque == false ){
if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
@@ -1031,8 +1032,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bw = bitmap_get_width( img );
- bh = bitmap_get_height( img );
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, when
// the bitmap is fully opaque
@@ -1080,7 +1081,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
native.fd_addr = (void*)malloc( dstsize );
if (native.fd_addr == NULL){
if (scrbuf != NULL)
- bitmap_destroy(scrbuf);
+ atari_bitmap_destroy(scrbuf);
return( 0-ERR_NO_MEM );
}
}
@@ -1119,7 +1120,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
stdform.fd_nplanes = (short)atari_plot_bpp_virt;
stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0;
- int img_stride = bitmap_get_rowstride(img);
+ int img_stride = atari_bitmap_get_rowstride(img);
uint32_t prev_pixel = 0x12345678; //TODO: check for collision in first pixel
unsigned long col = 0;
unsigned char val = 0;
@@ -1233,7 +1234,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
struct bitmap * scrbuf = NULL;
struct bitmap * source = NULL;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = bitmap_get_opaque( img );
+ bool opaque = atari_bitmap_get_opaque( img );
if( opaque == false ){
if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
@@ -1247,8 +1248,8 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bw = bitmap_get_width( img );
- bh = bitmap_get_height( img );
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, WHEN:
// A.) the bitmap is fully opaque OR
@@ -1319,7 +1320,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
assert( buf_packed );
if( buf_packed == NULL ) {
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
+ atari_bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
size_buf_packed = blocks * CONV_BLOCK_SIZE;
@@ -1330,7 +1331,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
out->fd_addr = (void*)malloc( dstsize );
if( out->fd_addr == NULL ){
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
+ atari_bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
}
@@ -1456,8 +1457,8 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor,
uint32_t flags)
{
-
- MFDB screen, tran;
+ MFDB screen;
+// MFDB tran;
MFDB * src;
short pxy[8];
short c[2] = {fgcolor, 0};
@@ -1674,6 +1675,8 @@ int plot_finalise( void )
free(buf_packed );
free(buf_planar);
snapshot_destroy();
+
+ return 0;
}
bool plot_lock(void)
@@ -2146,8 +2149,8 @@ static bool plot_bitmap(int x, int y, int width, int height,
int bmpw,bmph;
struct rect clip = {0,0,0,0};
- bmpw = bitmap_get_width(bitmap);
- bmph = bitmap_get_height(bitmap);
+ bmpw = atari_bitmap_get_width(bitmap);
+ bmph = atari_bitmap_get_height(bitmap);
if(view.scale != 1.0){
width = (int)(((float)width)*view.scale);
@@ -2167,7 +2170,7 @@ static bool plot_bitmap(int x, int y, int width, int height,
}
if( width != bmpw || height != bmph ) {
- bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height );
+ atari_bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height );
if( bitmap->resized )
bm = bitmap->resized;
else
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ad18ef5db99eb38075e...
commit ad18ef5db99eb38075e6e49246b097a8ba727ab8
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update RISC OS frontend to use bitmap operation table
diff --git a/riscos/bitmap.c b/riscos/bitmap.c
index 2c700ec..c232f20 100644
--- a/riscos/bitmap.c
+++ b/riscos/bitmap.c
@@ -30,22 +30,24 @@
#include <string.h>
#include <swis.h>
#include <unixlib/local.h>
-#include "oslib/osfile.h"
-#include "oslib/osfind.h"
-#include "oslib/osgbpb.h"
-#include "oslib/osspriteop.h"
-#include "oslib/wimp.h"
+#include <oslib/osfile.h>
+#include <oslib/osfind.h>
+#include <oslib/osgbpb.h>
+#include <oslib/osspriteop.h>
+#include <oslib/wimp.h>
+
+#include "utils/nsoption.h"
+#include "utils/filename.h"
+#include "utils/log.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "image/bitmap.h"
-#include "riscos/bitmap.h"
+
#include "riscos/image.h"
-#include "utils/nsoption.h"
#include "riscos/palettes.h"
#include "riscos/content-handlers/sprite.h"
#include "riscos/tinct.h"
-#include "utils/filename.h"
-#include "utils/log.h"
-#include "utils/utils.h"
+#include "riscos/bitmap.h"
/** Colour in the overlay sprite that allows the bitmap to show through */
#define OVERLAY_INDEX 0xfe
@@ -109,8 +111,7 @@ static bool bitmap_initialise(struct bitmap *bitmap)
* \param state the state to create the bitmap in.
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+void *riscos_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
@@ -129,91 +130,30 @@ void *bitmap_create(int width, int height, unsigned int state)
/**
- * Overlay a sprite onto the given bitmap
+ * Return a pointer to the pixel data in a bitmap.
*
- * \param bitmap bitmap object
- * \param s 8bpp sprite to be overlayed onto bitmap
+ * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
+ * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ * \return pointer to the pixel buffer
*/
-
-void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
+unsigned char *riscos_bitmap_get_buffer(void *vbitmap)
{
- const os_colour *palette;
- const byte *sp, *mp;
- bool masked = false;
- bool alpha = false;
- os_error *error;
- int dp_offset;
- int sp_offset;
- unsigned *dp;
- int x, y;
- int w, h;
-
- assert(sprite_bpp(s) == 8);
-
- if ((unsigned)s->mode & 0x80000000U)
- alpha = true;
+ struct bitmap *bitmap = (struct bitmap *) vbitmap;
+ assert(bitmap);
- error = xosspriteop_read_sprite_info(osspriteop_PTR,
- (osspriteop_area *)0x100,
- (osspriteop_id)s,
- &w, &h, NULL, NULL);
- if (error) {
- LOG(("xosspriteop_read_sprite_info: 0x%x:%s",
- error->errnum, error->errmess));
- return;
+ /* dynamically create the buffer */
+ if (bitmap->sprite_area == NULL) {
+ if (!bitmap_initialise(bitmap))
+ return NULL;
}
- sp_offset = ((s->width + 1) * 4) - w;
-
- if (w > bitmap->width)
- w = bitmap->width;
- if (h > bitmap->height)
- h = bitmap->height;
-
- dp_offset = bitmap_get_rowstride(bitmap) / 4;
-
- dp = (void*)bitmap_get_buffer(bitmap);
- if (!dp)
- return;
- sp = (byte*)s + s->image;
- mp = (byte*)s + s->mask;
-
- sp += s->left_bit / 8;
- mp += s->left_bit / 8;
-
- if (s->image > (int)sizeof(*s))
- palette = (os_colour*)(s + 1);
- else
- palette = default_palette8;
- if (s->mask != s->image) {
- masked = true;
- bitmap_set_opaque(bitmap, false);
- }
+ /* image data area should exist */
+ if (bitmap->sprite_area)
+ return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44;
- /* (partially-)transparent pixels in the overlayed sprite retain
- * their transparency in the output bitmap; opaque sprite pixels
- * are also propagated to the bitmap, except those which are the
- * OVERLAY_INDEX colour which allow the original bitmap contents to
- * show through */
- for (y = 0; y < h; y++) {
- unsigned *sdp = dp;
- for(x = 0; x < w; x++) {
- os_colour d = ((unsigned)palette[(*sp) << 1]) >> 8;
- if (*sp++ == OVERLAY_INDEX)
- d = *dp;
- if (masked) {
- if (alpha)
- d |= ((*mp << 24) ^ 0xff000000U);
- else if (*mp)
- d |= 0xff000000U;
- }
- *dp++ = d;
- mp++;
- }
- dp = sdp + dp_offset;
- sp += sp_offset;
- mp += sp_offset;
- }
+ return NULL;
}
@@ -223,7 +163,7 @@ void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *vbitmap, bool opaque)
+static void bitmap_set_opaque(void *vbitmap, bool opaque)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
assert(bitmap);
@@ -236,12 +176,25 @@ void bitmap_set_opaque(void *vbitmap, bool opaque)
/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
+size_t riscos_bitmap_get_rowstride(void *vbitmap)
+{
+ struct bitmap *bitmap = (struct bitmap *) vbitmap;
+ return bitmap->width * 4;
+}
+
+
+/**
* Tests whether a bitmap has an opaque alpha channel
*
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *vbitmap)
+static bool bitmap_test_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
unsigned char *sprite;
@@ -251,11 +204,11 @@ bool bitmap_test_opaque(void *vbitmap)
assert(bitmap);
- sprite = bitmap_get_buffer(bitmap);
+ sprite = riscos_bitmap_get_buffer(bitmap);
if (!sprite)
return false;
- width = bitmap_get_rowstride(bitmap);
+ width = riscos_bitmap_get_rowstride(bitmap);
sprite_header = (osspriteop_header *) (bitmap->sprite_area + 1);
@@ -289,7 +242,7 @@ bool bitmap_test_opaque(void *vbitmap)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *vbitmap)
+bool riscos_bitmap_get_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
assert(bitmap);
@@ -298,55 +251,11 @@ bool bitmap_get_opaque(void *vbitmap)
/**
- * Return a pointer to the pixel data in a bitmap.
- *
- * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
- * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- */
-
-unsigned char *bitmap_get_buffer(void *vbitmap)
-{
- struct bitmap *bitmap = (struct bitmap *) vbitmap;
- assert(bitmap);
-
- /* dynamically create the buffer */
- if (bitmap->sprite_area == NULL) {
- if (!bitmap_initialise(bitmap))
- return NULL;
- }
-
- /* image data area should exist */
- if (bitmap->sprite_area)
- return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44;
-
- return NULL;
-}
-
-
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
-
-size_t bitmap_get_rowstride(void *vbitmap)
-{
- struct bitmap *bitmap = (struct bitmap *) vbitmap;
- return bitmap->width * 4;
-}
-
-
-/**
* Free a bitmap.
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *vbitmap)
+void riscos_bitmap_destroy(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -369,18 +278,18 @@ void bitmap_destroy(void *vbitmap)
* \param flags modify the behaviour of the save
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
+bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
os_error *error;
- if (!bitmap->sprite_area)
- bitmap_get_buffer(bitmap);
+ if (!bitmap->sprite_area) {
+ riscos_bitmap_get_buffer(bitmap);
+ }
if (!bitmap->sprite_area)
return false;
- if (bitmap_get_opaque(bitmap)) {
+ if (riscos_bitmap_get_opaque(bitmap)) {
error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
(bitmap->sprite_area), path);
if (error) {
@@ -539,20 +448,21 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *vbitmap) {
+void riscos_bitmap_modified(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
bitmap->state |= BITMAP_MODIFIED;
}
-int bitmap_get_width(void *vbitmap)
+int riscos_bitmap_get_width(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
return bitmap->width;
}
-int bitmap_get_height(void *vbitmap)
+int riscos_bitmap_get_height(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
return bitmap->height;
@@ -565,11 +475,113 @@ int bitmap_get_height(void *vbitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return bytes per pixel
*/
-
-size_t bitmap_get_bpp(void *vbitmap)
+static size_t bitmap_get_bpp(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
return 4;
}
+/**
+ * Overlay a sprite onto the given bitmap
+ *
+ * \param bitmap bitmap object
+ * \param s 8bpp sprite to be overlayed onto bitmap
+ */
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
+{
+ const os_colour *palette;
+ const byte *sp, *mp;
+ bool masked = false;
+ bool alpha = false;
+ os_error *error;
+ int dp_offset;
+ int sp_offset;
+ unsigned *dp;
+ int x, y;
+ int w, h;
+
+ assert(sprite_bpp(s) == 8);
+
+ if ((unsigned)s->mode & 0x80000000U)
+ alpha = true;
+
+ error = xosspriteop_read_sprite_info(osspriteop_PTR,
+ (osspriteop_area *)0x100,
+ (osspriteop_id)s,
+ &w, &h, NULL, NULL);
+ if (error) {
+ LOG(("xosspriteop_read_sprite_info: 0x%x:%s",
+ error->errnum, error->errmess));
+ return;
+ }
+ sp_offset = ((s->width + 1) * 4) - w;
+
+ if (w > bitmap->width)
+ w = bitmap->width;
+ if (h > bitmap->height)
+ h = bitmap->height;
+
+ dp_offset = riscos_bitmap_get_rowstride(bitmap) / 4;
+
+ dp = (void*)riscos_bitmap_get_buffer(bitmap);
+ if (!dp)
+ return;
+ sp = (byte*)s + s->image;
+ mp = (byte*)s + s->mask;
+
+ sp += s->left_bit / 8;
+ mp += s->left_bit / 8;
+
+ if (s->image > (int)sizeof(*s))
+ palette = (os_colour*)(s + 1);
+ else
+ palette = default_palette8;
+
+ if (s->mask != s->image) {
+ masked = true;
+ bitmap_set_opaque(bitmap, false);
+ }
+
+ /* (partially-)transparent pixels in the overlayed sprite retain
+ * their transparency in the output bitmap; opaque sprite pixels
+ * are also propagated to the bitmap, except those which are the
+ * OVERLAY_INDEX colour which allow the original bitmap contents to
+ * show through */
+ for (y = 0; y < h; y++) {
+ unsigned *sdp = dp;
+ for(x = 0; x < w; x++) {
+ os_colour d = ((unsigned)palette[(*sp) << 1]) >> 8;
+ if (*sp++ == OVERLAY_INDEX)
+ d = *dp;
+ if (masked) {
+ if (alpha)
+ d |= ((*mp << 24) ^ 0xff000000U);
+ else if (*mp)
+ d |= 0xff000000U;
+ }
+ *dp++ = d;
+ mp++;
+ }
+ dp = sdp + dp_offset;
+ sp += sp_offset;
+ mp += sp_offset;
+ }
+}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = riscos_bitmap_create,
+ .destroy = riscos_bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = riscos_bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = riscos_bitmap_get_buffer,
+ .get_rowstride = riscos_bitmap_get_rowstride,
+ .get_width = riscos_bitmap_get_width,
+ .get_height = riscos_bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = riscos_bitmap_save,
+ .modified = riscos_bitmap_modified,
+};
+
+struct gui_bitmap_table *riscos_bitmap_table = &bitmap_table;
diff --git a/riscos/bitmap.h b/riscos/bitmap.h
index 1b7d1b9..1ae50fd 100644
--- a/riscos/bitmap.h
+++ b/riscos/bitmap.h
@@ -19,11 +19,15 @@
#ifndef _NETSURF_RISCOS_BITMAP_H_
#define _NETSURF_RISCOS_BITMAP_H_
+/** bitmap operations table */
+struct gui_bitmap_table *riscos_bitmap_table;
+
#include <stdbool.h>
#include "oslib/osspriteop.h"
#include "image/bitmap.h"
-#define BITMAP_SAVE_FULL_ALPHA (1 << 0) /** save with full alpha channel (if not opaque) */
+/** save with full alpha channel (if not opaque) */
+#define BITMAP_SAVE_FULL_ALPHA (1 << 0)
struct osspriteop_area;
@@ -36,6 +40,15 @@ struct bitmap {
osspriteop_area *sprite_area; /** Uncompressed data, or NULL */
};
-void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s);
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s);
+void riscos_bitmap_destroy(void *vbitmap);
+void *riscos_bitmap_create(int width, int height, unsigned int state);
+unsigned char *riscos_bitmap_get_buffer(void *vbitmap);
+void riscos_bitmap_modified(void *vbitmap);
+int riscos_bitmap_get_width(void *vbitmap);
+int riscos_bitmap_get_height(void *vbitmap);
+size_t riscos_bitmap_get_rowstride(void *vbitmap);
+bool riscos_bitmap_get_opaque(void *vbitmap);
+bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags);
#endif
diff --git a/riscos/gui.c b/riscos/gui.c
index 3fd113c..6a861c2 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -58,6 +58,7 @@
#include "content/backing_store.h"
#include "riscos/gui.h"
+#include "riscos/bitmap.h"
#include "riscos/wimputils.h"
#include "riscos/hotlist.h"
#include "riscos/buffer.h"
@@ -2446,6 +2447,7 @@ int main(int argc, char** argv)
.utf8 = riscos_utf8_table,
.search = riscos_search_table,
.llcache = filesystem_llcache_table,
+ .bitmap = riscos_bitmap_table,
};
ret = netsurf_register(&riscos_table);
diff --git a/riscos/plotters.c b/riscos/plotters.c
index d35d1f0..e23242e 100644
--- a/riscos/plotters.c
+++ b/riscos/plotters.c
@@ -519,7 +519,7 @@ bool ro_plot_bitmap(int x, int y, int width, int height,
{
const uint8_t *buffer;
- buffer = bitmap_get_buffer(bitmap);
+ buffer = riscos_bitmap_get_buffer(bitmap);
if (!buffer) {
LOG(("bitmap_get_buffer failed"));
return false;
@@ -534,6 +534,6 @@ bool ro_plot_bitmap(int x, int y, int width, int height,
bg,
flags & BITMAPF_REPEAT_X, flags & BITMAPF_REPEAT_Y,
flags & BITMAPF_REPEAT_X || flags & BITMAPF_REPEAT_Y,
- bitmap_get_opaque(bitmap) ? IMAGE_PLOT_TINCT_OPAQUE :
+ riscos_bitmap_get_opaque(bitmap) ? IMAGE_PLOT_TINCT_OPAQUE :
IMAGE_PLOT_TINCT_ALPHA);
}
diff --git a/riscos/save.c b/riscos/save.c
index 7b60239..6b27db4 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -1144,7 +1144,7 @@ bool ro_gui_save_object_native(hlcache_handle *h, char *path)
{
unsigned flags = (os_version == 0xA9) ?
BITMAP_SAVE_FULL_ALPHA : 0;
- bitmap_save(content_get_bitmap(h), path, flags);
+ riscos_bitmap_save(content_get_bitmap(h), path, flags);
}
break;
case osfile_TYPE_DRAW:
@@ -1370,14 +1370,14 @@ bool ro_gui_save_create_thumbnail(hlcache_handle *h, const char *name)
struct bitmap *bitmap;
osspriteop_area *area;
- bitmap = bitmap_create(34, 34, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
+ bitmap = riscos_bitmap_create(34, 34, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
if (!bitmap) {
LOG(("Thumbnail initialisation failed."));
return false;
}
thumbnail_create(h, bitmap);
area = thumbnail_convert_8bpp(bitmap);
- bitmap_destroy(bitmap);
+ riscos_bitmap_destroy(bitmap);
if (!area) {
LOG(("Thumbnail conversion failed."));
return false;
diff --git a/riscos/save_draw.c b/riscos/save_draw.c
index fe14071..bf81bca 100644
--- a/riscos/save_draw.c
+++ b/riscos/save_draw.c
@@ -400,7 +400,7 @@ bool ro_save_draw_bitmap(int x, int y, int width, int height,
pencil_code code;
const uint8_t *buffer;
- buffer = bitmap_get_buffer(bitmap);
+ buffer = riscos_bitmap_get_buffer(bitmap);
if (!buffer) {
warn_user("NoMemory", 0);
return false;
diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c
index 6613b0e..ee21747 100644
--- a/riscos/thumbnail.c
+++ b/riscos/thumbnail.c
@@ -108,7 +108,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap)
return false;
sprite_header = (osspriteop_header *)(sprite_area + 1);
} else {
- const uint8_t *pixbufp = bitmap_get_buffer(bitmap);
+ const uint8_t *pixbufp = riscos_bitmap_get_buffer(bitmap);
if (!pixbufp || !bitmap->sprite_area)
return false;
sprite_area = bitmap->sprite_area;
@@ -137,7 +137,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap)
/* if we changed to 8bpp then go back to 32bpp */
if (thumbnail_32bpp_available != 1) {
- const uint8_t *pixbufp = bitmap_get_buffer(bitmap);
+ const uint8_t *pixbufp = riscos_bitmap_get_buffer(bitmap);
_kernel_oserror *error;
if (!pixbufp || !bitmap->sprite_area) {
@@ -152,7 +152,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap)
return false;
}
- bitmap_modified(bitmap);
+ riscos_bitmap_modified(bitmap);
return true;
}
@@ -190,13 +190,13 @@ osspriteop_area *thumbnail_convert_8bpp(struct bitmap *bitmap)
if (sprite_header->image != sprite_header->mask) {
/* build the sprite mask from the alpha channel */
- void *buf = bitmap_get_buffer(bitmap);
+ void *buf = riscos_bitmap_get_buffer(bitmap);
unsigned *dp = (unsigned *) buf;
if (!dp)
return sprite_area;
- int w = bitmap_get_width(bitmap);
- int h = bitmap_get_height(bitmap);
- int dp_offset = bitmap_get_rowstride(bitmap) / 4 - w;
+ int w = riscos_bitmap_get_width(bitmap);
+ int h = riscos_bitmap_get_height(bitmap);
+ int dp_offset = riscos_bitmap_get_rowstride(bitmap) / 4 - w;
int mp_offset = ((sprite_header->width + 1) * 4) - w;
byte *mp = (byte*)sprite_header + sprite_header->mask;
bool alpha = ((unsigned)sprite_header->mode & 0x80000000U) != 0;
@@ -228,7 +228,7 @@ osspriteop_area *thumbnail_convert_8bpp(struct bitmap *bitmap)
osspriteop_area *thumbnail_create_8bpp(struct bitmap *bitmap)
{
unsigned image_size = ((bitmap->width + 3) & ~3) * bitmap->height;
- bool opaque = bitmap_get_opaque(bitmap);
+ bool opaque = riscos_bitmap_get_opaque(bitmap);
osspriteop_header *sprite_header = NULL;
osspriteop_area *sprite_area = NULL;
unsigned area_size;
diff --git a/riscos/window.c b/riscos/window.c
index fae7566..4f281b9 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -3411,7 +3411,7 @@ void ro_gui_window_iconise(struct gui_window *g,
}
/* create the thumbnail sprite */
- bitmap = bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE |
+ bitmap = riscos_bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE |
BITMAP_CLEAR_MEMORY);
if (!bitmap) {
LOG(("Thumbnail initialisation failed."));
@@ -3419,10 +3419,10 @@ void ro_gui_window_iconise(struct gui_window *g,
}
thumbnail_create(h, bitmap);
if (overlay) {
- bitmap_overlay_sprite(bitmap, overlay);
+ riscos_bitmap_overlay_sprite(bitmap, overlay);
}
area = thumbnail_convert_8bpp(bitmap);
- bitmap_destroy(bitmap);
+ riscos_bitmap_destroy(bitmap);
if (!area) {
LOG(("Thumbnail conversion failed."));
return;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5c7e8618d5e5f2eb0b3...
commit 5c7e8618d5e5f2eb0b37dd937fb5669eeba407d0
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Convert windows frontend to using bitmap operation table
diff --git a/windows/bitmap.c b/windows/bitmap.c
index c047e17..f010860 100644
--- a/windows/bitmap.c
+++ b/windows/bitmap.c
@@ -17,18 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "utils/config.h"
+
#include <inttypes.h>
#include <sys/types.h>
#include <string.h>
-
-#include "utils/config.h"
-
#include <windows.h>
+#include "utils/log.h"
#include "image/bitmap.h"
-#include "windows/bitmap.h"
-#include "utils/log.h"
+#include "windows/bitmap.h"
/**
* Create a bitmap.
@@ -38,8 +37,7 @@
* \param state a flag word indicating the initial state
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+void *win32_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
BITMAPV5HEADER *pbmi;
@@ -99,14 +97,13 @@ void *bitmap_create(int width, int height, unsigned int state)
/**
* Return a pointer to the pixel data in a bitmap.
*
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- *
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return pointer to the pixel buffer
*/
-
-unsigned char *bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
if (bitmap == NULL) {
@@ -124,8 +121,7 @@ unsigned char *bitmap_get_buffer(void *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return width of a pixel row in the bitmap
*/
-
-size_t bitmap_get_rowstride(void *bitmap)
+static size_t bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -143,8 +139,7 @@ size_t bitmap_get_rowstride(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *bitmap)
+void win32_bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -167,8 +162,7 @@ void bitmap_destroy(void *bitmap)
* \param flags flags controlling how the bitmap is saved.
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
@@ -179,7 +173,7 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *bitmap) {
+static void bitmap_modified(void *bitmap) {
}
/**
@@ -188,7 +182,7 @@ void bitmap_modified(void *bitmap) {
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
@@ -208,7 +202,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
int tst;
struct bitmap *bm = bitmap;
@@ -236,7 +230,7 @@ bool bitmap_test_opaque(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *bitmap)
+static bool bitmap_get_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -248,7 +242,7 @@ bool bitmap_get_opaque(void *bitmap)
return bm->opaque;
}
-int bitmap_get_width(void *bitmap)
+static int bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -260,7 +254,7 @@ int bitmap_get_width(void *bitmap)
return(bm->width);
}
-int bitmap_get_height(void *bitmap)
+static int bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -272,7 +266,7 @@ int bitmap_get_height(void *bitmap)
return(bm->height);
}
-size_t bitmap_get_bpp(void *bitmap)
+static size_t bitmap_get_bpp(void *bitmap)
{
return 4;
}
@@ -350,3 +344,20 @@ struct bitmap *bitmap_pretile(struct bitmap *untiled, int width, int height,
ret->height = height;
return ret;
}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = win32_bitmap_create,
+ .destroy = win32_bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *win32_bitmap_table = &bitmap_table;
diff --git a/windows/bitmap.h b/windows/bitmap.h
index d05fef2..434c5e9 100644
--- a/windows/bitmap.h
+++ b/windows/bitmap.h
@@ -22,6 +22,8 @@
#include "desktop/plotters.h"
+struct gui_bitmap_table *win32_bitmap_table;
+
struct bitmap {
HBITMAP windib;
BITMAPV5HEADER *pbmi;
@@ -35,4 +37,7 @@ struct bitmap *bitmap_scale(struct bitmap *prescale, int width, int height);
struct bitmap *bitmap_pretile(struct bitmap *untiled, int width, int height,
bitmap_flags_t flags);
+void *win32_bitmap_create(int width, int height, unsigned int state);
+void win32_bitmap_destroy(void *bitmap);
+
#endif
diff --git a/windows/main.c b/windows/main.c
index c5bb240..4114297 100644
--- a/windows/main.c
+++ b/windows/main.c
@@ -43,6 +43,7 @@
#include "windows/font.h"
#include "windows/filetype.h"
#include "windows/pointers.h"
+#include "windows/bitmap.h"
#include "windows/gui.h"
static char **respaths; /** resource search path vector. */
@@ -130,6 +131,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
.fetch = win32_fetch_table,
.file = win32_file_table,
.utf8 = win32_utf8_table,
+ .bitmap = win32_bitmap_table,
};
win32_fetch_table->get_resource_url = gui_get_resource_url;
diff --git a/windows/thumbnail.c b/windows/thumbnail.c
index 1fee8cc..2cf6783 100644
--- a/windows/thumbnail.c
+++ b/windows/thumbnail.c
@@ -65,7 +65,7 @@ thumbnail_create(hlcache_handle *content,
}
/* create a full size bitmap and plot into it */
- fsbitmap = bitmap_create(width, height, BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE);
+ fsbitmap = win32_bitmap_create(width, height, BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE);
SelectObject(bufferdc, fsbitmap->windib);
@@ -83,7 +83,7 @@ thumbnail_create(hlcache_handle *content,
DeleteDC(bufferdc);
DeleteDC(minidc);
- bitmap_destroy(fsbitmap);
+ win32_bitmap_destroy(fsbitmap);
return true;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9679561eca26bf79276...
commit 9679561eca26bf792764002465bc0548c5d694bf
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update monkey frontend to use bitmap operation table.
diff --git a/gtk/bitmap.c b/gtk/bitmap.c
index 03b5d98..978838d 100644
--- a/gtk/bitmap.c
+++ b/gtk/bitmap.c
@@ -26,16 +26,15 @@
#include <assert.h>
#include <stdbool.h>
#include <string.h>
-
#include <cairo.h>
#include <gtk/gtk.h>
+#include "utils/log.h"
#include "content/content.h"
-#include "gtk/scaffolding.h"
-#include "gtk/bitmap.h"
#include "image/bitmap.h"
-#include "utils/log.h"
+#include "gtk/scaffolding.h"
+#include "gtk/bitmap.h"
/**
diff --git a/monkey/bitmap.c b/monkey/bitmap.c
index 79bab8c..16c98b5 100644
--- a/monkey/bitmap.c
+++ b/monkey/bitmap.c
@@ -18,9 +18,12 @@
#include <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include "image/bitmap.h"
+#include "monkey/bitmap.h"
+
struct bitmap {
void *ptr;
size_t rowstride;
@@ -29,7 +32,7 @@ struct bitmap {
unsigned int state;
};
-void *bitmap_create(int width, int height, unsigned int state)
+static void *bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)
@@ -49,14 +52,14 @@ void *bitmap_create(int width, int height, unsigned int state)
return ret;
}
-void bitmap_destroy(void *bitmap)
+static void bitmap_destroy(void *bitmap)
{
struct bitmap *bmap = bitmap;
free(bmap->ptr);
free(bmap);
}
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bmap = bitmap;
@@ -66,56 +69,73 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
bmap->state &= ~(BITMAP_OPAQUE);
}
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
return false;
}
-bool bitmap_get_opaque(void *bitmap)
+static bool bitmap_get_opaque(void *bitmap)
{
struct bitmap *bmap = bitmap;
return (bmap->state & BITMAP_OPAQUE) == BITMAP_OPAQUE;
}
-unsigned char *bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bmap = bitmap;
return (unsigned char *)(bmap->ptr);
}
-size_t bitmap_get_rowstride(void *bitmap)
+static size_t bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->width * 4;
}
-size_t bitmap_get_bpp(void *bitmap)
+static size_t bitmap_get_bpp(void *bitmap)
{
/* OMG?! */
return 4;
}
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
-void bitmap_modified(void *bitmap)
+static void bitmap_modified(void *bitmap)
{
struct bitmap *bmap = bitmap;
bmap->state |= BITMAP_MODIFIED;
}
-int bitmap_get_width(void *bitmap)
+static int bitmap_get_width(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->width;
}
-int bitmap_get_height(void *bitmap)
+static int bitmap_get_height(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->height;
}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *monkey_bitmap_table = &bitmap_table;
diff --git a/monkey/bitmap.h b/monkey/bitmap.h
new file mode 100644
index 0000000..e293ce9
--- /dev/null
+++ b/monkey/bitmap.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NS_MONKEY_BITMAP_H
+#define NS_MONKEY_BITMAP_H
+
+extern struct gui_bitmap_table *monkey_bitmap_table;
+
+#endif /* NS_MONKEY_BITMAP_H */
diff --git a/monkey/fetch.h b/monkey/fetch.h
index 59e8696..f146e2e 100644
--- a/monkey/fetch.h
+++ b/monkey/fetch.h
@@ -16,4 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef NS_MONKEY_FETCH_H
+#define NS_MONKEY_FETCH_H
+
struct gui_fetch_table *monkey_fetch_table;
+
+#endif /* NS_MONKEY_FETCH_H */
diff --git a/monkey/main.c b/monkey/main.c
index a58bec5..81406bc 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -37,6 +37,7 @@
#include "monkey/filetype.h"
#include "monkey/fetch.h"
#include "monkey/schedule.h"
+#include "monkey/bitmap.h"
char **respaths; /** resource search path vector */
@@ -140,6 +141,7 @@ main(int argc, char **argv)
.window = monkey_window_table,
.download = monkey_download_table,
.fetch = monkey_fetch_table,
+ .bitmap = monkey_bitmap_table,
};
ret = netsurf_register(&monkey_table);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cc11912da1e28818038...
commit cc11912da1e2881803828330f85b0fe177b570b6
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Convert framebuffer frontend to bitmap operations table.
diff --git a/desktop/browser.c b/desktop/browser.c
index 195814c..74d15f6 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -2518,7 +2518,7 @@ void browser_window_reformat(struct browser_window *bw, bool background,
}
/**
- * Set bowser window scale.
+ * Set browser window scale.
*
* \param bw Browser window.
* \param scale value.
diff --git a/framebuffer/bitmap.c b/framebuffer/bitmap.c
index fb45d6e..713cf84 100644
--- a/framebuffer/bitmap.c
+++ b/framebuffer/bitmap.c
@@ -16,16 +16,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Framebuffer implementation of generic bitmap interface.
+ */
+
#include <inttypes.h>
#include <sys/types.h>
#include <stdbool.h>
#include <assert.h>
-
#include <libnsfb.h>
#include "image/bitmap.h"
#include "utils/log.h"
+#include "framebuffer/bitmap.h"
+
/**
* Create a bitmap.
*
@@ -34,8 +40,7 @@
* \param state a flag word indicating the initial state
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+static void *bitmap_create(int width, int height, unsigned int state)
{
nsfb_t *bm;
@@ -72,8 +77,7 @@ void *bitmap_create(int width, int height, unsigned int state)
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-
-unsigned char *bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
nsfb_t *bm = bitmap;
unsigned char *bmpptr;
@@ -92,8 +96,7 @@ unsigned char *bitmap_get_buffer(void *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return width of a pixel row in the bitmap
*/
-
-size_t bitmap_get_rowstride(void *bitmap)
+static size_t bitmap_get_rowstride(void *bitmap)
{
nsfb_t *bm = bitmap;
int bmpstride;
@@ -111,8 +114,7 @@ size_t bitmap_get_rowstride(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *bitmap)
+static void bitmap_destroy(void *bitmap)
{
nsfb_t *bm = bitmap;
@@ -130,8 +132,7 @@ void bitmap_destroy(void *bitmap)
* \param flags flags controlling how the bitmap is saved.
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
@@ -142,7 +143,7 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *bitmap) {
+static void bitmap_modified(void *bitmap) {
}
/**
@@ -151,7 +152,7 @@ void bitmap_modified(void *bitmap) {
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
nsfb_t *bm = bitmap;
@@ -171,7 +172,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
int tst;
nsfb_t *bm = bitmap;
@@ -203,7 +204,7 @@ bool bitmap_test_opaque(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *bitmap)
+bool framebuffer_bitmap_get_opaque(void *bitmap)
{
nsfb_t *bm = bitmap;
enum nsfb_format_e format;
@@ -218,7 +219,7 @@ bool bitmap_get_opaque(void *bitmap)
return true;
}
-int bitmap_get_width(void *bitmap)
+static int bitmap_get_width(void *bitmap)
{
nsfb_t *bm = bitmap;
int width;
@@ -230,7 +231,7 @@ int bitmap_get_width(void *bitmap)
return(width);
}
-int bitmap_get_height(void *bitmap)
+static int bitmap_get_height(void *bitmap)
{
nsfb_t *bm = bitmap;
int height;
@@ -243,11 +244,29 @@ int bitmap_get_height(void *bitmap)
}
/* get bytes per pixel */
-size_t bitmap_get_bpp(void *bitmap)
+static size_t bitmap_get_bpp(void *bitmap)
{
return 4;
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = framebuffer_bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *framebuffer_bitmap_table = &bitmap_table;
+
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/framebuffer/bitmap.h b/framebuffer/bitmap.h
new file mode 100644
index 0000000..0a72f19
--- /dev/null
+++ b/framebuffer/bitmap.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.h>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NS_FB_BITMAP_H
+#define NS_FB_BITMAP_H
+
+extern struct gui_bitmap_table *framebuffer_bitmap_table;
+
+bool framebuffer_bitmap_get_opaque(void *bitmap);
+
+#endif /* NS_FB_BITMAP_H */
diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c
index 0988c6b..927e631 100644
--- a/framebuffer/framebuffer.c
+++ b/framebuffer/framebuffer.c
@@ -37,6 +37,7 @@
#include "framebuffer/fbtk.h"
#include "framebuffer/framebuffer.h"
#include "framebuffer/font.h"
+#include "framebuffer/bitmap.h"
/* netsurf framebuffer library handle */
static nsfb_t *nsfb;
@@ -215,7 +216,7 @@ framebuffer_plot_bitmap(int x, int y,
* a flat fill of the area. Can only be done when image is fully
* opaque. */
if ((width == 1) && (height == 1)) {
- if (bitmap_get_opaque(bm)) {
+ if (framebuffer_bitmap_get_opaque(bm)) {
/** TODO: Currently using top left pixel. Maybe centre
* pixel or average value would be better. */
return nsfb_plot_rectangle_fill(nsfb, &clipbox,
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index e178d28..56fe41b 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -54,6 +54,7 @@
#include "framebuffer/font.h"
#include "framebuffer/clipboard.h"
#include "framebuffer/fetch.h"
+#include "framebuffer/bitmap.h"
#include "content/urldb.h"
#include "content/fetch.h"
@@ -106,7 +107,7 @@ static struct gui_drag {
*/
static void die(const char *error)
{
- LOG(("%s", error));
+ fprintf(stderr, "%s\n", error);
exit(1);
}
@@ -2081,6 +2082,7 @@ main(int argc, char** argv)
.clipboard = framebuffer_clipboard_table,
.fetch = framebuffer_fetch_table,
.utf8 = framebuffer_utf8_table,
+ .bitmap = framebuffer_bitmap_table,
};
ret = netsurf_register(&framebuffer_table);
diff --git a/gtk/bitmap.c b/gtk/bitmap.c
index 4803b0f..03b5d98 100644
--- a/gtk/bitmap.c
+++ b/gtk/bitmap.c
@@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Generic bitmap handling (GDK / GTK+ implementation).
*
* This implements the interface given by desktop/bitmap.h using GdkPixbufs.
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c02f552e8704f52e1a9...
commit c02f552e8704f52e1a9ab92b21cb7d23211d98ab
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
chnage GTK frontend to using bitmap operation table
diff --git a/gtk/bitmap.c b/gtk/bitmap.c
index a1cb849..4803b0f 100644
--- a/gtk/bitmap.c
+++ b/gtk/bitmap.c
@@ -45,8 +45,7 @@
* \param state a flag word indicating the initial state
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+static void *bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *gbitmap;
@@ -75,7 +74,7 @@ void *bitmap_create(int width, int height, unsigned int state)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *vbitmap, bool opaque)
+static void bitmap_set_opaque(void *vbitmap, bool opaque)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
cairo_format_t fmt;
@@ -127,7 +126,7 @@ void bitmap_set_opaque(void *vbitmap, bool opaque)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *vbitmap)
+static bool bitmap_test_opaque(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
unsigned char *pixels;
@@ -156,7 +155,7 @@ bool bitmap_test_opaque(void *vbitmap)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *vbitmap)
+static bool bitmap_get_opaque(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
cairo_format_t fmt;
@@ -181,8 +180,7 @@ bool bitmap_get_opaque(void *vbitmap)
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-
-unsigned char *bitmap_get_buffer(void *vbitmap)
+static unsigned char *bitmap_get_buffer(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
int pixel_loop;
@@ -272,8 +270,7 @@ unsigned char *bitmap_get_buffer(void *vbitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return width of a pixel row in the bitmap
*/
-
-size_t bitmap_get_rowstride(void *vbitmap)
+static size_t bitmap_get_rowstride(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -288,8 +285,7 @@ size_t bitmap_get_rowstride(void *vbitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return bytes per pixel
*/
-
-size_t bitmap_get_bpp(void *vbitmap)
+static size_t bitmap_get_bpp(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -304,8 +300,7 @@ size_t bitmap_get_bpp(void *vbitmap)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *vbitmap)
+static void bitmap_destroy(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -328,8 +323,7 @@ void bitmap_destroy(void *vbitmap)
* \param flags modify the behaviour of the save
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -343,7 +337,8 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *vbitmap) {
+static void bitmap_modified(void *vbitmap)
+{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
int pixel_loop;
int pixel_count;
@@ -422,18 +417,37 @@ void bitmap_modified(void *vbitmap) {
gbitmap->converted = true;
}
-int bitmap_get_width(void *vbitmap){
+/* exported interface documented in gtk/bitmap.h */
+int nsgtk_bitmap_get_width(void *vbitmap)
+{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
return cairo_image_surface_get_width(gbitmap->surface);
}
-int bitmap_get_height(void *vbitmap){
+/* exported interface documented in gtk/bitmap.h */
+int nsgtk_bitmap_get_height(void *vbitmap)
+{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
return cairo_image_surface_get_height(gbitmap->surface);
}
-
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = nsgtk_bitmap_get_width,
+ .get_height = nsgtk_bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *nsgtk_bitmap_table = &bitmap_table;
diff --git a/gtk/bitmap.h b/gtk/bitmap.h
index 62d50f4..0f46d19 100644
--- a/gtk/bitmap.h
+++ b/gtk/bitmap.h
@@ -20,7 +20,8 @@
#define NS_GTK_BITMAP_H
#include <cairo.h>
-#include "image/bitmap.h"
+
+extern struct gui_bitmap_table *nsgtk_bitmap_table;
struct bitmap {
cairo_surface_t *surface; /* original cairo surface */
@@ -28,4 +29,7 @@ struct bitmap {
bool converted; /** set if the surface data has been converted */
};
+int nsgtk_bitmap_get_width(void *vbitmap);
+int nsgtk_bitmap_get_height(void *vbitmap);
+
#endif /* NS_GTK_BITMAP_H */
diff --git a/gtk/gui.c b/gtk/gui.c
index 3bcb33c..6f51133 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -66,6 +66,7 @@
#include "gtk/selection.h"
#include "gtk/search.h"
#include "gtk/ssl_cert.h"
+#include "gtk/bitmap.h"
bool nsgtk_complete = false;
@@ -1112,6 +1113,7 @@ int main(int argc, char** argv)
.llcache = filesystem_llcache_table,
.search = nsgtk_search_table,
.search_web = nsgtk_search_web_table,
+ .bitmap = nsgtk_bitmap_table,
};
ret = netsurf_register(&nsgtk_table);
diff --git a/gtk/print.c b/gtk/print.c
index e587026..53fbed0 100644
--- a/gtk/print.c
+++ b/gtk/print.c
@@ -462,8 +462,8 @@ static bool nsgtk_print_plot_bitmap(int x, int y, int width, int height,
return nsgtk_print_plot_pixbuf(x, y, width, height, bitmap, bg);
}
- width = bitmap_get_width(bitmap);
- height = bitmap_get_height(bitmap);
+ width = nsgtk_bitmap_get_width(bitmap);
+ height = nsgtk_bitmap_get_height(bitmap);
/* Bail early if we can */
if (width == 0 || height == 0)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f37e52c39475e6efd37...
commit f37e52c39475e6efd3740c5ae1ec4f290662928f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Move bitmap operations into an operation table.
The generic bitmap handlers provided by each frontend are called back
from the core and therefore should be in an operation table. This was
one of the very few remaining interfaces stopping the core code from
being split into a library.
diff --git a/content/content.c b/content/content.c
index a27647b..a6ca978 100644
--- a/content/content.c
+++ b/content/content.c
@@ -34,6 +34,7 @@
#include "content/hlcache.h"
#include "image/bitmap.h"
#include "desktop/browser.h"
+#include "desktop/gui_internal.h"
#include "utils/nsoption.h"
#include "utils/http.h"
@@ -1243,7 +1244,7 @@ bool content__get_opaque(struct content *c)
struct bitmap *bitmap = NULL;
bitmap = c->handler->get_internal(c, NULL);
if (bitmap != NULL) {
- opaque = bitmap_get_opaque(bitmap);
+ opaque = guit->bitmap->get_opaque(bitmap);
}
}
diff --git a/content/urldb.c b/content/urldb.c
index f77f597..a9476d7 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -95,19 +95,20 @@
#include <string.h>
#include <strings.h>
#include <time.h>
-
#include <curl/curl.h>
-#include "image/bitmap.h"
-#include "content/content.h"
-#include "content/urldb.h"
-#include "desktop/cookie_manager.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/utils.h"
#include "utils/bloom.h"
+#include "image/bitmap.h"
+#include "desktop/cookie_manager.h"
+#include "desktop/gui_internal.h"
+
+#include "content/content.h"
+#include "content/urldb.h"
struct cookie_internal_data {
char *name; /**< Cookie name */
@@ -2330,8 +2331,9 @@ static void urldb_destroy_path_node_content(struct path_data *node)
free(node->fragment[i]);
free(node->fragment);
- if (node->thumb)
- bitmap_destroy(node->thumb);
+ if (node->thumb) {
+ guit->bitmap->destroy(node->thumb);
+ }
free(node->urld.title);
@@ -3065,8 +3067,9 @@ void urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap)
LOG(("Setting bitmap on %s", nsurl_access(url)));
- if (p->thumb && p->thumb != bitmap)
- bitmap_destroy(p->thumb);
+ if (p->thumb && p->thumb != bitmap) {
+ guit->bitmap->destroy(p->thumb);
+ }
p->thumb = bitmap;
}
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 1991bf9..e7fd875 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -37,6 +37,7 @@
#include "css/css.h"
#include "image/bitmap.h"
+#include "desktop/gui_internal.h"
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/plotters.h"
@@ -511,9 +512,9 @@ nserror browser_window_history_add(struct browser_window *bw,
bitmap = urldb_get_thumbnail(nsurl);
if (bitmap == NULL) {
LOG(("Creating thumbnail for %s", nsurl_access(nsurl)));
- bitmap = bitmap_create(WIDTH, HEIGHT,
- BITMAP_NEW | BITMAP_CLEAR_MEMORY |
- BITMAP_OPAQUE);
+ bitmap = guit->bitmap->create(WIDTH, HEIGHT,
+ BITMAP_NEW | BITMAP_CLEAR_MEMORY |
+ BITMAP_OPAQUE);
if (bitmap != NULL) {
if (thumbnail_create(content, bitmap)) {
/* Successful thumbnail so register it
@@ -525,7 +526,7 @@ nserror browser_window_history_add(struct browser_window *bw,
* silently but clean up bitmap.
*/
LOG(("Thumbnail bitmap creation failed"));
- bitmap_destroy(bitmap);
+ guit->bitmap->destroy(bitmap);
bitmap = NULL;
}
}
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index df88b8c..cab11eb 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -16,10 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "utils/errors.h"
+#include "utils/file.h"
+#include "image/bitmap.h"
#include "content/hlcache.h"
#include "content/backing_store.h"
-#include "utils/file.h"
#include "desktop/save_pdf.h"
#include "desktop/download.h"
#include "desktop/searchweb.h"
@@ -552,6 +558,71 @@ static nserror verify_file_register(struct gui_file_table *gft)
return NSERROR_OK;
}
+/**
+ * verify bitmap table is valid
+ *
+ * \param gbt The bitmap table to verify.
+ * \return NSERROR_OK if teh table is valid else NSERROR_BAD_PARAMETER.
+ */
+static nserror verify_bitmap_register(struct gui_bitmap_table *gbt)
+{
+ /* check table is present */
+ if (gbt == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* check the mandantory fields are set */
+ if (gbt->create == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->destroy == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->set_opaque == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_opaque == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->test_opaque == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_buffer == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_rowstride == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_width == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_height == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_bpp == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->save == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->modified == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ return NSERROR_OK;
+}
+
static void gui_default_quit(void)
{
}
@@ -651,6 +722,12 @@ nserror netsurf_register(struct netsurf_table *gt)
return err;
}
+ /* bitmap table */
+ err = verify_bitmap_register(gt->bitmap);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
/* file table */
if (gt->file == NULL) {
gt->file = default_file_table;
diff --git a/desktop/gui_table.h b/desktop/gui_table.h
index 10f2bf1..52cdde2 100644
--- a/desktop/gui_table.h
+++ b/desktop/gui_table.h
@@ -37,6 +37,7 @@ struct gui_utf8_table;
struct gui_search_table;
struct gui_search_web_table;
struct gui_llcache_table;
+struct gui_bitmap_table;
/**
* NetSurf operation function table
@@ -119,6 +120,15 @@ struct netsurf_table {
* uses the default implementation.
*/
struct gui_llcache_table *llcache;
+
+ /**
+ * Bitmap table.
+ *
+ * Used by the image convertors as a generic interface to
+ * native platform-specific image formats. The table
+ * is mandantory and must be provided.
+ */
+ struct gui_bitmap_table *bitmap;
};
#endif
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 0321423..303ba8f 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -66,9 +66,12 @@
#include <string.h>
#include <stdio.h>
-#include "image/bitmap.h"
#include "utils/log.h"
+#include "utils/errors.h"
+#include "image/bitmap.h"
#include "content/content.h"
+
+#include "desktop/gui_internal.h"
#include "desktop/knockout.h"
#include "desktop/plotters.h"
@@ -772,8 +775,9 @@ bool knockout_plot_bitmap(int x, int y, int width, int height,
}
/* tiled bitmaps both knock out and get knocked out */
- if (bitmap_get_opaque(bitmap))
+ if (guit->bitmap->get_opaque(bitmap)) {
knockout_calculate(kx0, ky0, kx1, ky1, NULL);
+ }
knockout_boxes[knockout_box_cur].bbox.x0 = kx0;
knockout_boxes[knockout_box_cur].bbox.y0 = ky0;
knockout_boxes[knockout_box_cur].bbox.x1 = kx1;
diff --git a/desktop/treeview.c b/desktop/treeview.c
index f6134ae..35458f7 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -3698,12 +3698,12 @@ static struct bitmap * treeview_generate_triangle_bitmap(
colour colour4 = fg;
/* Create the bitmap */
- b = bitmap_create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
+ b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
if (b == NULL)
return NULL;
- rpos = bitmap_get_buffer(b);
- stride = bitmap_get_rowstride(b);
+ rpos = guit->bitmap->get_buffer(b);
+ stride = guit->bitmap->get_rowstride(b);
/* Draw the triangle */
for (y = 0; y < size; y++) {
@@ -3770,7 +3770,7 @@ static struct bitmap * treeview_generate_triangle_bitmap(
rpos += stride;
}
- bitmap_modified(b);
+ guit->bitmap->modified(b);
return b;
}
@@ -3793,29 +3793,29 @@ static struct bitmap * treeview_generate_copy_bitmap(
if (orig == NULL)
return NULL;
- assert(size == bitmap_get_width(orig));
- assert(size == bitmap_get_height(orig));
+ assert(size == guit->bitmap->get_width(orig));
+ assert(size == guit->bitmap->get_height(orig));
/* Create the bitmap */
- b = bitmap_create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
+ b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
if (b == NULL)
return NULL;
- stride = bitmap_get_rowstride(b);
- assert(stride == bitmap_get_rowstride(orig));
+ stride = guit->bitmap->get_rowstride(b);
+ assert(stride == guit->bitmap->get_rowstride(orig));
- data = bitmap_get_buffer(b);
- orig_data = bitmap_get_buffer(orig);
+ data = guit->bitmap->get_buffer(b);
+ orig_data = guit->bitmap->get_buffer(orig);
/* Copy the bitmap */
memcpy(data, orig_data, stride * size);
- bitmap_modified(b);
+ guit->bitmap->modified(b);
/* We've not modified the original image, but we called
* bitmap_get_buffer(), so we need to pair that with a
* bitmap_modified() call to appease certain front ends. */
- bitmap_modified(orig);
+ guit->bitmap->modified(orig);
return b;
}
@@ -3841,19 +3841,19 @@ static struct bitmap * treeview_generate_rotate_bitmap(
if (orig == NULL)
return NULL;
- assert(size == bitmap_get_width(orig));
- assert(size == bitmap_get_height(orig));
+ assert(size == guit->bitmap->get_width(orig));
+ assert(size == guit->bitmap->get_height(orig));
/* Create the bitmap */
- b = bitmap_create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
+ b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
if (b == NULL)
return NULL;
- stride = bitmap_get_rowstride(b);
- assert(stride == bitmap_get_rowstride(orig));
+ stride = guit->bitmap->get_rowstride(b);
+ assert(stride == guit->bitmap->get_rowstride(orig));
- rpos = bitmap_get_buffer(b);
- orig_data = bitmap_get_buffer(orig);
+ rpos = guit->bitmap->get_buffer(b);
+ orig_data = guit->bitmap->get_buffer(orig);
/* Copy the rotated bitmap */
for (y = 0; y < size; y++) {
@@ -3871,12 +3871,13 @@ static struct bitmap * treeview_generate_rotate_bitmap(
rpos += stride;
}
- bitmap_modified(b);
+ guit->bitmap->modified(b);
/* We've not modified the original image, but we called
* bitmap_get_buffer(), so we need to pair that with a
- * bitmap_modified() call to appease certain front ends. */
- bitmap_modified(orig);
+ * bitmap_modified() call to appease certain front ends.
+ */
+ guit->bitmap->modified(orig);
return b;
}
@@ -3988,14 +3989,14 @@ nserror treeview_fini(void)
hlcache_handle_release(treeview_res[i].c);
}
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_EXPAND].bmp);
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_EXPAND].sel);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_EXPAND].bmp);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_EXPAND].sel);
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].bmp);
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].sel);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_CONTRACT].bmp);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_CONTRACT].sel);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_EXPAND].bmp);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_EXPAND].sel);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_EXPAND].bmp);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_EXPAND].sel);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].bmp);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].sel);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].bmp);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].sel);
tree_g.initialised = false;
diff --git a/image/bitmap.h b/image/bitmap.h
index 1932492..459a50a 100644
--- a/image/bitmap.h
+++ b/image/bitmap.h
@@ -53,31 +53,72 @@
#ifndef _NETSURF_IMAGE_BITMAP_H_
#define _NETSURF_IMAGE_BITMAP_H_
-#include <stdbool.h>
-#include <stdlib.h>
-
#define BITMAP_NEW 0
#define BITMAP_OPAQUE (1 << 0) /** image is opaque */
#define BITMAP_MODIFIED (1 << 1) /** buffer has been modified */
#define BITMAP_CLEAR_MEMORY (1 << 2) /** memory should be wiped */
struct content;
-
-/** An opaque image. */
struct bitmap;
-void *bitmap_create(int width, int height, unsigned int state);
-void bitmap_set_opaque(void *bitmap, bool opaque);
-bool bitmap_test_opaque(void *bitmap);
-bool bitmap_get_opaque(void *bitmap);
-unsigned char *bitmap_get_buffer(void *bitmap);
-size_t bitmap_get_rowstride(void *bitmap);
-size_t bitmap_get_bpp(void *bitmap);
-void bitmap_destroy(void *bitmap);
-bool bitmap_save(void *bitmap, const char *path, unsigned flags);
-void bitmap_modified(void *bitmap);
-
-int bitmap_get_width(void *bitmap);
-int bitmap_get_height(void *bitmap);
+/**
+ * Bitmap operations.
+ */
+struct gui_bitmap_table {
+ /* Mandantory entries */
+
+ /**
+ * Create a new bitmap
+ */
+ void *(*create)(int width, int height, unsigned int state);
+
+ /**
+ * Destroy a bitmap
+ */
+ void (*destroy)(void *bitmap);
+
+ /**
+ * Set the opacity of a bitmap
+ */
+ void (*set_opaque)(void *bitmap, bool opaque);
+
+ /**
+ * Get the opacity of a bitmap
+ */
+ bool (*get_opaque)(void *bitmap);
+
+ /**
+ */
+ bool (*test_opaque)(void *bitmap);
+
+ /**
+ */
+ unsigned char *(*get_buffer)(void *bitmap);
+
+ /**
+ */
+ size_t (*get_rowstride)(void *bitmap);
+
+ /**
+ */
+ int (*get_width)(void *bitmap);
+
+ /**
+ */
+ int (*get_height)(void *bitmap);
+
+ /**
+ */
+ size_t (*get_bpp)(void *bitmap);
+
+ /**
+ */
+ bool (*save)(void *bitmap, const char *path, unsigned flags);
+
+ /**
+ * Marks a bitmap as modified.
+ */
+ void (*modified)(void *bitmap);
+};
#endif
diff --git a/image/bmp.c b/image/bmp.c
index 946bca8..dfa573f 100644
--- a/image/bmp.c
+++ b/image/bmp.c
@@ -17,23 +17,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Content for image/bmp (implementation)
+/**
+ * \file
+ * implementation of content handler for BMP images.
*/
-#include <assert.h>
-#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <libnsbmp.h>
-#include "utils/config.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
-#include "content/hlcache.h"
+#include "desktop/gui_internal.h"
#include "desktop/plotters.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
#include "image/bitmap.h"
#include "image/bmp.h"
@@ -46,9 +42,36 @@ typedef struct nsbmp_content {
struct bitmap *bitmap; /**< Created NetSurf bitmap */
} nsbmp_content;
+/**
+ * Callback for libnsbmp; forwards the call to bitmap_create()
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
+{
+ unsigned int bitmap_state = BITMAP_NEW;
+
+ /* set bitmap state based on bmp state */
+ bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
+ bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
+ BITMAP_CLEAR_MEMORY : 0;
+
+ /* return the created bitmap */
+ return guit->bitmap->create(width, height, bitmap_state);
+}
+
static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
{
union content_msg_data msg_data;
+ bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
+ .bitmap_create = nsbmp_bitmap_create,
+ .bitmap_destroy = guit->bitmap->destroy,
+ .bitmap_get_buffer = guit->bitmap->get_buffer,
+ .bitmap_get_bpp = guit->bitmap->get_bpp
+ };
bmp->bmp = calloc(sizeof(struct bmp_image), 1);
if (bmp->bmp == NULL) {
@@ -62,7 +85,6 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
return NSERROR_OK;
}
-
static nserror nsbmp_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
@@ -93,37 +115,6 @@ static nserror nsbmp_create(const content_handler *handler,
return NSERROR_OK;
}
-/**
- * Callback for libnsbmp; forwards the call to bitmap_create()
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
-{
- unsigned int bitmap_state = BITMAP_NEW;
-
- /* set bitmap state based on bmp state */
- bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
- bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
- BITMAP_CLEAR_MEMORY : 0;
-
- /* return the created bitmap */
- return bitmap_create(width, height, bitmap_state);
-}
-
-/* The Bitmap callbacks function table;
- * necessary for interaction with nsbmplib.
- */
-bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
- .bitmap_create = nsbmp_bitmap_create,
- .bitmap_destroy = bitmap_destroy,
- .bitmap_get_buffer = bitmap_get_buffer,
- .bitmap_get_bpp = bitmap_get_bpp
-};
-
static bool nsbmp_convert(struct content *c)
{
nsbmp_content *bmp = (nsbmp_content *) c;
@@ -171,7 +162,7 @@ static bool nsbmp_convert(struct content *c)
/* exit as a success */
bmp->bitmap = bmp->bmp->bitmap;
- bitmap_modified(bmp->bitmap);
+ guit->bitmap->modified(bmp->bitmap);
content_set_ready(c);
content_set_done(c);
diff --git a/image/gif.c b/image/gif.c
index c2f0ae4..871b1cc 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -36,14 +36,9 @@
#include <stdlib.h>
#include <libnsgif.h>
-#include "utils/config.h"
-#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/utils.h"
#include "utils/nsoption.h"
#include "content/content_protected.h"
-#include "content/hlcache.h"
-#include "desktop/plotters.h"
#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
@@ -68,24 +63,21 @@ typedef struct nsgif_content {
*/
static void *nsgif_bitmap_create(int width, int height)
{
- return bitmap_create(width, height, BITMAP_NEW);
+ return guit->bitmap->create(width, height, BITMAP_NEW);
}
-/* The Bitmap callbacks function table;
- * necessary for interaction with nsgiflib.
- */
-static gif_bitmap_callback_vt gif_bitmap_callbacks = {
- .bitmap_create = nsgif_bitmap_create,
- .bitmap_destroy = bitmap_destroy,
- .bitmap_get_buffer = bitmap_get_buffer,
- .bitmap_set_opaque = bitmap_set_opaque,
- .bitmap_test_opaque = bitmap_test_opaque,
- .bitmap_modified = bitmap_modified
-};
static nserror nsgif_create_gif_data(nsgif_content *c)
{
union content_msg_data msg_data;
+ gif_bitmap_callback_vt gif_bitmap_callbacks = {
+ .bitmap_create = nsgif_bitmap_create,
+ .bitmap_destroy = guit->bitmap->destroy,
+ .bitmap_get_buffer = guit->bitmap->get_buffer,
+ .bitmap_set_opaque = guit->bitmap->set_opaque,
+ .bitmap_test_opaque = guit->bitmap->test_opaque,
+ .bitmap_modified = guit->bitmap->modified
+ };
/* Initialise our data structure */
c->gif = calloc(sizeof(gif_animation), 1);
diff --git a/image/ico.c b/image/ico.c
index e455a59..b6743cb 100644
--- a/image/ico.c
+++ b/image/ico.c
@@ -20,22 +20,18 @@
* Content for image/ico (implementation)
*/
-#include <assert.h>
-#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <libnsbmp.h>
-#include "utils/config.h"
+
+#include "utils/log.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
-#include "content/hlcache.h"
-#include "desktop/plotters.h"
+#include "desktop/gui_internal.h"
+
+#include "image/image.h"
#include "image/bitmap.h"
-#include "image/bmp.h"
#include "image/ico.h"
-#include "image/image.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
typedef struct nsico_content {
struct content base;
@@ -44,10 +40,36 @@ typedef struct nsico_content {
} nsico_content;
+/**
+ * Callback for libnsbmp; forwards the call to bitmap_create()
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+static void *nsico_bitmap_create(int width, int height, unsigned int bmp_state)
+{
+ unsigned int bitmap_state = BITMAP_NEW;
+
+ /* set bitmap state based on bmp state */
+ bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
+ bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
+ BITMAP_CLEAR_MEMORY : 0;
+
+ /* return the created bitmap */
+ return guit->bitmap->create(width, height, bitmap_state);
+}
static nserror nsico_create_ico_data(nsico_content *c)
{
union content_msg_data msg_data;
+ bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
+ .bitmap_create = nsico_bitmap_create,
+ .bitmap_destroy = guit->bitmap->destroy,
+ .bitmap_get_buffer = guit->bitmap->get_buffer,
+ .bitmap_get_bpp = guit->bitmap->get_bpp
+ };
c->ico = calloc(sizeof(ico_collection), 1);
if (c->ico == NULL) {
@@ -173,7 +195,7 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
return false;
} else {
LOG(("Decoding bitmap"));
- bitmap_modified(bmp->bitmap);
+ guit->bitmap->modified(bmp->bitmap);
}
}
@@ -243,7 +265,7 @@ static void *nsico_get_internal(const struct content *c, void *context)
if (bmp_decode(bmp) != BMP_OK) {
return NULL;
} else {
- bitmap_modified(bmp->bitmap);
+ guit->bitmap->modified(bmp->bitmap);
}
}
diff --git a/image/image.c b/image/image.c
index e0c9a43..339f775 100644
--- a/image/image.c
+++ b/image/image.c
@@ -16,19 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
-#include <stdint.h>
#include <stdbool.h>
-#include <string.h>
+#include <stdlib.h>
-#include "utils/utils.h"
-#include "utils/errors.h"
-#include "utils/config.h"
#include "utils/log.h"
-#include "desktop/plotters.h"
+#include "utils/messages.h"
#include "content/content.h"
-#include "image/bitmap.h"
+#include "desktop/plotters.h"
+#include "desktop/gui_internal.h"
+#include "image/bitmap.h"
#include "image/bmp.h"
#include "image/gif.h"
#include "image/ico.h"
@@ -38,7 +35,6 @@
#include "image/rsvg.h"
#include "image/svg.h"
#include "image/webp.h"
-
#include "image/image.h"
/**
@@ -109,7 +105,7 @@ nserror image_init(void)
bool image_bitmap_plot(struct bitmap *bitmap,
- struct content_redraw_data *data,
+ struct content_redraw_data *data,
const struct rect *clip,
const struct redraw_context *ctx)
{
@@ -121,15 +117,15 @@ bool image_bitmap_plot(struct bitmap *bitmap,
plot_style_t fill_style;
struct rect area;
- width = bitmap_get_width(bitmap);
+ width = guit->bitmap->get_width(bitmap);
if (width == 1) {
- height = bitmap_get_height(bitmap);
+ height = guit->bitmap->get_height(bitmap);
if (height == 1) {
/* optimise 1x1 bitmap plot */
- pixel = bitmap_get_buffer(bitmap);
+ pixel = guit->bitmap->get_buffer(bitmap);
fill_style.fill_colour = pixel_to_colour(pixel);
- if (bitmap_get_opaque(bitmap) ||
+ if (guit->bitmap->get_opaque(bitmap) ||
((fill_style.fill_colour & 0xff000000) == 0xff000000)) {
area = *clip;
@@ -147,8 +143,8 @@ bool image_bitmap_plot(struct bitmap *bitmap,
fill_style.stroke_type = PLOT_OP_TYPE_NONE;
fill_style.fill_type = PLOT_OP_TYPE_SOLID;
- return ctx->plot->rectangle(area.x0, area.y0,
- area.x1, area.y1,
+ return ctx->plot->rectangle(area.x0, area.y0,
+ area.x1, area.y1,
&fill_style);
} else if ((fill_style.fill_colour & 0xff000000) == 0) {
@@ -157,7 +153,7 @@ bool image_bitmap_plot(struct bitmap *bitmap,
}
}
}
-
+
/* do the plot */
if (data->repeat_x)
flags |= BITMAPF_REPEAT_X;
@@ -166,6 +162,4 @@ bool image_bitmap_plot(struct bitmap *bitmap,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
bitmap, data->background_colour, flags);
-
-
}
diff --git a/image/image_cache.c b/image/image_cache.c
index 565636c..ac36790 100644
--- a/image/image_cache.c
+++ b/image/image_cache.c
@@ -229,7 +229,7 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
image_cache->current_age - centry->bitmap_age,
centry->redraw_count));
#endif
- bitmap_destroy(centry->bitmap);
+ guit->bitmap->destroy(centry->bitmap);
centry->bitmap = NULL;
image_cache->total_bitmap_size -= centry->bitmap_size;
image_cache->bitmap_count--;
@@ -484,7 +484,7 @@ nserror image_cache_add(struct content *content,
/* set bitmap entry if one is passed, free extant one if present */
if (bitmap != NULL) {
if (centry->bitmap != NULL) {
- bitmap_destroy(centry->bitmap);
+ guit->bitmap->destroy(centry->bitmap);
} else {
image_cache_stats_bitmap_add(centry);
}
diff --git a/image/jpeg.c b/image/jpeg.c
index a5d77b5..309dec0 100644
--- a/image/jpeg.c
+++ b/image/jpeg.c
@@ -23,19 +23,17 @@
* This implementation uses the IJG JPEG library.
*/
-#include <assert.h>
-#include <setjmp.h>
-#include <string.h>
-#include <stdio.h>
+#include <stdbool.h>
#include <stdlib.h>
-
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/image_cache.h"
+#include <setjmp.h>
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/utils.h"
+#include "content/content_protected.h"
+#include "desktop/gui_internal.h"
+
+#include "image/image_cache.h"
+#include "image/bitmap.h"
#define JPEG_INTERNAL_OPTIONS
#include "jpeglib.h"
@@ -224,23 +222,23 @@ jpeg_cache_convert(struct content *c)
height = cinfo.output_height;
/* create opaque bitmap (jpegs cannot be transparent) */
- bitmap = bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE);
+ bitmap = guit->bitmap->create(width, height, BITMAP_NEW | BITMAP_OPAQUE);
if (bitmap == NULL) {
/* empty bitmap could not be created */
jpeg_destroy_decompress(&cinfo);
return NULL;
}
- pixels = bitmap_get_buffer(bitmap);
+ pixels = guit->bitmap->get_buffer(bitmap);
if (pixels == NULL) {
/* bitmap with no buffer available */
- bitmap_destroy(bitmap);
+ guit->bitmap->destroy(bitmap);
jpeg_destroy_decompress(&cinfo);
return NULL;
}
/* Convert scanlines from jpeg into bitmap */
- rowstride = bitmap_get_rowstride(bitmap);
+ rowstride = guit->bitmap->get_rowstride(bitmap);
do {
JSAMPROW scanlines[1];
@@ -265,7 +263,7 @@ jpeg_cache_convert(struct content *c)
}
#endif
} while (cinfo.output_scanline != cinfo.output_height);
- bitmap_modified(bitmap);
+ guit->bitmap->modified(bitmap);
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
diff --git a/image/png.c b/image/png.c
index acf375e..de2059f 100644
--- a/image/png.c
+++ b/image/png.c
@@ -18,25 +18,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
#include <stdbool.h>
-#include <string.h>
#include <stdlib.h>
-
#include <png.h>
-#include "desktop/plotters.h"
-
+#include "utils/log.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
+#include "desktop/gui_internal.h"
-#include "image/bitmap.h"
#include "image/image_cache.h"
+#include "image/bitmap.h"
#include "image/png.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-
/* accommodate for old versions of libpng (beware security holes!) */
#ifndef png_jmpbuf
@@ -164,14 +158,14 @@ static void info_callback(png_structp png_s, png_infop info)
}
/* Claim the required memory for the converted PNG */
- png_c->bitmap = bitmap_create(width, height, BITMAP_NEW);
+ png_c->bitmap = guit->bitmap->create(width, height, BITMAP_NEW);
if (png_c->bitmap == NULL) {
/* Failed to create bitmap skip pre-conversion */
longjmp(png_jmpbuf(png_s), CBERR_NOPRE);
}
- png_c->rowstride = bitmap_get_rowstride(png_c->bitmap);
- png_c->bpp = bitmap_get_bpp(png_c->bitmap);
+ png_c->rowstride = guit->bitmap->get_rowstride(png_c->bitmap);
+ png_c->bpp = guit->bitmap->get_bpp(png_c->bitmap);
nspng_setup_transforms(png_s, info);
@@ -198,7 +192,7 @@ static void row_callback(png_structp png_s, png_bytep new_row,
return;
/* Get bitmap buffer */
- buffer = bitmap_get_buffer(png_c->bitmap);
+ buffer = guit->bitmap->get_buffer(png_c->bitmap);
if (buffer == NULL) {
/* No buffer, bail out */
longjmp(png_jmpbuf(png_s), 1);
@@ -404,9 +398,9 @@ png_cache_read_fn(png_structp png_ptr, png_bytep data, png_size_t length)
*/
static png_bytep *calc_row_pointers(struct bitmap *bitmap)
{
- int height = bitmap_get_height(bitmap);
- unsigned char *buffer= bitmap_get_buffer(bitmap);
- size_t rowstride = bitmap_get_rowstride(bitmap);
+ int height = guit->bitmap->get_height(bitmap);
+ unsigned char *buffer= guit->bitmap->get_buffer(bitmap);
+ size_t rowstride = guit->bitmap->get_rowstride(bitmap);
png_bytep *row_ptrs;
int hloop;
@@ -481,7 +475,7 @@ png_cache_convert(struct content *c)
height = png_get_image_height(png_ptr, info_ptr);
/* Claim the required memory for the converted PNG */
- bitmap = bitmap_create(width, height, BITMAP_NEW);
+ bitmap = guit->bitmap->create(width, height, BITMAP_NEW);
if (bitmap == NULL) {
/* cleanup and bail */
goto png_cache_convert_error;
@@ -500,8 +494,9 @@ png_cache_convert_error:
free((png_bytep *) row_pointers);
- if (bitmap != NULL)
- bitmap_modified((struct bitmap *)bitmap);
+ if (bitmap != NULL) {
+ guit->bitmap->modified((struct bitmap *)bitmap);
+ }
return (struct bitmap *)bitmap;
}
@@ -527,8 +522,8 @@ static bool nspng_convert(struct content *c)
}
if (png_c->bitmap != NULL) {
- bitmap_set_opaque(png_c->bitmap, bitmap_test_opaque(png_c->bitmap));
- bitmap_modified(png_c->bitmap);
+ guit->bitmap->set_opaque(png_c->bitmap, guit->bitmap->test_opaque(png_c->bitmap));
+ guit->bitmap->modified(png_c->bitmap);
}
image_cache_add(c, png_c->bitmap, png_cache_convert);
-----------------------------------------------------------------------
Summary of changes:
amiga/bitmap.c | 139 ++++++---------
amiga/bitmap.h | 80 ++++++++-
amiga/dt_anim.c | 30 ++--
amiga/dt_picture.c | 32 ++--
amiga/file.c | 2 +-
amiga/gui.c | 7 +-
amiga/icon.c | 18 +-
amiga/plotters.c | 2 +-
amiga/theme.c | 2 +-
atari/bitmap.c | 211 +++++++++-------------
atari/bitmap.h | 119 +++++++++----
atari/gui.c | 4 +-
atari/plot/font_freetype.c | 46 ++---
atari/plot/font_internal.c | 6 +-
atari/plot/plot.c | 85 ++++-----
beos/bitmap.cpp | 17 ++
beos/bitmap.h | 2 +-
beos/gui.cpp | 15 +-
cocoa/NetsurfApp.m | 4 +-
cocoa/bitmap.h | 4 +-
cocoa/bitmap.m | 16 ++
content/content.c | 3 +-
content/urldb.c | 21 ++-
desktop/browser.c | 2 +-
desktop/browser_history.c | 9 +-
desktop/gui_factory.c | 79 ++++++++-
desktop/gui_table.h | 10 ++
desktop/knockout.c | 8 +-
desktop/treeview.c | 63 +++----
framebuffer/bitmap.c | 55 ++++--
atari/about.h => framebuffer/bitmap.h | 15 +-
framebuffer/framebuffer.c | 3 +-
framebuffer/gui.c | 4 +-
gtk/bitmap.c | 62 ++++---
gtk/bitmap.h | 6 +-
gtk/gui.c | 2 +
gtk/print.c | 4 +-
image/bitmap.h | 77 ++++++--
image/bmp.c | 75 ++++----
image/gif.c | 26 +--
image/ico.c | 46 +++--
image/image.c | 32 ++--
image/image_cache.c | 4 +-
image/jpeg.c | 26 ++-
image/png.c | 39 ++---
monkey/bitmap.c | 44 +++--
{cocoa => monkey}/bitmap.h | 10 +-
monkey/fetch.h | 5 +
monkey/main.c | 2 +
riscos/bitmap.c | 312 +++++++++++++++++----------------
riscos/bitmap.h | 17 +-
riscos/gui.c | 2 +
riscos/plotters.c | 4 +-
riscos/save.c | 6 +-
riscos/save_draw.c | 2 +-
riscos/thumbnail.c | 16 +-
riscos/window.c | 6 +-
windows/bitmap.c | 61 ++++---
windows/bitmap.h | 5 +
windows/main.c | 2 +
windows/thumbnail.c | 4 +-
61 files changed, 1192 insertions(+), 818 deletions(-)
copy atari/about.h => framebuffer/bitmap.h (73%)
copy {cocoa => monkey}/bitmap.h (76%)
diff --git a/amiga/bitmap.c b/amiga/bitmap.c
index 633d8d0..67e7b15 100644
--- a/amiga/bitmap.c
+++ b/amiga/bitmap.c
@@ -35,6 +35,7 @@
#include "utils/messages.h"
#include "desktop/mouse.h"
#include "desktop/gui_window.h"
+#include "image/bitmap.h"
#include "amiga/gui.h"
#include "amiga/bitmap.h"
@@ -42,16 +43,8 @@
#include "amiga/misc.h"
#include "amiga/rtg.h"
-/**
- * Create a bitmap.
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-
-void *bitmap_create(int width, int height, unsigned int state)
+/* exported function documented in amiga/bitmap.h */
+void *amiga_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
@@ -70,31 +63,15 @@ void *bitmap_create(int width, int height, unsigned int state)
}
-/**
- * Return a pointer to the pixel data in a bitmap.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- *
- * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
- * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
- */
-
-unsigned char *bitmap_get_buffer(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+unsigned char *amiga_bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
return bm->pixdata;
}
-
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
-
-size_t bitmap_get_rowstride(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+size_t amiga_bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -109,13 +86,8 @@ size_t bitmap_get_rowstride(void *bitmap)
}
-/**
- * Free a bitmap.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-
-void bitmap_destroy(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+void amiga_bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -142,16 +114,8 @@ void bitmap_destroy(void *bitmap)
}
-/**
- * Save a bitmap in the platform's native format.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \param path pathname for file
- * \param flags flags controlling how the bitmap is saved.
- * \return true on success, false on error and error reported
- */
-
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+/* exported function documented in amiga/bitmap.h */
+bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags)
{
int err = 0;
Object *dto = NULL;
@@ -171,12 +135,9 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
}
-/**
- * The bitmap image has changed, so flush any persistant cache.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-void bitmap_modified(void *bitmap) {
+/* exported function documented in amiga/bitmap.h */
+void amiga_bitmap_modified(void *bitmap)
+{
struct bitmap *bm = bitmap;
if((bm->nativebm) && (bm->dto == NULL))
@@ -189,13 +150,9 @@ void bitmap_modified(void *bitmap) {
bm->native_mask = NULL;
}
-/**
- * Sets whether a bitmap should be plotted opaque
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \param opaque whether the bitmap should be plotted opaque
- */
-void bitmap_set_opaque(void *bitmap, bool opaque)
+
+/* exported function documented in amiga/bitmap.h */
+void amiga_bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
assert(bitmap);
@@ -203,13 +160,8 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
}
-/**
- * Tests whether a bitmap has an opaque alpha channel
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return whether the bitmap is opaque
- */
-bool bitmap_test_opaque(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+bool amiga_bitmap_test_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
uint32 p = bm->width * bm->height;
@@ -227,19 +179,18 @@ bool bitmap_test_opaque(void *bitmap)
}
-/**
- * Gets whether a bitmap should be plotted opaque
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-bool bitmap_get_opaque(void *bitmap)
+/* exported function documented in amiga/bitmap.h */
+bool amiga_bitmap_get_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
assert(bitmap);
return bm->opaque;
}
-int bitmap_get_width(void *bitmap)
+/**
+ * get width of a bitmap.
+ */
+static int bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -253,7 +204,10 @@ int bitmap_get_width(void *bitmap)
}
}
-int bitmap_get_height(void *bitmap)
+/**
+ * get height of a bitmap.
+ */
+static int bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -274,8 +228,7 @@ int bitmap_get_height(void *bitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return bytes per pixel
*/
-
-size_t bitmap_get_bpp(void *vbitmap)
+static size_t bitmap_get_bpp(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
@@ -318,7 +271,7 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
bmhd->bmh_Width = (UWORD)bitmap_get_width(bitmap);
bmhd->bmh_Height = (UWORD)bitmap_get_height(bitmap);
bmhd->bmh_Depth = (UBYTE)bitmap_get_bpp(bitmap) * 8;
- if(!bitmap_get_opaque(bitmap)) bmhd->bmh_Masking = mskHasAlpha;
+ if(!amiga_bitmap_get_opaque(bitmap)) bmhd->bmh_Masking = mskHasAlpha;
}
SetDTAttrs(dto,NULL,NULL,
@@ -330,8 +283,8 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
PDTA_SourceMode,PMODE_V43,
TAG_DONE);
- IDoMethod(dto, PDTM_WRITEPIXELARRAY, bitmap_get_buffer(bitmap),
- PBPAFMT_RGBA, bitmap_get_rowstride(bitmap), 0, 0,
+ IDoMethod(dto, PDTM_WRITEPIXELARRAY, amiga_bitmap_get_buffer(bitmap),
+ PBPAFMT_RGBA, amiga_bitmap_get_rowstride(bitmap), 0, 0,
bitmap_get_width(bitmap), bitmap_get_height(bitmap));
}
@@ -353,13 +306,13 @@ struct bitmap *ami_bitmap_from_datatype(char *filename)
if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE))
{
- bm = bitmap_create(bmh->bmh_Width, bmh->bmh_Height, 0);
+ bm = amiga_bitmap_create(bmh->bmh_Width, bmh->bmh_Height, 0);
- IDoMethod(dto, PDTM_READPIXELARRAY, bitmap_get_buffer(bm),
- PBPAFMT_RGBA, bitmap_get_rowstride(bm), 0, 0,
+ IDoMethod(dto, PDTM_READPIXELARRAY, amiga_bitmap_get_buffer(bm),
+ PBPAFMT_RGBA, amiga_bitmap_get_rowstride(bm), 0, 0,
bmh->bmh_Width, bmh->bmh_Height);
- bitmap_set_opaque(bm, bitmap_test_opaque(bm));
+ amiga_bitmap_set_opaque(bm, amiga_bitmap_test_opaque(bm));
}
DisposeDTObject(dto);
}
@@ -477,7 +430,7 @@ PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width,
int y, x, bpr;
if((height != bitmap->height) || (width != bitmap->width)) return NULL;
- if(bitmap_get_opaque(bitmap) == true) return NULL;
+ if(amiga_bitmap_get_opaque(bitmap) == true) return NULL;
if(bitmap->native_mask) return bitmap->native_mask;
bm_width = GetBitMapAttr(n_bm, BMA_WIDTH);
@@ -552,3 +505,19 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
}
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = amiga_bitmap_create,
+ .destroy = amiga_bitmap_destroy,
+ .set_opaque = amiga_bitmap_set_opaque,
+ .get_opaque = amiga_bitmap_get_opaque,
+ .test_opaque = amiga_bitmap_test_opaque,
+ .get_buffer = amiga_bitmap_get_buffer,
+ .get_rowstride = amiga_bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = amiga_bitmap_save,
+ .modified = amiga_bitmap_modified,
+};
+
+struct gui_bitmap_table *amiga_bitmap_table = &bitmap_table;
diff --git a/amiga/bitmap.h b/amiga/bitmap.h
index 6657d2f..63969ec 100755
--- a/amiga/bitmap.h
+++ b/amiga/bitmap.h
@@ -18,7 +18,6 @@
#ifndef AMIGA_BITMAP_H
#define AMIGA_BITMAP_H
-#include "image/bitmap.h"
#include <exec/types.h>
#include <proto/graphics.h>
@@ -28,6 +27,8 @@
#define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8
#define AMI_BITMAP_FORCE_OVERWRITE 0xFF
+struct gui_bitmap_table *amiga_bitmap_table;
+
struct bitmap {
int width;
int height;
@@ -55,4 +56,81 @@ struct bitmap *ami_bitmap_from_datatype(char *filename);
void ami_bitmap_argb_to_rgba(struct bitmap *bm);
#endif
+/**
+ * Create a bitmap.
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+void *amiga_bitmap_create(int width, int height, unsigned int state);
+
+/**
+ * Return a pointer to the pixel data in a bitmap.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return pointer to the pixel buffer
+ *
+ * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
+ * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
+ */
+unsigned char *amiga_bitmap_get_buffer(void *bitmap);
+
+/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
+size_t amiga_bitmap_get_rowstride(void *bitmap);
+
+/**
+ * Free a bitmap.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+void amiga_bitmap_destroy(void *bitmap);
+
+/**
+ * Save a bitmap in the platform's native format.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \param path pathname for file
+ * \param flags flags controlling how the bitmap is saved.
+ * \return true on success, false on error and error reported
+ */
+bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags);
+
+/**
+ * The bitmap image has changed, so flush any persistant cache.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+void amiga_bitmap_modified(void *bitmap);
+
+/**
+ * Sets whether a bitmap should be plotted opaque
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \param opaque whether the bitmap should be plotted opaque
+ */
+void amiga_bitmap_set_opaque(void *bitmap, bool opaque);
+
+/**
+ * Tests whether a bitmap has an opaque alpha channel
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return whether the bitmap is opaque
+ */
+bool amiga_bitmap_test_opaque(void *bitmap);
+
+/**
+ * Gets whether a bitmap should be plotted opaque
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+bool amiga_bitmap_get_opaque(void *bitmap);
+
+
#endif
diff --git a/amiga/dt_anim.c b/amiga/dt_anim.c
index f69af31..723bd13 100644
--- a/amiga/dt_anim.c
+++ b/amiga/dt_anim.c
@@ -23,16 +23,6 @@
#ifdef WITH_AMIGA_DATATYPES
#include "amiga/os3support.h"
-#include "amiga/filetype.h"
-#include "amiga/datatypes.h"
-#include "amiga/misc.h"
-#include "amiga/plotters.h"
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-
#include <proto/datatypes.h>
#include <proto/dos.h>
#include <proto/exec.h>
@@ -44,6 +34,18 @@
#endif
#include <intuition/classusr.h>
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "content/content_protected.h"
+#include "desktop/plotters.h"
+#include "image/bitmap.h"
+
+#include "amiga/bitmap.h"
+#include "amiga/filetype.h"
+#include "amiga/datatypes.h"
+#include "amiga/misc.h"
+#include "amiga/plotters.h"
+
typedef struct amiga_dt_anim_content {
struct content base;
@@ -183,14 +185,14 @@ bool amiga_dt_anim_convert(struct content *c)
width = (int)bmh->bmh_Width;
height = (int)bmh->bmh_Height;
- plugin->bitmap = bitmap_create(width, height, bm_flags);
+ plugin->bitmap = amiga_bitmap_create(width, height, bm_flags);
if (!plugin->bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
- bm_buffer = bitmap_get_buffer(plugin->bitmap);
+ bm_buffer = amiga_bitmap_get_buffer(plugin->bitmap);
adt_frame.MethodID = ADTM_LOADFRAME;
adt_frame.alf_TimeStamp = 0;
@@ -229,7 +231,7 @@ bool amiga_dt_anim_convert(struct content *c)
content__set_title(c, title);
*/
- bitmap_modified(plugin->bitmap);
+ amiga_bitmap_modified(plugin->bitmap);
content_set_ready(c);
content_set_done(c);
@@ -245,7 +247,7 @@ void amiga_dt_anim_destroy(struct content *c)
LOG(("amiga_dt_anim_destroy"));
if (plugin->bitmap != NULL)
- bitmap_destroy(plugin->bitmap);
+ amiga_bitmap_destroy(plugin->bitmap);
DisposeDTObject(plugin->dto);
diff --git a/amiga/dt_picture.c b/amiga/dt_picture.c
index 15fc30e..b5c3ba5 100644
--- a/amiga/dt_picture.c
+++ b/amiga/dt_picture.c
@@ -23,22 +23,25 @@
#ifdef WITH_AMIGA_DATATYPES
#include "amiga/os3support.h"
-#include "amiga/bitmap.h"
-#include "amiga/filetype.h"
-#include "amiga/datatypes.h"
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
-#include "image/image_cache.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-
+#include <stdbool.h>
#include <proto/datatypes.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <datatypes/pictureclass.h>
#include <intuition/classusr.h>
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "content/content_protected.h"
+#include "desktop/plotters.h"
+#include "image/bitmap.h"
+#include "image/image_cache.h"
+
+#include "amiga/bitmap.h"
+#include "amiga/filetype.h"
+#include "amiga/datatypes.h"
+
+
static nserror amiga_dt_picture_create(const content_handler *handler,
lwc_string *imime_type, const http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
@@ -179,20 +182,21 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
if((dto = amiga_dt_picture_newdtobject(adt)))
{
- bitmap = bitmap_create(c->width, c->height, BITMAP_NEW);
+ bitmap = amiga_bitmap_create(c->width, c->height, BITMAP_NEW);
if (!bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return NULL;
}
- bm_buffer = bitmap_get_buffer(bitmap);
+ bm_buffer = amiga_bitmap_get_buffer(bitmap);
IDoMethod(dto, PDTM_READPIXELARRAY,
- bm_buffer, PBPAFMT_RGBA, bitmap_get_rowstride(bitmap),
+ bm_buffer, PBPAFMT_RGBA,
+ amiga_bitmap_get_rowstride(bitmap),
0, 0, c->width, c->height);
- bitmap_set_opaque(bitmap, bitmap_test_opaque(bitmap));
+ amiga_bitmap_set_opaque(bitmap, amiga_bitmap_test_opaque(bitmap));
DisposeDTObject(dto);
adt->dto = NULL;
diff --git a/amiga/file.c b/amiga/file.c
index e7f1fd3..307fbfc 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -188,7 +188,7 @@ void ami_file_save(int type, char *fname, struct Window *win,
if((bm = content_get_bitmap(object))) {
bm->url = (char *)nsurl_access(hlcache_handle_get_url(object));
bm->title = (char *)content_get_title(object);
- bitmap_save(bm, fname, 0);
+ amiga_bitmap_save(bm, fname, 0);
}
#ifdef WITH_NS_SVG
else if(ami_mime_compare(object, "svg") == true) {
diff --git a/amiga/gui.c b/amiga/gui.c
index dd06771..3df4d54 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -828,8 +828,8 @@ static void ami_gui_commandline(int *argc, char **argv)
p++;
} while(*p != NULL);
- char *new_argv = malloc(sizeof(char *) * new_argc);
- char **new_argvp = &new_argv;
+ const char *new_argv = malloc(sizeof(char *) * new_argc);
+ const char **new_argvp = &new_argv;
*new_argvp = messages_get("NetSurf");
p = (char **)rarray[A_NSOPTS];
@@ -3082,7 +3082,7 @@ static void ami_gui_cache_favicon(nsurl *url, struct bitmap *favicon)
STRPTR filename = NULL;
if ((filename = ami_gui_get_cache_favicon_name(url, false))) {
- if(favicon) bitmap_save(favicon, filename, AMI_BITMAP_FORCE_OVERWRITE);
+ if(favicon) amiga_bitmap_save(favicon, filename, AMI_BITMAP_FORCE_OVERWRITE);
FreeVec(filename);
}
}
@@ -5410,6 +5410,7 @@ int main(int argc, char** argv)
.search = amiga_search_table,
.search_web = &amiga_search_web_table,
.llcache = filesystem_llcache_table,
+ .bitmap = amiga_bitmap_table,
};
#ifdef __amigaos4__
diff --git a/amiga/icon.c b/amiga/icon.c
index dfbf84c..042e1a8 100644
--- a/amiga/icon.c
+++ b/amiga/icon.c
@@ -26,6 +26,7 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <proto/exec.h>
#include <proto/icon.h>
@@ -36,10 +37,6 @@
#endif
#include <workbench/icon.h>
-#include "amiga/os3support.h"
-#include "amiga/bitmap.h"
-#include "amiga/icon.h"
-#include "amiga/misc.h"
#include "desktop/plotters.h"
#include "image/bitmap.h"
#include "content/content_protected.h"
@@ -48,6 +45,11 @@
#include "utils/utils.h"
#include "utils/file.h"
+#include "amiga/os3support.h"
+#include "amiga/bitmap.h"
+#include "amiga/icon.h"
+#include "amiga/misc.h"
+
#define THUMBNAIL_WIDTH 100 /* Icon sizes for thumbnails, usually the same as */
#define THUMBNAIL_HEIGHT 86 /* WIDTH/HEIGHT in desktop/thumbnail.c */
@@ -182,14 +184,14 @@ bool amiga_icon_convert(struct content *c)
return false;
}
- icon_c->bitmap = bitmap_create(width, height, BITMAP_NEW);
+ icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NEW);
if (!icon_c->bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
if(dobj) FreeDiskObject(dobj);
return false;
}
- imagebuf = (ULONG *) bitmap_get_buffer(icon_c->bitmap);
+ imagebuf = (ULONG *) amiga_bitmap_get_buffer(icon_c->bitmap);
if (!imagebuf) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -229,7 +231,7 @@ bool amiga_icon_convert(struct content *c)
c->width = width;
c->height = height;
- bitmap_modified(icon_c->bitmap);
+ amiga_bitmap_modified(icon_c->bitmap);
content_set_ready(c);
content_set_done(c);
content_set_status(c, "");
@@ -252,7 +254,7 @@ void amiga_icon_destroy(struct content *c)
amiga_icon_content *icon_c = (amiga_icon_content *)c;
if (icon_c->bitmap != NULL)
- bitmap_destroy(icon_c->bitmap);
+ amiga_bitmap_destroy(icon_c->bitmap);
}
diff --git a/amiga/plotters.c b/amiga/plotters.c
index 899ec49..4c86f31 100644
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -510,7 +510,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
(nsoption_bool(direct_render) == false), 1)) {
uint32 comptype = COMPOSITE_Src_Over_Dest;
uint32 compflags = COMPFLAG_IgnoreDestAlpha;
- if(bitmap_get_opaque(bitmap)) {
+ if(amiga_bitmap_get_opaque(bitmap)) {
compflags |= COMPFLAG_SrcAlphaOverride;
comptype = COMPOSITE_Src;
}
diff --git a/amiga/theme.c b/amiga/theme.c
index b75f6ed..4d6107a 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -176,7 +176,7 @@ void ami_theme_throbber_setup(void)
void ami_theme_throbber_free(void)
{
- bitmap_destroy(throbber_nsbm);
+ amiga_bitmap_destroy(throbber_nsbm);
throbber = NULL;
}
diff --git a/atari/bitmap.c b/atari/bitmap.c
index 3bca82e..52e515f 100755
--- a/atari/bitmap.c
+++ b/atari/bitmap.c
@@ -68,20 +68,6 @@ int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out )
/**
* Create a bitmap.
*
- * \param w width of image in pixels
- * \param h width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-
-void *bitmap_create(int w, int h, unsigned int state)
-{
- return bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, state, NULL );
-}
-
-/**
- * Create a bitmap.
- *
* \param w width of image in pixels
* \param h height of image in pixels
* \param bpp number of BYTES per pixel
@@ -90,7 +76,7 @@ void *bitmap_create(int w, int h, unsigned int state)
* \param pixdata NULL or an memory address to use as the bitmap pixdata
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata )
+static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata )
{
struct bitmap * bitmap;
@@ -128,7 +114,37 @@ void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int st
return bitmap;
}
-void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp )
+
+/* exported interface documented in atari/bitmap.h */
+void *atari_bitmap_create(int w, int h, unsigned int state)
+{
+ return atari_bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, state, NULL );
+}
+
+/**
+ * The bitmap image has changed, so flush any persistant cache.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+static void bitmap_modified(void *bitmap)
+{
+ struct bitmap *bm = bitmap;
+ if( bm->resized != NULL ) {
+ atari_bitmap_destroy( bm->resized );
+ bm->resized = NULL;
+ }
+ if( bm->converted ){
+ if( bm->pixdata != bm->native.fd_addr ){
+ free( bm->native.fd_addr );
+ }
+ bm->native.fd_addr = NULL;
+ bm->converted = false;
+ }
+}
+
+
+/* exported interface documented in atari/bitmap.h */
+void *atari_bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp )
{
struct bitmap * bitmap = bmp;
int newsize = rowstride * h;
@@ -163,46 +179,6 @@ void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int stat
return( bitmap );
}
-void bitmap_to_mfdb(void * bitmap, MFDB * out)
-{
- struct bitmap * bm;
- uint8_t * tmp;
- size_t dststride, oldstride;
-
- bm = bitmap;
- assert( out != NULL );
- assert( bm->pixdata != NULL );
-
- oldstride = bitmap_get_rowstride( bm );
- dststride = MFDB_STRIDE( bm->width );
-
- if( oldstride != dststride * bm->bpp )
- {
- assert( oldstride <= dststride );
- /* we need to convert the img to new rowstride */
- tmp = bm->pixdata;
- bm->pixdata = calloc(1, dststride * bm->bpp * bm->height );
- if( tmp == NULL ){
- bm->pixdata = tmp;
- out->fd_addr = NULL;
- return;
- }
- bm->rowstride = dststride * bm->bpp;
- int i=0;
- for( i=0; i<bm->height; i++) {
- memcpy( (bm->pixdata+i*bm->rowstride), (tmp + i*oldstride), oldstride);
- }
- free( tmp );
- }
- out->fd_w = dststride;
- out->fd_h = bm->height;
- out->fd_wdwidth = dststride >> 4;
- out->fd_addr = bm->pixdata;
- out->fd_stand = 0;
- out->fd_nplanes = (short)bm->bpp;
- out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
-}
-
/**
* Return a pointer to the pixel data in a bitmap.
@@ -213,8 +189,7 @@ void bitmap_to_mfdb(void * bitmap, MFDB * out)
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-
-unsigned char * bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -226,7 +201,9 @@ unsigned char * bitmap_get_buffer(void *bitmap)
return bm->pixdata;
}
-size_t bitmap_buffer_size( void * bitmap )
+
+/* exported interface documented in atari/bitmap.h */
+size_t atari_bitmap_buffer_size(void *bitmap)
{
struct bitmap * bm = bitmap;
if( bm == NULL )
@@ -235,14 +212,8 @@ size_t bitmap_buffer_size( void * bitmap )
}
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
-
-size_t bitmap_get_rowstride(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+size_t atari_bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -254,13 +225,8 @@ size_t bitmap_get_rowstride(void *bitmap)
}
-/**
- * Free a bitmap.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-
-void bitmap_destroy(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+void atari_bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -270,10 +236,11 @@ void bitmap_destroy(void *bitmap)
}
if( bm->resized != NULL ) {
- bitmap_destroy(bm->resized);
+ atari_bitmap_destroy(bm->resized);
}
- if( bm->converted && ( bm->native.fd_addr != bm->pixdata ) )
+ if( bm->converted && ( bm->native.fd_addr != bm->pixdata ) ) {
free( bm->native.fd_addr );
+ }
free(bm->pixdata);
free(bm);
}
@@ -288,32 +255,11 @@ void bitmap_destroy(void *bitmap)
* \return true on success, false on error and error reported
*/
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
-/**
- * The bitmap image has changed, so flush any persistant cache.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-void bitmap_modified(void *bitmap)
-{
- struct bitmap *bm = bitmap;
- if( bm->resized != NULL ) {
- bitmap_destroy( bm->resized );
- bm->resized = NULL;
- }
- if( bm->converted ){
- if( bm->pixdata != bm->native.fd_addr ){
- free( bm->native.fd_addr );
- }
- bm->native.fd_addr = NULL;
- bm->converted = false;
- }
-
-}
/**
* Sets whether a bitmap should be plotted opaque
@@ -321,7 +267,7 @@ void bitmap_modified(void *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
@@ -341,7 +287,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
int tst;
struct bitmap *bm = bitmap;
@@ -368,12 +314,8 @@ bool bitmap_test_opaque(void *bitmap)
}
-/**
- * Gets whether a bitmap should be plotted opaque
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-bool bitmap_get_opaque(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+bool atari_bitmap_get_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -385,7 +327,9 @@ bool bitmap_get_opaque(void *bitmap)
return bm->opaque;
}
-int bitmap_get_width(void *bitmap)
+
+/* exported interface documented in atari/bitmap.h */
+int atari_bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -397,7 +341,9 @@ int bitmap_get_width(void *bitmap)
return(bm->width);
}
-int bitmap_get_height(void *bitmap)
+
+/* exported interface documented in atari/bitmap.h */
+int atari_bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -410,27 +356,26 @@ int bitmap_get_height(void *bitmap)
/**
-*
-* Gets the number of BYTES per pixel.
-*
-*/
-size_t bitmap_get_bpp(void *bitmap)
+ * Gets the number of BYTES per pixel.
+ */
+static size_t bitmap_get_bpp(void *bitmap)
{
struct bitmap *bm = bitmap;
return bm->bpp;
}
-bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
+/* exported interface documented in atari/bitmap.h */
+bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
HermesFormat *fmt, int nw, int nh)
{
unsigned int state = 0;
short bpp = bitmap_get_bpp( img );
- int stride = bitmap_get_rowstride( img );
+ int stride = atari_bitmap_get_rowstride( img );
int err;
if( img->resized != NULL ) {
if( img->resized->width != nw || img->resized->height != nh ) {
- bitmap_destroy( img->resized );
+ atari_bitmap_destroy( img->resized );
img->resized = NULL;
} else {
/* the bitmap is already resized */
@@ -442,7 +387,7 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
if (img->opaque == true) {
state |= BITMAP_OPAQUE;
}
- img->resized = bitmap_create_ex( nw, nh, bpp, nw*bpp, state, NULL );
+ img->resized = atari_bitmap_create_ex( nw, nh, bpp, nw*bpp, state, NULL );
if( img->resized == NULL ) {
printf("W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
assert(img->resized);
@@ -460,18 +405,19 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
err = Hermes_ConverterCopy( hermes_h,
img->pixdata,
- 0, /* x src coord of top left in pixel coords */
- 0, /* y src coord of top left in pixel coords */
- bitmap_get_width( img ), bitmap_get_height( img ),
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ atari_bitmap_get_width( img ),
+ atari_bitmap_get_height( img ),
stride, /* stride as bytes */
img->resized->pixdata,
- 0, /* x dst coord of top left in pixel coords */
- 0, /* y dst coord of top left in pixel coords */
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
nw, nh,
- bitmap_get_rowstride(img->resized) /* stride as bytes */
+ atari_bitmap_get_rowstride(img->resized) /* stride as bytes */
);
if( err == 0 ) {
- bitmap_destroy( img->resized );
+ atari_bitmap_destroy( img->resized );
img->resized = NULL;
return(false);
}
@@ -479,6 +425,23 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
return(true);
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = atari_bitmap_create,
+ .destroy = atari_bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = atari_bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = atari_bitmap_get_rowstride,
+ .get_width = atari_bitmap_get_width,
+ .get_height = atari_bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *atari_bitmap_table = &bitmap_table;
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/atari/bitmap.h b/atari/bitmap.h
index ed80938..b0fa180 100755
--- a/atari/bitmap.h
+++ b/atari/bitmap.h
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Atari bitmap handling implementation.
+ */
+
#ifndef NS_ATARI_BITMAP_H
#define NS_ATARI_BITMAP_H
@@ -24,33 +29,33 @@
#define NS_BMP_DEFAULT_BPP 4
-/* Flags for init_mfdb function: */
-#define MFDB_FLAG_STAND 0x01
-#define MFDB_FLAG_ZEROMEM 0x02
-#define MFDB_FLAG_NOALLOC 0x04
+/* Flags for init_mfdb function: */
+#define MFDB_FLAG_STAND 0x01
+#define MFDB_FLAG_ZEROMEM 0x02
+#define MFDB_FLAG_NOALLOC 0x04
-#define BITMAP_SHRINK 0
-#define BITMAP_GROW 1024 /* Don't realloc when bitmap size shrinks */
-#define BITMAP_CLEAR 2048 /* Zero bitmap memory */
+#define BITMAP_SHRINK 0
+#define BITMAP_GROW 1024 /* Don't realloc when bitmap size shrinks */
+#define BITMAP_CLEAR 2048 /* Zero bitmap memory */
-/*
- calculates MFDB compatible rowstride (in number of bits)
-*/
+/**
+ * Calculates MFDB compatible rowstride (in number of bits)
+ */
#define MFDB_STRIDE( w ) (((w & 15) != 0) ? (w | 15)+1 : w)
-/*
-Calculate size of an mfdb,
-
- params:
-
- bpp: Bits per pixel,
- stride: Word aligned rowstride (width) as returned by MFDB_STRIDE,
- h: Height in pixels
+/**
+ * Calculate size of an mfdb,
+ *
+ * \param bpp Bits per pixel.
+ * \param stride Word aligned rowstride (width) as returned by MFDB_STRIDE,
+ * \param h Height in pixels.
*/
#define MFDB_SIZE( bpp, stride, h ) ( ((stride >> 3) * h) * bpp )
+struct gui_bitmap_table *atari_bitmap_table;
+
struct bitmap {
int width;
int height;
@@ -63,20 +68,70 @@ struct bitmap {
bool converted;
};
-void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata );
-void bitmap_to_mfdb(void * bitmap, MFDB * out);
-void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp );
-size_t bitmap_buffer_size( void * bitmap ) ;
-bool bitmap_resize(struct bitmap * img, HermesHandle hermes_h,
- HermesFormat *fmt, int nw, int nh);
-/*
- setup an MFDB struct and allocate memory for it when it is needed.
- If bpp == 0, this function assumes that the MFDB shall point to the screen
- and will not allocate any memory (mfdb.fd_addr == 0).
- The function will return 0 when the memory allocation fails
- ( out of memory), otherwise it returns the size of the mfdb.fd_addr
- as number of bytes.
-*/
+
+
+/**
+ * setup an MFDB struct and allocate memory for it when it is needed.
+ *
+ * If bpp == 0, this function assumes that the MFDB shall point to the
+ * screen and will not allocate any memory (mfdb.fd_addr == 0).
+ *
+ * \return 0 when the memory allocation fails (out of memory),
+ * otherwise it returns the size of the mfdb.fd_addr as number
+ * of bytes.
+ */
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out );
+/**
+ * Create a bitmap.
+ *
+ * \param w width of image in pixels
+ * \param h width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+void *atari_bitmap_create(int w, int h, unsigned int state);
+
+/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
+size_t atari_bitmap_get_rowstride(void *bitmap);
+
+/**
+ * Free a bitmap.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+void atari_bitmap_destroy(void *bitmap);
+
+/**
+ * Get bitmap width
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+int atari_bitmap_get_width(void *bitmap);
+
+/**
+ * Get bitmap height
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+int atari_bitmap_get_height(void *bitmap);
+
+/**
+ * Gets whether a bitmap should be plotted opaque
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+bool atari_bitmap_get_opaque(void *bitmap);
+
+size_t atari_bitmap_buffer_size(void *bitmap);
+
+bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h, HermesFormat *fmt, int nw, int nh);
+
+void *atari_bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp );
+
#endif
diff --git a/atari/gui.c b/atari/gui.c
index 3cd22e6..daf342a 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -77,6 +77,7 @@
#include "atari/download.h"
#include "atari/file.h"
#include "atari/filetype.h"
+#include "atari/bitmap.h"
#include "cflib.h"
static bool atari_quit = false;
@@ -1130,7 +1131,8 @@ int main(int argc, char** argv)
.file = atari_file_table,
.utf8 = atari_utf8_table,
.search = atari_search_table,
- .llcache = filesystem_llcache_table
+ .llcache = filesystem_llcache_table,
+ .bitmap = atari_bitmap_table
};
ret = netsurf_register(&atari_table);
diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c
index b88505d..c4d7748 100755
--- a/atari/plot/font_freetype.c
+++ b/atari/plot/font_freetype.c
@@ -94,23 +94,23 @@ fantasy.ttf => Fantasy
#define CACHE_MIN_SIZE (100 * 1024)
#define BOLD_WEIGHT 700
-extern unsigned long atari_plot_flags;
-extern int atari_plot_vdi_handle;
-
-static FT_Library library;
-static FTC_Manager ft_cmanager;
-static FTC_CMapCache ft_cmap_cache ;
-static FTC_ImageCache ft_image_cache;
-
-int ft_load_type;
-
-/* cache manager faceID data to create freetype faceid on demand */
-typedef struct ftc_faceid_s {
- char *fontfile; /* path to font */
- int index; /* index of font */
- int cidx; /* character map index for unicode */
-} ftc_faceid_t;
-
+extern unsigned long atari_plot_flags;
+extern int atari_plot_vdi_handle;
+
+static FT_Library library;
+static FTC_Manager ft_cmanager;
+static FTC_CMapCache ft_cmap_cache ;
+static FTC_ImageCache ft_image_cache;
+
+int ft_load_type;
+
+/* cache manager faceID data to create freetype faceid on demand */
+typedef struct ftc_faceid_s {
+ char *fontfile; /* path to font */
+ int index; /* index of font */
+ int cidx; /* character map index for unicode */
+} ftc_faceid_t;
+
static int dtor( FONT_PLOTTER self );
static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle,
const char * str, size_t length, int * width );
@@ -608,10 +608,10 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
#ifdef WITH_8BPP_SUPPORT
if( app.nplanes > 8 ){
#endif
- RGB1000 out;
+ RGB1000 out; /* struct with RGB shorts */
rgb_to_vdi1000( (unsigned char*)&c, &out);
vs_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR,
- (unsigned short*)&out);
+ (short*)&out);
#ifdef WITH_8BPP_SUPPORT
} else {
c = RGB_TO_VDI(c);
@@ -625,10 +625,10 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
clip.g_w = (clipping.x1 - clipping.x0)+1;
clip.g_h = (clipping.y1 - clipping.y0)+1;
- fontbmp = bitmap_realloc( clip.g_w, clip.g_h,
+ fontbmp = atari_bitmap_realloc( clip.g_w, clip.g_h,
4, clip.g_w << 2,
BITMAP_GROW, fontbmp );
- fontbmp_stride = bitmap_get_rowstride(fontbmp);
+ fontbmp_stride = atari_bitmap_get_rowstride(fontbmp);
fontbmp_allocated_height = clip.g_h;
fontbmp_allocated_width = clip.g_w;
@@ -684,7 +684,7 @@ int ctor_font_plotter_freetype( FONT_PLOTTER self )
LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
if( !init ) {
ft_font_init();
- fontbmp = bitmap_create(48, 48, 0);
+ fontbmp = atari_bitmap_create(48, 48, 0);
fontbmp->opaque = false;
init = true;
}
@@ -696,7 +696,7 @@ static int dtor( FONT_PLOTTER self )
{
ft_font_finalise();
if( fontbmp != NULL ) {
- bitmap_destroy( fontbmp );
+ atari_bitmap_destroy( fontbmp );
fontbmp = NULL;
}
if( tmp.fd_addr != NULL ){
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 0a8619f..427444d 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -95,7 +95,7 @@ int ctor_font_plotter_internal( FONT_PLOTTER self )
LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
if( !init ) {
vdih = self->vdi_handle;
- fontbmp = bitmap_create(48, 48, 0);
+ fontbmp = atari_bitmap_create(48, 48, 0);
fontbmp->opaque = false;
}
init = true;
@@ -164,8 +164,8 @@ static void draw_glyph1(FONT_PLOTTER self, GRECT *inloc, uint8_t *chrp, int pitc
uint32_t * linebuf;
GRECT loc = *inloc;
- fontbmp = bitmap_realloc( loc.g_w, loc.g_h, fontbmp->bpp, loc.g_w * fontbmp->bpp, BITMAP_GROW, fontbmp );
- bmpstride = bitmap_get_rowstride(fontbmp);
+ fontbmp = atari_bitmap_realloc( loc.g_w, loc.g_h, fontbmp->bpp, loc.g_w * fontbmp->bpp, BITMAP_GROW, fontbmp );
+ bmpstride = atari_bitmap_get_rowstride(fontbmp);
for( yloop = 0; yloop < loc.g_h; yloop++) {
uint32_t pixmask = 1 ;
linebuf = (uint32_t *)(fontbmp->pixdata + (bmpstride * yloop));
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 1b949d2..523ce44 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -164,11 +164,11 @@ struct s_vdi_sysinfo vdi_sysinfo;
static int atari_plot_bpp_virt;
static struct s_view view;
-static HermesHandle hermes_pal_h; /* hermes palette handle */
+//static HermesHandle hermes_pal_h; /* hermes palette handle */
static HermesHandle hermes_cnv_h; /* hermes converter instance handle */
static HermesHandle hermes_res_h;
-static short prev_vdi_clip[4];
+//static short prev_vdi_clip[4];
static struct bitmap snapshot;
VdiHdl atari_plot_vdi_handle = -1;
@@ -195,10 +195,9 @@ inline static void vsl_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- //unsigned short c[4];
- RGB1000 c;
+ RGB1000 c; /* a struct with three (RGB) shorts */
rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color(vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vs_color(vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
vsl_color(vdih, OFFSET_CUSTOM_COLOR);
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -222,9 +221,9 @@ inline static void vsf_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- RGB1000 c;
+ RGB1000 c; /* a struct with three (RGB) shorts */
rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
vsf_color( vdih, OFFSET_CUSTOM_COLOR );
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -383,15 +382,17 @@ bool plot_copy_rect(GRECT src, GRECT dst)
/**
* Fill the screen info structure.
*
+ * \param vdhi The handle
+ * \param[out] info The infor structure to fill.
*/
-static struct s_vdi_sysinfo * read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
+static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
- unsigned long cookie_EdDI=0;
+ unsigned long cookie_EdDI=0; /** \todo this long is being cast to a pointer */
short out[300];
memset( info, 0, sizeof(struct s_vdi_sysinfo) );
info->vdi_handle = vdih;
- if ( tos_getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND ) {
+ if ( tos_getcookie(C_EdDI, (long *)&cookie_EdDI) == C_NOTFOUND ) {
info->EdDiVersion = 0;
} else {
info->EdDiVersion = EdDI_version( (void *)cookie_EdDI );
@@ -668,20 +669,20 @@ static void dump_vdi_info(short vdih)
printf(" short scr_h: %d\n", temp.scr_h);
printf(" short scr_bpp: %d\n", temp.scr_bpp);
printf(" int colors: %d\n", temp.colors);
- printf(" ulong hicolors: %d\n", temp.hicolors);
+ printf(" ulong hicolors: %lu\n", temp.hicolors);
printf(" short pixelsize: %d\n", temp.pixelsize);
printf(" unsigned short pitch: %d\n", temp.pitch);
printf(" unsigned short vdiformat: %d\n", temp.vdiformat);
printf(" unsigned short clut: %d\n", temp.clut);
printf(" void * screen: 0x0%p\n", temp.screen);
- printf(" unsigned long screensize: %d\n", temp.screensize);
- printf(" unsigned long mask_r: 0x0%08x\n", temp.mask_r);
- printf(" unsigned long mask_g: 0x0%08x\n", temp.mask_g);
- printf(" unsigned long mask_b: 0x0%08x\n", temp.mask_b);
- printf(" unsigned long mask_a: 0x0%08x\n", temp.mask_a);
+ printf(" unsigned long screensize: %lu\n", temp.screensize);
+ printf(" unsigned long mask_r: 0x0%08lx\n", temp.mask_r);
+ printf(" unsigned long mask_g: 0x0%08lx\n", temp.mask_g);
+ printf(" unsigned long mask_b: 0x0%08lx\n", temp.mask_b);
+ printf(" unsigned long mask_a: 0x0%08lx\n", temp.mask_a);
printf(" short maxintin: %d\n", temp.maxintin);
printf(" short maxpolycoords: %d\n", temp.maxpolycoords);
- printf(" unsigned long EdDiVersion: 0x0%03x\n", temp.EdDiVersion);
+ printf(" unsigned long EdDiVersion: 0x0%03lx\n", temp.EdDiVersion);
printf(" unsigned short rasterscale: 0x%2x\n", temp.rasterscale);
printf("};\n");
}
@@ -800,9 +801,9 @@ static struct bitmap * snapshot_create(int x, int y, int w, int h)
/* allocate buffer for result bitmap: */
if(buf_scr_compat == NULL ) {
- buf_scr_compat = bitmap_create(w, h, 0);
+ buf_scr_compat = atari_bitmap_create(w, h, 0);
} else {
- buf_scr_compat = bitmap_realloc( w, h,
+ buf_scr_compat = atari_bitmap_realloc( w, h,
buf_scr_compat->bpp,
w *buf_scr_compat->bpp,
BITMAP_GROW,
@@ -825,7 +826,7 @@ static struct bitmap * snapshot_create(int x, int y, int w, int h)
0, /* x dst coord of top left in pixel coords */
0, /* y dst coord of top left in pixel coords */
w, h,
- bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
+ atari_bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
);
assert( err != 0 );
return( (struct bitmap * )buf_scr_compat );
@@ -879,13 +880,13 @@ static void snapshot_suspend(void)
#endif
if(buf_scr_compat != NULL ) {
- size_t bs = bitmap_buffer_size(buf_scr_compat );
+ size_t bs = atari_bitmap_buffer_size(buf_scr_compat );
if( bs > CONV_KEEP_LIMIT ) {
int w = 0;
int h = 1;
w = (CONV_KEEP_LIMIT /buf_scr_compat->bpp);
assert( CONV_KEEP_LIMIT == w*buf_scr_compat->bpp );
- buf_scr_compat = bitmap_realloc( w, h,
+ buf_scr_compat = atari_bitmap_realloc( w, h,
buf_scr_compat->bpp,
CONV_KEEP_LIMIT, BITMAP_SHRINK,buf_scr_compat
);
@@ -901,7 +902,7 @@ static void snapshot_destroy(void)
free(buf_scr.fd_addr);
if( buf_scr_compat != NULL) {
- bitmap_destroy(buf_scr_compat);
+ atari_bitmap_destroy(buf_scr_compat);
}
buf_scr.fd_addr = NULL;
@@ -938,7 +939,7 @@ inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip)
uint32_t * imgrow;
int img_x, img_y, img_stride;
- img_stride= bitmap_get_rowstride(img);
+ img_stride= atari_bitmap_get_rowstride(img);
for( img_y = 0; img_y < clip->g_h; img_y++) {
imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
@@ -963,8 +964,8 @@ inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg,
int img_x, img_y, bg_x, bg_y, img_stride, bg_stride;
bg_clip = bg_clip;
- img_stride= bitmap_get_rowstride(img);
- bg_stride = bitmap_get_rowstride(bg);
+ img_stride = atari_bitmap_get_rowstride(img);
+ bg_stride = atari_bitmap_get_rowstride(bg);
for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
@@ -1018,7 +1019,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
int bw, bh;
struct bitmap * scrbuf = NULL;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = bitmap_get_opaque( img );
+ bool opaque = atari_bitmap_get_opaque( img );
if( opaque == false ){
if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
@@ -1031,8 +1032,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bw = bitmap_get_width( img );
- bh = bitmap_get_height( img );
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, when
// the bitmap is fully opaque
@@ -1080,7 +1081,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
native.fd_addr = (void*)malloc( dstsize );
if (native.fd_addr == NULL){
if (scrbuf != NULL)
- bitmap_destroy(scrbuf);
+ atari_bitmap_destroy(scrbuf);
return( 0-ERR_NO_MEM );
}
}
@@ -1119,7 +1120,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
stdform.fd_nplanes = (short)atari_plot_bpp_virt;
stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0;
- int img_stride = bitmap_get_rowstride(img);
+ int img_stride = atari_bitmap_get_rowstride(img);
uint32_t prev_pixel = 0x12345678; //TODO: check for collision in first pixel
unsigned long col = 0;
unsigned char val = 0;
@@ -1233,7 +1234,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
struct bitmap * scrbuf = NULL;
struct bitmap * source = NULL;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = bitmap_get_opaque( img );
+ bool opaque = atari_bitmap_get_opaque( img );
if( opaque == false ){
if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
@@ -1247,8 +1248,8 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bw = bitmap_get_width( img );
- bh = bitmap_get_height( img );
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, WHEN:
// A.) the bitmap is fully opaque OR
@@ -1319,7 +1320,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
assert( buf_packed );
if( buf_packed == NULL ) {
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
+ atari_bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
size_buf_packed = blocks * CONV_BLOCK_SIZE;
@@ -1330,7 +1331,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
out->fd_addr = (void*)malloc( dstsize );
if( out->fd_addr == NULL ){
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
+ atari_bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
}
@@ -1456,8 +1457,8 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor,
uint32_t flags)
{
-
- MFDB screen, tran;
+ MFDB screen;
+// MFDB tran;
MFDB * src;
short pxy[8];
short c[2] = {fgcolor, 0};
@@ -1674,6 +1675,8 @@ int plot_finalise( void )
free(buf_packed );
free(buf_planar);
snapshot_destroy();
+
+ return 0;
}
bool plot_lock(void)
@@ -2146,8 +2149,8 @@ static bool plot_bitmap(int x, int y, int width, int height,
int bmpw,bmph;
struct rect clip = {0,0,0,0};
- bmpw = bitmap_get_width(bitmap);
- bmph = bitmap_get_height(bitmap);
+ bmpw = atari_bitmap_get_width(bitmap);
+ bmph = atari_bitmap_get_height(bitmap);
if(view.scale != 1.0){
width = (int)(((float)width)*view.scale);
@@ -2167,7 +2170,7 @@ static bool plot_bitmap(int x, int y, int width, int height,
}
if( width != bmpw || height != bmph ) {
- bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height );
+ atari_bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height );
if( bitmap->resized )
bm = bitmap->resized;
else
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 1524aed..7f7d2b1 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -401,3 +401,20 @@ nsbeos_bitmap_get_pretile_xy(struct bitmap* bitmap)
}
return bitmap->pretile_xy;
}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *beos_bitmap_table = &bitmap_table;
diff --git a/beos/bitmap.h b/beos/bitmap.h
index 6ec6621..a9bb694 100644
--- a/beos/bitmap.h
+++ b/beos/bitmap.h
@@ -29,6 +29,6 @@ BBitmap *nsbeos_bitmap_get_pretile_x(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_y(struct bitmap*);
BBitmap *nsbeos_bitmap_get_pretile_xy(struct bitmap*);
-
+struct gui_bitmap_table *beos_bitmap_table;
#endif /* NS_BEOS_BITMAP_H */
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 9486382..e479cc2 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -79,6 +79,7 @@ extern "C" {
#include "beos/schedule.h"
#include "beos/fetch_rsrc.h"
#include "beos/scaffolding.h"
+#include "beos/bitmap.h"
static void *myrealloc(void *ptr, size_t len, void *pw);
@@ -995,7 +996,13 @@ int main(int argc, char** argv)
beos_window_table,
beos_download_table,
&beos_clipboard_table,
- &beos_fetch_table
+ &beos_fetch_table,
+ NULL, /* use POSIX file */
+ NULL, /* default utf8 */
+ NULL, /* default search */
+ NULL, /* default web search */
+ NULL, /* default low level cache persistant storage */
+ beos_bitmap_table
};
ret = netsurf_register(&beos_table);
@@ -1055,6 +1062,12 @@ int gui_init_replicant(int argc, char** argv)
beos_download_table,
&beos_clipboard_table,
&beos_fetch_table
+ NULL, /* use POSIX file */
+ NULL, /* default utf8 */
+ NULL, /* default search */
+ NULL, /* default web search */
+ NULL, /* default low level cache persistant storage */
+ beos_bitmap_table
};
ret = netsurf_register(&beos_table);
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index d76aee1..ac26c9c 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -24,6 +24,7 @@
#import "cocoa/SearchWindowController.h"
#import "cocoa/selection.h"
#import "cocoa/fetch.h"
+#import "cocoa/bitmap.h"
#import "utils/filename.h"
#import "utils/log.h"
@@ -220,7 +221,8 @@ int main( int argc, char **argv )
.clipboard = cocoa_clipboard_table,
.download = cocoa_download_table,
.fetch = cocoa_fetch_table,
- .search = cocoa_search_table,
+ .search = cocoa_search_table,
+ .bitmap = cocoa_bitmap_table,
};
cocoa_autorelease();
diff --git a/cocoa/bitmap.h b/cocoa/bitmap.h
index 78526e4..dc463b8 100644
--- a/cocoa/bitmap.h
+++ b/cocoa/bitmap.h
@@ -21,4 +21,6 @@
CGImageRef cocoa_get_cgimage( void *bitmap );
-#endif
\ No newline at end of file
+struct gui_bitmap_table *cocoa_bitmap_table;
+
+#endif
diff --git a/cocoa/bitmap.m b/cocoa/bitmap.m
index 45b1d3b..45ea1e0 100644
--- a/cocoa/bitmap.m
+++ b/cocoa/bitmap.m
@@ -215,3 +215,19 @@ static CGImageRef cocoa_prepare_bitmap( void *bitmap )
return result;
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *cocoa_bitmap_table = &bitmap_table;
diff --git a/content/content.c b/content/content.c
index a27647b..a6ca978 100644
--- a/content/content.c
+++ b/content/content.c
@@ -34,6 +34,7 @@
#include "content/hlcache.h"
#include "image/bitmap.h"
#include "desktop/browser.h"
+#include "desktop/gui_internal.h"
#include "utils/nsoption.h"
#include "utils/http.h"
@@ -1243,7 +1244,7 @@ bool content__get_opaque(struct content *c)
struct bitmap *bitmap = NULL;
bitmap = c->handler->get_internal(c, NULL);
if (bitmap != NULL) {
- opaque = bitmap_get_opaque(bitmap);
+ opaque = guit->bitmap->get_opaque(bitmap);
}
}
diff --git a/content/urldb.c b/content/urldb.c
index f77f597..a9476d7 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -95,19 +95,20 @@
#include <string.h>
#include <strings.h>
#include <time.h>
-
#include <curl/curl.h>
-#include "image/bitmap.h"
-#include "content/content.h"
-#include "content/urldb.h"
-#include "desktop/cookie_manager.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/utils.h"
#include "utils/bloom.h"
+#include "image/bitmap.h"
+#include "desktop/cookie_manager.h"
+#include "desktop/gui_internal.h"
+
+#include "content/content.h"
+#include "content/urldb.h"
struct cookie_internal_data {
char *name; /**< Cookie name */
@@ -2330,8 +2331,9 @@ static void urldb_destroy_path_node_content(struct path_data *node)
free(node->fragment[i]);
free(node->fragment);
- if (node->thumb)
- bitmap_destroy(node->thumb);
+ if (node->thumb) {
+ guit->bitmap->destroy(node->thumb);
+ }
free(node->urld.title);
@@ -3065,8 +3067,9 @@ void urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap)
LOG(("Setting bitmap on %s", nsurl_access(url)));
- if (p->thumb && p->thumb != bitmap)
- bitmap_destroy(p->thumb);
+ if (p->thumb && p->thumb != bitmap) {
+ guit->bitmap->destroy(p->thumb);
+ }
p->thumb = bitmap;
}
diff --git a/desktop/browser.c b/desktop/browser.c
index 195814c..74d15f6 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -2518,7 +2518,7 @@ void browser_window_reformat(struct browser_window *bw, bool background,
}
/**
- * Set bowser window scale.
+ * Set browser window scale.
*
* \param bw Browser window.
* \param scale value.
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 1991bf9..e7fd875 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -37,6 +37,7 @@
#include "css/css.h"
#include "image/bitmap.h"
+#include "desktop/gui_internal.h"
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/plotters.h"
@@ -511,9 +512,9 @@ nserror browser_window_history_add(struct browser_window *bw,
bitmap = urldb_get_thumbnail(nsurl);
if (bitmap == NULL) {
LOG(("Creating thumbnail for %s", nsurl_access(nsurl)));
- bitmap = bitmap_create(WIDTH, HEIGHT,
- BITMAP_NEW | BITMAP_CLEAR_MEMORY |
- BITMAP_OPAQUE);
+ bitmap = guit->bitmap->create(WIDTH, HEIGHT,
+ BITMAP_NEW | BITMAP_CLEAR_MEMORY |
+ BITMAP_OPAQUE);
if (bitmap != NULL) {
if (thumbnail_create(content, bitmap)) {
/* Successful thumbnail so register it
@@ -525,7 +526,7 @@ nserror browser_window_history_add(struct browser_window *bw,
* silently but clean up bitmap.
*/
LOG(("Thumbnail bitmap creation failed"));
- bitmap_destroy(bitmap);
+ guit->bitmap->destroy(bitmap);
bitmap = NULL;
}
}
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index df88b8c..cab11eb 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -16,10 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "utils/errors.h"
+#include "utils/file.h"
+#include "image/bitmap.h"
#include "content/hlcache.h"
#include "content/backing_store.h"
-#include "utils/file.h"
#include "desktop/save_pdf.h"
#include "desktop/download.h"
#include "desktop/searchweb.h"
@@ -552,6 +558,71 @@ static nserror verify_file_register(struct gui_file_table *gft)
return NSERROR_OK;
}
+/**
+ * verify bitmap table is valid
+ *
+ * \param gbt The bitmap table to verify.
+ * \return NSERROR_OK if teh table is valid else NSERROR_BAD_PARAMETER.
+ */
+static nserror verify_bitmap_register(struct gui_bitmap_table *gbt)
+{
+ /* check table is present */
+ if (gbt == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* check the mandantory fields are set */
+ if (gbt->create == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->destroy == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->set_opaque == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_opaque == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->test_opaque == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_buffer == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_rowstride == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_width == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_height == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->get_bpp == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->save == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (gbt->modified == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ return NSERROR_OK;
+}
+
static void gui_default_quit(void)
{
}
@@ -651,6 +722,12 @@ nserror netsurf_register(struct netsurf_table *gt)
return err;
}
+ /* bitmap table */
+ err = verify_bitmap_register(gt->bitmap);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
/* file table */
if (gt->file == NULL) {
gt->file = default_file_table;
diff --git a/desktop/gui_table.h b/desktop/gui_table.h
index 10f2bf1..52cdde2 100644
--- a/desktop/gui_table.h
+++ b/desktop/gui_table.h
@@ -37,6 +37,7 @@ struct gui_utf8_table;
struct gui_search_table;
struct gui_search_web_table;
struct gui_llcache_table;
+struct gui_bitmap_table;
/**
* NetSurf operation function table
@@ -119,6 +120,15 @@ struct netsurf_table {
* uses the default implementation.
*/
struct gui_llcache_table *llcache;
+
+ /**
+ * Bitmap table.
+ *
+ * Used by the image convertors as a generic interface to
+ * native platform-specific image formats. The table
+ * is mandantory and must be provided.
+ */
+ struct gui_bitmap_table *bitmap;
};
#endif
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 0321423..303ba8f 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -66,9 +66,12 @@
#include <string.h>
#include <stdio.h>
-#include "image/bitmap.h"
#include "utils/log.h"
+#include "utils/errors.h"
+#include "image/bitmap.h"
#include "content/content.h"
+
+#include "desktop/gui_internal.h"
#include "desktop/knockout.h"
#include "desktop/plotters.h"
@@ -772,8 +775,9 @@ bool knockout_plot_bitmap(int x, int y, int width, int height,
}
/* tiled bitmaps both knock out and get knocked out */
- if (bitmap_get_opaque(bitmap))
+ if (guit->bitmap->get_opaque(bitmap)) {
knockout_calculate(kx0, ky0, kx1, ky1, NULL);
+ }
knockout_boxes[knockout_box_cur].bbox.x0 = kx0;
knockout_boxes[knockout_box_cur].bbox.y0 = ky0;
knockout_boxes[knockout_box_cur].bbox.x1 = kx1;
diff --git a/desktop/treeview.c b/desktop/treeview.c
index f6134ae..35458f7 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -3698,12 +3698,12 @@ static struct bitmap * treeview_generate_triangle_bitmap(
colour colour4 = fg;
/* Create the bitmap */
- b = bitmap_create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
+ b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
if (b == NULL)
return NULL;
- rpos = bitmap_get_buffer(b);
- stride = bitmap_get_rowstride(b);
+ rpos = guit->bitmap->get_buffer(b);
+ stride = guit->bitmap->get_rowstride(b);
/* Draw the triangle */
for (y = 0; y < size; y++) {
@@ -3770,7 +3770,7 @@ static struct bitmap * treeview_generate_triangle_bitmap(
rpos += stride;
}
- bitmap_modified(b);
+ guit->bitmap->modified(b);
return b;
}
@@ -3793,29 +3793,29 @@ static struct bitmap * treeview_generate_copy_bitmap(
if (orig == NULL)
return NULL;
- assert(size == bitmap_get_width(orig));
- assert(size == bitmap_get_height(orig));
+ assert(size == guit->bitmap->get_width(orig));
+ assert(size == guit->bitmap->get_height(orig));
/* Create the bitmap */
- b = bitmap_create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
+ b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
if (b == NULL)
return NULL;
- stride = bitmap_get_rowstride(b);
- assert(stride == bitmap_get_rowstride(orig));
+ stride = guit->bitmap->get_rowstride(b);
+ assert(stride == guit->bitmap->get_rowstride(orig));
- data = bitmap_get_buffer(b);
- orig_data = bitmap_get_buffer(orig);
+ data = guit->bitmap->get_buffer(b);
+ orig_data = guit->bitmap->get_buffer(orig);
/* Copy the bitmap */
memcpy(data, orig_data, stride * size);
- bitmap_modified(b);
+ guit->bitmap->modified(b);
/* We've not modified the original image, but we called
* bitmap_get_buffer(), so we need to pair that with a
* bitmap_modified() call to appease certain front ends. */
- bitmap_modified(orig);
+ guit->bitmap->modified(orig);
return b;
}
@@ -3841,19 +3841,19 @@ static struct bitmap * treeview_generate_rotate_bitmap(
if (orig == NULL)
return NULL;
- assert(size == bitmap_get_width(orig));
- assert(size == bitmap_get_height(orig));
+ assert(size == guit->bitmap->get_width(orig));
+ assert(size == guit->bitmap->get_height(orig));
/* Create the bitmap */
- b = bitmap_create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
+ b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
if (b == NULL)
return NULL;
- stride = bitmap_get_rowstride(b);
- assert(stride == bitmap_get_rowstride(orig));
+ stride = guit->bitmap->get_rowstride(b);
+ assert(stride == guit->bitmap->get_rowstride(orig));
- rpos = bitmap_get_buffer(b);
- orig_data = bitmap_get_buffer(orig);
+ rpos = guit->bitmap->get_buffer(b);
+ orig_data = guit->bitmap->get_buffer(orig);
/* Copy the rotated bitmap */
for (y = 0; y < size; y++) {
@@ -3871,12 +3871,13 @@ static struct bitmap * treeview_generate_rotate_bitmap(
rpos += stride;
}
- bitmap_modified(b);
+ guit->bitmap->modified(b);
/* We've not modified the original image, but we called
* bitmap_get_buffer(), so we need to pair that with a
- * bitmap_modified() call to appease certain front ends. */
- bitmap_modified(orig);
+ * bitmap_modified() call to appease certain front ends.
+ */
+ guit->bitmap->modified(orig);
return b;
}
@@ -3988,14 +3989,14 @@ nserror treeview_fini(void)
hlcache_handle_release(treeview_res[i].c);
}
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_EXPAND].bmp);
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_EXPAND].sel);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_EXPAND].bmp);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_EXPAND].sel);
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].bmp);
- bitmap_destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].sel);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_CONTRACT].bmp);
- bitmap_destroy(plot_style_even.furn[TREE_FURN_CONTRACT].sel);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_EXPAND].bmp);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_EXPAND].sel);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_EXPAND].bmp);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_EXPAND].sel);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].bmp);
+ guit->bitmap->destroy(plot_style_odd.furn[TREE_FURN_CONTRACT].sel);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].bmp);
+ guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].sel);
tree_g.initialised = false;
diff --git a/framebuffer/bitmap.c b/framebuffer/bitmap.c
index fb45d6e..713cf84 100644
--- a/framebuffer/bitmap.c
+++ b/framebuffer/bitmap.c
@@ -16,16 +16,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Framebuffer implementation of generic bitmap interface.
+ */
+
#include <inttypes.h>
#include <sys/types.h>
#include <stdbool.h>
#include <assert.h>
-
#include <libnsfb.h>
#include "image/bitmap.h"
#include "utils/log.h"
+#include "framebuffer/bitmap.h"
+
/**
* Create a bitmap.
*
@@ -34,8 +40,7 @@
* \param state a flag word indicating the initial state
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+static void *bitmap_create(int width, int height, unsigned int state)
{
nsfb_t *bm;
@@ -72,8 +77,7 @@ void *bitmap_create(int width, int height, unsigned int state)
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-
-unsigned char *bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
nsfb_t *bm = bitmap;
unsigned char *bmpptr;
@@ -92,8 +96,7 @@ unsigned char *bitmap_get_buffer(void *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return width of a pixel row in the bitmap
*/
-
-size_t bitmap_get_rowstride(void *bitmap)
+static size_t bitmap_get_rowstride(void *bitmap)
{
nsfb_t *bm = bitmap;
int bmpstride;
@@ -111,8 +114,7 @@ size_t bitmap_get_rowstride(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *bitmap)
+static void bitmap_destroy(void *bitmap)
{
nsfb_t *bm = bitmap;
@@ -130,8 +132,7 @@ void bitmap_destroy(void *bitmap)
* \param flags flags controlling how the bitmap is saved.
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
@@ -142,7 +143,7 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *bitmap) {
+static void bitmap_modified(void *bitmap) {
}
/**
@@ -151,7 +152,7 @@ void bitmap_modified(void *bitmap) {
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
nsfb_t *bm = bitmap;
@@ -171,7 +172,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
int tst;
nsfb_t *bm = bitmap;
@@ -203,7 +204,7 @@ bool bitmap_test_opaque(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *bitmap)
+bool framebuffer_bitmap_get_opaque(void *bitmap)
{
nsfb_t *bm = bitmap;
enum nsfb_format_e format;
@@ -218,7 +219,7 @@ bool bitmap_get_opaque(void *bitmap)
return true;
}
-int bitmap_get_width(void *bitmap)
+static int bitmap_get_width(void *bitmap)
{
nsfb_t *bm = bitmap;
int width;
@@ -230,7 +231,7 @@ int bitmap_get_width(void *bitmap)
return(width);
}
-int bitmap_get_height(void *bitmap)
+static int bitmap_get_height(void *bitmap)
{
nsfb_t *bm = bitmap;
int height;
@@ -243,11 +244,29 @@ int bitmap_get_height(void *bitmap)
}
/* get bytes per pixel */
-size_t bitmap_get_bpp(void *bitmap)
+static size_t bitmap_get_bpp(void *bitmap)
{
return 4;
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = framebuffer_bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *framebuffer_bitmap_table = &bitmap_table;
+
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/atari/about.h b/framebuffer/bitmap.h
similarity index 73%
copy from atari/about.h
copy to framebuffer/bitmap.h
index db18250..0a72f19 100644
--- a/atari/about.h
+++ b/framebuffer/bitmap.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Ole Loots <ole(a)monochrom.net>
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.h>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,10 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NS_ATARI_ABOUT_H_INCLUDED
-#define NS_ATARI_ABOUT_H_INCLUDED
+#ifndef NS_FB_BITMAP_H
+#define NS_FB_BITMAP_H
-void atari_about_show(void);
-
-
-#endif // NS_ATARI_ABOUT_H_INCLUDED
+extern struct gui_bitmap_table *framebuffer_bitmap_table;
+
+bool framebuffer_bitmap_get_opaque(void *bitmap);
+
+#endif /* NS_FB_BITMAP_H */
diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c
index 0988c6b..927e631 100644
--- a/framebuffer/framebuffer.c
+++ b/framebuffer/framebuffer.c
@@ -37,6 +37,7 @@
#include "framebuffer/fbtk.h"
#include "framebuffer/framebuffer.h"
#include "framebuffer/font.h"
+#include "framebuffer/bitmap.h"
/* netsurf framebuffer library handle */
static nsfb_t *nsfb;
@@ -215,7 +216,7 @@ framebuffer_plot_bitmap(int x, int y,
* a flat fill of the area. Can only be done when image is fully
* opaque. */
if ((width == 1) && (height == 1)) {
- if (bitmap_get_opaque(bm)) {
+ if (framebuffer_bitmap_get_opaque(bm)) {
/** TODO: Currently using top left pixel. Maybe centre
* pixel or average value would be better. */
return nsfb_plot_rectangle_fill(nsfb, &clipbox,
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index e178d28..56fe41b 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -54,6 +54,7 @@
#include "framebuffer/font.h"
#include "framebuffer/clipboard.h"
#include "framebuffer/fetch.h"
+#include "framebuffer/bitmap.h"
#include "content/urldb.h"
#include "content/fetch.h"
@@ -106,7 +107,7 @@ static struct gui_drag {
*/
static void die(const char *error)
{
- LOG(("%s", error));
+ fprintf(stderr, "%s\n", error);
exit(1);
}
@@ -2081,6 +2082,7 @@ main(int argc, char** argv)
.clipboard = framebuffer_clipboard_table,
.fetch = framebuffer_fetch_table,
.utf8 = framebuffer_utf8_table,
+ .bitmap = framebuffer_bitmap_table,
};
ret = netsurf_register(&framebuffer_table);
diff --git a/gtk/bitmap.c b/gtk/bitmap.c
index a1cb849..978838d 100644
--- a/gtk/bitmap.c
+++ b/gtk/bitmap.c
@@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Generic bitmap handling (GDK / GTK+ implementation).
*
* This implements the interface given by desktop/bitmap.h using GdkPixbufs.
@@ -25,16 +26,15 @@
#include <assert.h>
#include <stdbool.h>
#include <string.h>
-
#include <cairo.h>
#include <gtk/gtk.h>
+#include "utils/log.h"
#include "content/content.h"
-#include "gtk/scaffolding.h"
-#include "gtk/bitmap.h"
#include "image/bitmap.h"
-#include "utils/log.h"
+#include "gtk/scaffolding.h"
+#include "gtk/bitmap.h"
/**
@@ -45,8 +45,7 @@
* \param state a flag word indicating the initial state
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+static void *bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *gbitmap;
@@ -75,7 +74,7 @@ void *bitmap_create(int width, int height, unsigned int state)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *vbitmap, bool opaque)
+static void bitmap_set_opaque(void *vbitmap, bool opaque)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
cairo_format_t fmt;
@@ -127,7 +126,7 @@ void bitmap_set_opaque(void *vbitmap, bool opaque)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *vbitmap)
+static bool bitmap_test_opaque(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
unsigned char *pixels;
@@ -156,7 +155,7 @@ bool bitmap_test_opaque(void *vbitmap)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *vbitmap)
+static bool bitmap_get_opaque(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
cairo_format_t fmt;
@@ -181,8 +180,7 @@ bool bitmap_get_opaque(void *vbitmap)
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-
-unsigned char *bitmap_get_buffer(void *vbitmap)
+static unsigned char *bitmap_get_buffer(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
int pixel_loop;
@@ -272,8 +270,7 @@ unsigned char *bitmap_get_buffer(void *vbitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return width of a pixel row in the bitmap
*/
-
-size_t bitmap_get_rowstride(void *vbitmap)
+static size_t bitmap_get_rowstride(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -288,8 +285,7 @@ size_t bitmap_get_rowstride(void *vbitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return bytes per pixel
*/
-
-size_t bitmap_get_bpp(void *vbitmap)
+static size_t bitmap_get_bpp(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -304,8 +300,7 @@ size_t bitmap_get_bpp(void *vbitmap)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *vbitmap)
+static void bitmap_destroy(void *vbitmap)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -328,8 +323,7 @@ void bitmap_destroy(void *vbitmap)
* \param flags modify the behaviour of the save
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
@@ -343,7 +337,8 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *vbitmap) {
+static void bitmap_modified(void *vbitmap)
+{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
int pixel_loop;
int pixel_count;
@@ -422,18 +417,37 @@ void bitmap_modified(void *vbitmap) {
gbitmap->converted = true;
}
-int bitmap_get_width(void *vbitmap){
+/* exported interface documented in gtk/bitmap.h */
+int nsgtk_bitmap_get_width(void *vbitmap)
+{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
return cairo_image_surface_get_width(gbitmap->surface);
}
-int bitmap_get_height(void *vbitmap){
+/* exported interface documented in gtk/bitmap.h */
+int nsgtk_bitmap_get_height(void *vbitmap)
+{
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);
return cairo_image_surface_get_height(gbitmap->surface);
}
-
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = nsgtk_bitmap_get_width,
+ .get_height = nsgtk_bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *nsgtk_bitmap_table = &bitmap_table;
diff --git a/gtk/bitmap.h b/gtk/bitmap.h
index 62d50f4..0f46d19 100644
--- a/gtk/bitmap.h
+++ b/gtk/bitmap.h
@@ -20,7 +20,8 @@
#define NS_GTK_BITMAP_H
#include <cairo.h>
-#include "image/bitmap.h"
+
+extern struct gui_bitmap_table *nsgtk_bitmap_table;
struct bitmap {
cairo_surface_t *surface; /* original cairo surface */
@@ -28,4 +29,7 @@ struct bitmap {
bool converted; /** set if the surface data has been converted */
};
+int nsgtk_bitmap_get_width(void *vbitmap);
+int nsgtk_bitmap_get_height(void *vbitmap);
+
#endif /* NS_GTK_BITMAP_H */
diff --git a/gtk/gui.c b/gtk/gui.c
index 3bcb33c..6f51133 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -66,6 +66,7 @@
#include "gtk/selection.h"
#include "gtk/search.h"
#include "gtk/ssl_cert.h"
+#include "gtk/bitmap.h"
bool nsgtk_complete = false;
@@ -1112,6 +1113,7 @@ int main(int argc, char** argv)
.llcache = filesystem_llcache_table,
.search = nsgtk_search_table,
.search_web = nsgtk_search_web_table,
+ .bitmap = nsgtk_bitmap_table,
};
ret = netsurf_register(&nsgtk_table);
diff --git a/gtk/print.c b/gtk/print.c
index e587026..53fbed0 100644
--- a/gtk/print.c
+++ b/gtk/print.c
@@ -462,8 +462,8 @@ static bool nsgtk_print_plot_bitmap(int x, int y, int width, int height,
return nsgtk_print_plot_pixbuf(x, y, width, height, bitmap, bg);
}
- width = bitmap_get_width(bitmap);
- height = bitmap_get_height(bitmap);
+ width = nsgtk_bitmap_get_width(bitmap);
+ height = nsgtk_bitmap_get_height(bitmap);
/* Bail early if we can */
if (width == 0 || height == 0)
diff --git a/image/bitmap.h b/image/bitmap.h
index 1932492..459a50a 100644
--- a/image/bitmap.h
+++ b/image/bitmap.h
@@ -53,31 +53,72 @@
#ifndef _NETSURF_IMAGE_BITMAP_H_
#define _NETSURF_IMAGE_BITMAP_H_
-#include <stdbool.h>
-#include <stdlib.h>
-
#define BITMAP_NEW 0
#define BITMAP_OPAQUE (1 << 0) /** image is opaque */
#define BITMAP_MODIFIED (1 << 1) /** buffer has been modified */
#define BITMAP_CLEAR_MEMORY (1 << 2) /** memory should be wiped */
struct content;
-
-/** An opaque image. */
struct bitmap;
-void *bitmap_create(int width, int height, unsigned int state);
-void bitmap_set_opaque(void *bitmap, bool opaque);
-bool bitmap_test_opaque(void *bitmap);
-bool bitmap_get_opaque(void *bitmap);
-unsigned char *bitmap_get_buffer(void *bitmap);
-size_t bitmap_get_rowstride(void *bitmap);
-size_t bitmap_get_bpp(void *bitmap);
-void bitmap_destroy(void *bitmap);
-bool bitmap_save(void *bitmap, const char *path, unsigned flags);
-void bitmap_modified(void *bitmap);
-
-int bitmap_get_width(void *bitmap);
-int bitmap_get_height(void *bitmap);
+/**
+ * Bitmap operations.
+ */
+struct gui_bitmap_table {
+ /* Mandantory entries */
+
+ /**
+ * Create a new bitmap
+ */
+ void *(*create)(int width, int height, unsigned int state);
+
+ /**
+ * Destroy a bitmap
+ */
+ void (*destroy)(void *bitmap);
+
+ /**
+ * Set the opacity of a bitmap
+ */
+ void (*set_opaque)(void *bitmap, bool opaque);
+
+ /**
+ * Get the opacity of a bitmap
+ */
+ bool (*get_opaque)(void *bitmap);
+
+ /**
+ */
+ bool (*test_opaque)(void *bitmap);
+
+ /**
+ */
+ unsigned char *(*get_buffer)(void *bitmap);
+
+ /**
+ */
+ size_t (*get_rowstride)(void *bitmap);
+
+ /**
+ */
+ int (*get_width)(void *bitmap);
+
+ /**
+ */
+ int (*get_height)(void *bitmap);
+
+ /**
+ */
+ size_t (*get_bpp)(void *bitmap);
+
+ /**
+ */
+ bool (*save)(void *bitmap, const char *path, unsigned flags);
+
+ /**
+ * Marks a bitmap as modified.
+ */
+ void (*modified)(void *bitmap);
+};
#endif
diff --git a/image/bmp.c b/image/bmp.c
index 946bca8..dfa573f 100644
--- a/image/bmp.c
+++ b/image/bmp.c
@@ -17,23 +17,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Content for image/bmp (implementation)
+/**
+ * \file
+ * implementation of content handler for BMP images.
*/
-#include <assert.h>
-#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <libnsbmp.h>
-#include "utils/config.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
-#include "content/hlcache.h"
+#include "desktop/gui_internal.h"
#include "desktop/plotters.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
#include "image/bitmap.h"
#include "image/bmp.h"
@@ -46,9 +42,36 @@ typedef struct nsbmp_content {
struct bitmap *bitmap; /**< Created NetSurf bitmap */
} nsbmp_content;
+/**
+ * Callback for libnsbmp; forwards the call to bitmap_create()
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
+{
+ unsigned int bitmap_state = BITMAP_NEW;
+
+ /* set bitmap state based on bmp state */
+ bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
+ bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
+ BITMAP_CLEAR_MEMORY : 0;
+
+ /* return the created bitmap */
+ return guit->bitmap->create(width, height, bitmap_state);
+}
+
static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
{
union content_msg_data msg_data;
+ bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
+ .bitmap_create = nsbmp_bitmap_create,
+ .bitmap_destroy = guit->bitmap->destroy,
+ .bitmap_get_buffer = guit->bitmap->get_buffer,
+ .bitmap_get_bpp = guit->bitmap->get_bpp
+ };
bmp->bmp = calloc(sizeof(struct bmp_image), 1);
if (bmp->bmp == NULL) {
@@ -62,7 +85,6 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
return NSERROR_OK;
}
-
static nserror nsbmp_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
@@ -93,37 +115,6 @@ static nserror nsbmp_create(const content_handler *handler,
return NSERROR_OK;
}
-/**
- * Callback for libnsbmp; forwards the call to bitmap_create()
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
-{
- unsigned int bitmap_state = BITMAP_NEW;
-
- /* set bitmap state based on bmp state */
- bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
- bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
- BITMAP_CLEAR_MEMORY : 0;
-
- /* return the created bitmap */
- return bitmap_create(width, height, bitmap_state);
-}
-
-/* The Bitmap callbacks function table;
- * necessary for interaction with nsbmplib.
- */
-bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
- .bitmap_create = nsbmp_bitmap_create,
- .bitmap_destroy = bitmap_destroy,
- .bitmap_get_buffer = bitmap_get_buffer,
- .bitmap_get_bpp = bitmap_get_bpp
-};
-
static bool nsbmp_convert(struct content *c)
{
nsbmp_content *bmp = (nsbmp_content *) c;
@@ -171,7 +162,7 @@ static bool nsbmp_convert(struct content *c)
/* exit as a success */
bmp->bitmap = bmp->bmp->bitmap;
- bitmap_modified(bmp->bitmap);
+ guit->bitmap->modified(bmp->bitmap);
content_set_ready(c);
content_set_done(c);
diff --git a/image/gif.c b/image/gif.c
index c2f0ae4..871b1cc 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -36,14 +36,9 @@
#include <stdlib.h>
#include <libnsgif.h>
-#include "utils/config.h"
-#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/utils.h"
#include "utils/nsoption.h"
#include "content/content_protected.h"
-#include "content/hlcache.h"
-#include "desktop/plotters.h"
#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
@@ -68,24 +63,21 @@ typedef struct nsgif_content {
*/
static void *nsgif_bitmap_create(int width, int height)
{
- return bitmap_create(width, height, BITMAP_NEW);
+ return guit->bitmap->create(width, height, BITMAP_NEW);
}
-/* The Bitmap callbacks function table;
- * necessary for interaction with nsgiflib.
- */
-static gif_bitmap_callback_vt gif_bitmap_callbacks = {
- .bitmap_create = nsgif_bitmap_create,
- .bitmap_destroy = bitmap_destroy,
- .bitmap_get_buffer = bitmap_get_buffer,
- .bitmap_set_opaque = bitmap_set_opaque,
- .bitmap_test_opaque = bitmap_test_opaque,
- .bitmap_modified = bitmap_modified
-};
static nserror nsgif_create_gif_data(nsgif_content *c)
{
union content_msg_data msg_data;
+ gif_bitmap_callback_vt gif_bitmap_callbacks = {
+ .bitmap_create = nsgif_bitmap_create,
+ .bitmap_destroy = guit->bitmap->destroy,
+ .bitmap_get_buffer = guit->bitmap->get_buffer,
+ .bitmap_set_opaque = guit->bitmap->set_opaque,
+ .bitmap_test_opaque = guit->bitmap->test_opaque,
+ .bitmap_modified = guit->bitmap->modified
+ };
/* Initialise our data structure */
c->gif = calloc(sizeof(gif_animation), 1);
diff --git a/image/ico.c b/image/ico.c
index e455a59..b6743cb 100644
--- a/image/ico.c
+++ b/image/ico.c
@@ -20,22 +20,18 @@
* Content for image/ico (implementation)
*/
-#include <assert.h>
-#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <libnsbmp.h>
-#include "utils/config.h"
+
+#include "utils/log.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
-#include "content/hlcache.h"
-#include "desktop/plotters.h"
+#include "desktop/gui_internal.h"
+
+#include "image/image.h"
#include "image/bitmap.h"
-#include "image/bmp.h"
#include "image/ico.h"
-#include "image/image.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
typedef struct nsico_content {
struct content base;
@@ -44,10 +40,36 @@ typedef struct nsico_content {
} nsico_content;
+/**
+ * Callback for libnsbmp; forwards the call to bitmap_create()
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+static void *nsico_bitmap_create(int width, int height, unsigned int bmp_state)
+{
+ unsigned int bitmap_state = BITMAP_NEW;
+
+ /* set bitmap state based on bmp state */
+ bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
+ bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
+ BITMAP_CLEAR_MEMORY : 0;
+
+ /* return the created bitmap */
+ return guit->bitmap->create(width, height, bitmap_state);
+}
static nserror nsico_create_ico_data(nsico_content *c)
{
union content_msg_data msg_data;
+ bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
+ .bitmap_create = nsico_bitmap_create,
+ .bitmap_destroy = guit->bitmap->destroy,
+ .bitmap_get_buffer = guit->bitmap->get_buffer,
+ .bitmap_get_bpp = guit->bitmap->get_bpp
+ };
c->ico = calloc(sizeof(ico_collection), 1);
if (c->ico == NULL) {
@@ -173,7 +195,7 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
return false;
} else {
LOG(("Decoding bitmap"));
- bitmap_modified(bmp->bitmap);
+ guit->bitmap->modified(bmp->bitmap);
}
}
@@ -243,7 +265,7 @@ static void *nsico_get_internal(const struct content *c, void *context)
if (bmp_decode(bmp) != BMP_OK) {
return NULL;
} else {
- bitmap_modified(bmp->bitmap);
+ guit->bitmap->modified(bmp->bitmap);
}
}
diff --git a/image/image.c b/image/image.c
index e0c9a43..339f775 100644
--- a/image/image.c
+++ b/image/image.c
@@ -16,19 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
-#include <stdint.h>
#include <stdbool.h>
-#include <string.h>
+#include <stdlib.h>
-#include "utils/utils.h"
-#include "utils/errors.h"
-#include "utils/config.h"
#include "utils/log.h"
-#include "desktop/plotters.h"
+#include "utils/messages.h"
#include "content/content.h"
-#include "image/bitmap.h"
+#include "desktop/plotters.h"
+#include "desktop/gui_internal.h"
+#include "image/bitmap.h"
#include "image/bmp.h"
#include "image/gif.h"
#include "image/ico.h"
@@ -38,7 +35,6 @@
#include "image/rsvg.h"
#include "image/svg.h"
#include "image/webp.h"
-
#include "image/image.h"
/**
@@ -109,7 +105,7 @@ nserror image_init(void)
bool image_bitmap_plot(struct bitmap *bitmap,
- struct content_redraw_data *data,
+ struct content_redraw_data *data,
const struct rect *clip,
const struct redraw_context *ctx)
{
@@ -121,15 +117,15 @@ bool image_bitmap_plot(struct bitmap *bitmap,
plot_style_t fill_style;
struct rect area;
- width = bitmap_get_width(bitmap);
+ width = guit->bitmap->get_width(bitmap);
if (width == 1) {
- height = bitmap_get_height(bitmap);
+ height = guit->bitmap->get_height(bitmap);
if (height == 1) {
/* optimise 1x1 bitmap plot */
- pixel = bitmap_get_buffer(bitmap);
+ pixel = guit->bitmap->get_buffer(bitmap);
fill_style.fill_colour = pixel_to_colour(pixel);
- if (bitmap_get_opaque(bitmap) ||
+ if (guit->bitmap->get_opaque(bitmap) ||
((fill_style.fill_colour & 0xff000000) == 0xff000000)) {
area = *clip;
@@ -147,8 +143,8 @@ bool image_bitmap_plot(struct bitmap *bitmap,
fill_style.stroke_type = PLOT_OP_TYPE_NONE;
fill_style.fill_type = PLOT_OP_TYPE_SOLID;
- return ctx->plot->rectangle(area.x0, area.y0,
- area.x1, area.y1,
+ return ctx->plot->rectangle(area.x0, area.y0,
+ area.x1, area.y1,
&fill_style);
} else if ((fill_style.fill_colour & 0xff000000) == 0) {
@@ -157,7 +153,7 @@ bool image_bitmap_plot(struct bitmap *bitmap,
}
}
}
-
+
/* do the plot */
if (data->repeat_x)
flags |= BITMAPF_REPEAT_X;
@@ -166,6 +162,4 @@ bool image_bitmap_plot(struct bitmap *bitmap,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
bitmap, data->background_colour, flags);
-
-
}
diff --git a/image/image_cache.c b/image/image_cache.c
index 565636c..ac36790 100644
--- a/image/image_cache.c
+++ b/image/image_cache.c
@@ -229,7 +229,7 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
image_cache->current_age - centry->bitmap_age,
centry->redraw_count));
#endif
- bitmap_destroy(centry->bitmap);
+ guit->bitmap->destroy(centry->bitmap);
centry->bitmap = NULL;
image_cache->total_bitmap_size -= centry->bitmap_size;
image_cache->bitmap_count--;
@@ -484,7 +484,7 @@ nserror image_cache_add(struct content *content,
/* set bitmap entry if one is passed, free extant one if present */
if (bitmap != NULL) {
if (centry->bitmap != NULL) {
- bitmap_destroy(centry->bitmap);
+ guit->bitmap->destroy(centry->bitmap);
} else {
image_cache_stats_bitmap_add(centry);
}
diff --git a/image/jpeg.c b/image/jpeg.c
index a5d77b5..309dec0 100644
--- a/image/jpeg.c
+++ b/image/jpeg.c
@@ -23,19 +23,17 @@
* This implementation uses the IJG JPEG library.
*/
-#include <assert.h>
-#include <setjmp.h>
-#include <string.h>
-#include <stdio.h>
+#include <stdbool.h>
#include <stdlib.h>
-
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/image_cache.h"
+#include <setjmp.h>
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/utils.h"
+#include "content/content_protected.h"
+#include "desktop/gui_internal.h"
+
+#include "image/image_cache.h"
+#include "image/bitmap.h"
#define JPEG_INTERNAL_OPTIONS
#include "jpeglib.h"
@@ -224,23 +222,23 @@ jpeg_cache_convert(struct content *c)
height = cinfo.output_height;
/* create opaque bitmap (jpegs cannot be transparent) */
- bitmap = bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE);
+ bitmap = guit->bitmap->create(width, height, BITMAP_NEW | BITMAP_OPAQUE);
if (bitmap == NULL) {
/* empty bitmap could not be created */
jpeg_destroy_decompress(&cinfo);
return NULL;
}
- pixels = bitmap_get_buffer(bitmap);
+ pixels = guit->bitmap->get_buffer(bitmap);
if (pixels == NULL) {
/* bitmap with no buffer available */
- bitmap_destroy(bitmap);
+ guit->bitmap->destroy(bitmap);
jpeg_destroy_decompress(&cinfo);
return NULL;
}
/* Convert scanlines from jpeg into bitmap */
- rowstride = bitmap_get_rowstride(bitmap);
+ rowstride = guit->bitmap->get_rowstride(bitmap);
do {
JSAMPROW scanlines[1];
@@ -265,7 +263,7 @@ jpeg_cache_convert(struct content *c)
}
#endif
} while (cinfo.output_scanline != cinfo.output_height);
- bitmap_modified(bitmap);
+ guit->bitmap->modified(bitmap);
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
diff --git a/image/png.c b/image/png.c
index acf375e..de2059f 100644
--- a/image/png.c
+++ b/image/png.c
@@ -18,25 +18,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
#include <stdbool.h>
-#include <string.h>
#include <stdlib.h>
-
#include <png.h>
-#include "desktop/plotters.h"
-
+#include "utils/log.h"
+#include "utils/messages.h"
#include "content/content_protected.h"
+#include "desktop/gui_internal.h"
-#include "image/bitmap.h"
#include "image/image_cache.h"
+#include "image/bitmap.h"
#include "image/png.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-
/* accommodate for old versions of libpng (beware security holes!) */
#ifndef png_jmpbuf
@@ -164,14 +158,14 @@ static void info_callback(png_structp png_s, png_infop info)
}
/* Claim the required memory for the converted PNG */
- png_c->bitmap = bitmap_create(width, height, BITMAP_NEW);
+ png_c->bitmap = guit->bitmap->create(width, height, BITMAP_NEW);
if (png_c->bitmap == NULL) {
/* Failed to create bitmap skip pre-conversion */
longjmp(png_jmpbuf(png_s), CBERR_NOPRE);
}
- png_c->rowstride = bitmap_get_rowstride(png_c->bitmap);
- png_c->bpp = bitmap_get_bpp(png_c->bitmap);
+ png_c->rowstride = guit->bitmap->get_rowstride(png_c->bitmap);
+ png_c->bpp = guit->bitmap->get_bpp(png_c->bitmap);
nspng_setup_transforms(png_s, info);
@@ -198,7 +192,7 @@ static void row_callback(png_structp png_s, png_bytep new_row,
return;
/* Get bitmap buffer */
- buffer = bitmap_get_buffer(png_c->bitmap);
+ buffer = guit->bitmap->get_buffer(png_c->bitmap);
if (buffer == NULL) {
/* No buffer, bail out */
longjmp(png_jmpbuf(png_s), 1);
@@ -404,9 +398,9 @@ png_cache_read_fn(png_structp png_ptr, png_bytep data, png_size_t length)
*/
static png_bytep *calc_row_pointers(struct bitmap *bitmap)
{
- int height = bitmap_get_height(bitmap);
- unsigned char *buffer= bitmap_get_buffer(bitmap);
- size_t rowstride = bitmap_get_rowstride(bitmap);
+ int height = guit->bitmap->get_height(bitmap);
+ unsigned char *buffer= guit->bitmap->get_buffer(bitmap);
+ size_t rowstride = guit->bitmap->get_rowstride(bitmap);
png_bytep *row_ptrs;
int hloop;
@@ -481,7 +475,7 @@ png_cache_convert(struct content *c)
height = png_get_image_height(png_ptr, info_ptr);
/* Claim the required memory for the converted PNG */
- bitmap = bitmap_create(width, height, BITMAP_NEW);
+ bitmap = guit->bitmap->create(width, height, BITMAP_NEW);
if (bitmap == NULL) {
/* cleanup and bail */
goto png_cache_convert_error;
@@ -500,8 +494,9 @@ png_cache_convert_error:
free((png_bytep *) row_pointers);
- if (bitmap != NULL)
- bitmap_modified((struct bitmap *)bitmap);
+ if (bitmap != NULL) {
+ guit->bitmap->modified((struct bitmap *)bitmap);
+ }
return (struct bitmap *)bitmap;
}
@@ -527,8 +522,8 @@ static bool nspng_convert(struct content *c)
}
if (png_c->bitmap != NULL) {
- bitmap_set_opaque(png_c->bitmap, bitmap_test_opaque(png_c->bitmap));
- bitmap_modified(png_c->bitmap);
+ guit->bitmap->set_opaque(png_c->bitmap, guit->bitmap->test_opaque(png_c->bitmap));
+ guit->bitmap->modified(png_c->bitmap);
}
image_cache_add(c, png_c->bitmap, png_cache_convert);
diff --git a/monkey/bitmap.c b/monkey/bitmap.c
index 79bab8c..16c98b5 100644
--- a/monkey/bitmap.c
+++ b/monkey/bitmap.c
@@ -18,9 +18,12 @@
#include <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include "image/bitmap.h"
+#include "monkey/bitmap.h"
+
struct bitmap {
void *ptr;
size_t rowstride;
@@ -29,7 +32,7 @@ struct bitmap {
unsigned int state;
};
-void *bitmap_create(int width, int height, unsigned int state)
+static void *bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)
@@ -49,14 +52,14 @@ void *bitmap_create(int width, int height, unsigned int state)
return ret;
}
-void bitmap_destroy(void *bitmap)
+static void bitmap_destroy(void *bitmap)
{
struct bitmap *bmap = bitmap;
free(bmap->ptr);
free(bmap);
}
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bmap = bitmap;
@@ -66,56 +69,73 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
bmap->state &= ~(BITMAP_OPAQUE);
}
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
return false;
}
-bool bitmap_get_opaque(void *bitmap)
+static bool bitmap_get_opaque(void *bitmap)
{
struct bitmap *bmap = bitmap;
return (bmap->state & BITMAP_OPAQUE) == BITMAP_OPAQUE;
}
-unsigned char *bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bmap = bitmap;
return (unsigned char *)(bmap->ptr);
}
-size_t bitmap_get_rowstride(void *bitmap)
+static size_t bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->width * 4;
}
-size_t bitmap_get_bpp(void *bitmap)
+static size_t bitmap_get_bpp(void *bitmap)
{
/* OMG?! */
return 4;
}
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
-void bitmap_modified(void *bitmap)
+static void bitmap_modified(void *bitmap)
{
struct bitmap *bmap = bitmap;
bmap->state |= BITMAP_MODIFIED;
}
-int bitmap_get_width(void *bitmap)
+static int bitmap_get_width(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->width;
}
-int bitmap_get_height(void *bitmap)
+static int bitmap_get_height(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->height;
}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = bitmap_create,
+ .destroy = bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *monkey_bitmap_table = &bitmap_table;
diff --git a/cocoa/bitmap.h b/monkey/bitmap.h
similarity index 76%
copy from cocoa/bitmap.h
copy to monkey/bitmap.h
index 78526e4..e293ce9 100644
--- a/cocoa/bitmap.h
+++ b/monkey/bitmap.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Sven Weidauer <sven.weidauer(a)gmail.com>
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef COCOA_BITMAP_H
-#define COCOA_BITMAP_H
+#ifndef NS_MONKEY_BITMAP_H
+#define NS_MONKEY_BITMAP_H
-CGImageRef cocoa_get_cgimage( void *bitmap );
+extern struct gui_bitmap_table *monkey_bitmap_table;
-#endif
\ No newline at end of file
+#endif /* NS_MONKEY_BITMAP_H */
diff --git a/monkey/fetch.h b/monkey/fetch.h
index 59e8696..f146e2e 100644
--- a/monkey/fetch.h
+++ b/monkey/fetch.h
@@ -16,4 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef NS_MONKEY_FETCH_H
+#define NS_MONKEY_FETCH_H
+
struct gui_fetch_table *monkey_fetch_table;
+
+#endif /* NS_MONKEY_FETCH_H */
diff --git a/monkey/main.c b/monkey/main.c
index a58bec5..81406bc 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -37,6 +37,7 @@
#include "monkey/filetype.h"
#include "monkey/fetch.h"
#include "monkey/schedule.h"
+#include "monkey/bitmap.h"
char **respaths; /** resource search path vector */
@@ -140,6 +141,7 @@ main(int argc, char **argv)
.window = monkey_window_table,
.download = monkey_download_table,
.fetch = monkey_fetch_table,
+ .bitmap = monkey_bitmap_table,
};
ret = netsurf_register(&monkey_table);
diff --git a/riscos/bitmap.c b/riscos/bitmap.c
index 2c700ec..c232f20 100644
--- a/riscos/bitmap.c
+++ b/riscos/bitmap.c
@@ -30,22 +30,24 @@
#include <string.h>
#include <swis.h>
#include <unixlib/local.h>
-#include "oslib/osfile.h"
-#include "oslib/osfind.h"
-#include "oslib/osgbpb.h"
-#include "oslib/osspriteop.h"
-#include "oslib/wimp.h"
+#include <oslib/osfile.h>
+#include <oslib/osfind.h>
+#include <oslib/osgbpb.h>
+#include <oslib/osspriteop.h>
+#include <oslib/wimp.h>
+
+#include "utils/nsoption.h"
+#include "utils/filename.h"
+#include "utils/log.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "image/bitmap.h"
-#include "riscos/bitmap.h"
+
#include "riscos/image.h"
-#include "utils/nsoption.h"
#include "riscos/palettes.h"
#include "riscos/content-handlers/sprite.h"
#include "riscos/tinct.h"
-#include "utils/filename.h"
-#include "utils/log.h"
-#include "utils/utils.h"
+#include "riscos/bitmap.h"
/** Colour in the overlay sprite that allows the bitmap to show through */
#define OVERLAY_INDEX 0xfe
@@ -109,8 +111,7 @@ static bool bitmap_initialise(struct bitmap *bitmap)
* \param state the state to create the bitmap in.
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+void *riscos_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
@@ -129,91 +130,30 @@ void *bitmap_create(int width, int height, unsigned int state)
/**
- * Overlay a sprite onto the given bitmap
+ * Return a pointer to the pixel data in a bitmap.
*
- * \param bitmap bitmap object
- * \param s 8bpp sprite to be overlayed onto bitmap
+ * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
+ * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ * \return pointer to the pixel buffer
*/
-
-void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
+unsigned char *riscos_bitmap_get_buffer(void *vbitmap)
{
- const os_colour *palette;
- const byte *sp, *mp;
- bool masked = false;
- bool alpha = false;
- os_error *error;
- int dp_offset;
- int sp_offset;
- unsigned *dp;
- int x, y;
- int w, h;
-
- assert(sprite_bpp(s) == 8);
-
- if ((unsigned)s->mode & 0x80000000U)
- alpha = true;
+ struct bitmap *bitmap = (struct bitmap *) vbitmap;
+ assert(bitmap);
- error = xosspriteop_read_sprite_info(osspriteop_PTR,
- (osspriteop_area *)0x100,
- (osspriteop_id)s,
- &w, &h, NULL, NULL);
- if (error) {
- LOG(("xosspriteop_read_sprite_info: 0x%x:%s",
- error->errnum, error->errmess));
- return;
+ /* dynamically create the buffer */
+ if (bitmap->sprite_area == NULL) {
+ if (!bitmap_initialise(bitmap))
+ return NULL;
}
- sp_offset = ((s->width + 1) * 4) - w;
-
- if (w > bitmap->width)
- w = bitmap->width;
- if (h > bitmap->height)
- h = bitmap->height;
-
- dp_offset = bitmap_get_rowstride(bitmap) / 4;
-
- dp = (void*)bitmap_get_buffer(bitmap);
- if (!dp)
- return;
- sp = (byte*)s + s->image;
- mp = (byte*)s + s->mask;
-
- sp += s->left_bit / 8;
- mp += s->left_bit / 8;
-
- if (s->image > (int)sizeof(*s))
- palette = (os_colour*)(s + 1);
- else
- palette = default_palette8;
- if (s->mask != s->image) {
- masked = true;
- bitmap_set_opaque(bitmap, false);
- }
+ /* image data area should exist */
+ if (bitmap->sprite_area)
+ return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44;
- /* (partially-)transparent pixels in the overlayed sprite retain
- * their transparency in the output bitmap; opaque sprite pixels
- * are also propagated to the bitmap, except those which are the
- * OVERLAY_INDEX colour which allow the original bitmap contents to
- * show through */
- for (y = 0; y < h; y++) {
- unsigned *sdp = dp;
- for(x = 0; x < w; x++) {
- os_colour d = ((unsigned)palette[(*sp) << 1]) >> 8;
- if (*sp++ == OVERLAY_INDEX)
- d = *dp;
- if (masked) {
- if (alpha)
- d |= ((*mp << 24) ^ 0xff000000U);
- else if (*mp)
- d |= 0xff000000U;
- }
- *dp++ = d;
- mp++;
- }
- dp = sdp + dp_offset;
- sp += sp_offset;
- mp += sp_offset;
- }
+ return NULL;
}
@@ -223,7 +163,7 @@ void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *vbitmap, bool opaque)
+static void bitmap_set_opaque(void *vbitmap, bool opaque)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
assert(bitmap);
@@ -236,12 +176,25 @@ void bitmap_set_opaque(void *vbitmap, bool opaque)
/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param vbitmap a bitmap, as returned by bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
+size_t riscos_bitmap_get_rowstride(void *vbitmap)
+{
+ struct bitmap *bitmap = (struct bitmap *) vbitmap;
+ return bitmap->width * 4;
+}
+
+
+/**
* Tests whether a bitmap has an opaque alpha channel
*
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *vbitmap)
+static bool bitmap_test_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
unsigned char *sprite;
@@ -251,11 +204,11 @@ bool bitmap_test_opaque(void *vbitmap)
assert(bitmap);
- sprite = bitmap_get_buffer(bitmap);
+ sprite = riscos_bitmap_get_buffer(bitmap);
if (!sprite)
return false;
- width = bitmap_get_rowstride(bitmap);
+ width = riscos_bitmap_get_rowstride(bitmap);
sprite_header = (osspriteop_header *) (bitmap->sprite_area + 1);
@@ -289,7 +242,7 @@ bool bitmap_test_opaque(void *vbitmap)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *vbitmap)
+bool riscos_bitmap_get_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
assert(bitmap);
@@ -298,55 +251,11 @@ bool bitmap_get_opaque(void *vbitmap)
/**
- * Return a pointer to the pixel data in a bitmap.
- *
- * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
- * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- */
-
-unsigned char *bitmap_get_buffer(void *vbitmap)
-{
- struct bitmap *bitmap = (struct bitmap *) vbitmap;
- assert(bitmap);
-
- /* dynamically create the buffer */
- if (bitmap->sprite_area == NULL) {
- if (!bitmap_initialise(bitmap))
- return NULL;
- }
-
- /* image data area should exist */
- if (bitmap->sprite_area)
- return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44;
-
- return NULL;
-}
-
-
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param vbitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
-
-size_t bitmap_get_rowstride(void *vbitmap)
-{
- struct bitmap *bitmap = (struct bitmap *) vbitmap;
- return bitmap->width * 4;
-}
-
-
-/**
* Free a bitmap.
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *vbitmap)
+void riscos_bitmap_destroy(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
@@ -369,18 +278,18 @@ void bitmap_destroy(void *vbitmap)
* \param flags modify the behaviour of the save
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
+bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
os_error *error;
- if (!bitmap->sprite_area)
- bitmap_get_buffer(bitmap);
+ if (!bitmap->sprite_area) {
+ riscos_bitmap_get_buffer(bitmap);
+ }
if (!bitmap->sprite_area)
return false;
- if (bitmap_get_opaque(bitmap)) {
+ if (riscos_bitmap_get_opaque(bitmap)) {
error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
(bitmap->sprite_area), path);
if (error) {
@@ -539,20 +448,21 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
*
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *vbitmap) {
+void riscos_bitmap_modified(void *vbitmap)
+{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
bitmap->state |= BITMAP_MODIFIED;
}
-int bitmap_get_width(void *vbitmap)
+int riscos_bitmap_get_width(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
return bitmap->width;
}
-int bitmap_get_height(void *vbitmap)
+int riscos_bitmap_get_height(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *) vbitmap;
return bitmap->height;
@@ -565,11 +475,113 @@ int bitmap_get_height(void *vbitmap)
* \param vbitmap a bitmap, as returned by bitmap_create()
* \return bytes per pixel
*/
-
-size_t bitmap_get_bpp(void *vbitmap)
+static size_t bitmap_get_bpp(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
return 4;
}
+/**
+ * Overlay a sprite onto the given bitmap
+ *
+ * \param bitmap bitmap object
+ * \param s 8bpp sprite to be overlayed onto bitmap
+ */
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
+{
+ const os_colour *palette;
+ const byte *sp, *mp;
+ bool masked = false;
+ bool alpha = false;
+ os_error *error;
+ int dp_offset;
+ int sp_offset;
+ unsigned *dp;
+ int x, y;
+ int w, h;
+
+ assert(sprite_bpp(s) == 8);
+
+ if ((unsigned)s->mode & 0x80000000U)
+ alpha = true;
+
+ error = xosspriteop_read_sprite_info(osspriteop_PTR,
+ (osspriteop_area *)0x100,
+ (osspriteop_id)s,
+ &w, &h, NULL, NULL);
+ if (error) {
+ LOG(("xosspriteop_read_sprite_info: 0x%x:%s",
+ error->errnum, error->errmess));
+ return;
+ }
+ sp_offset = ((s->width + 1) * 4) - w;
+
+ if (w > bitmap->width)
+ w = bitmap->width;
+ if (h > bitmap->height)
+ h = bitmap->height;
+
+ dp_offset = riscos_bitmap_get_rowstride(bitmap) / 4;
+
+ dp = (void*)riscos_bitmap_get_buffer(bitmap);
+ if (!dp)
+ return;
+ sp = (byte*)s + s->image;
+ mp = (byte*)s + s->mask;
+
+ sp += s->left_bit / 8;
+ mp += s->left_bit / 8;
+
+ if (s->image > (int)sizeof(*s))
+ palette = (os_colour*)(s + 1);
+ else
+ palette = default_palette8;
+
+ if (s->mask != s->image) {
+ masked = true;
+ bitmap_set_opaque(bitmap, false);
+ }
+
+ /* (partially-)transparent pixels in the overlayed sprite retain
+ * their transparency in the output bitmap; opaque sprite pixels
+ * are also propagated to the bitmap, except those which are the
+ * OVERLAY_INDEX colour which allow the original bitmap contents to
+ * show through */
+ for (y = 0; y < h; y++) {
+ unsigned *sdp = dp;
+ for(x = 0; x < w; x++) {
+ os_colour d = ((unsigned)palette[(*sp) << 1]) >> 8;
+ if (*sp++ == OVERLAY_INDEX)
+ d = *dp;
+ if (masked) {
+ if (alpha)
+ d |= ((*mp << 24) ^ 0xff000000U);
+ else if (*mp)
+ d |= 0xff000000U;
+ }
+ *dp++ = d;
+ mp++;
+ }
+ dp = sdp + dp_offset;
+ sp += sp_offset;
+ mp += sp_offset;
+ }
+}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = riscos_bitmap_create,
+ .destroy = riscos_bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = riscos_bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = riscos_bitmap_get_buffer,
+ .get_rowstride = riscos_bitmap_get_rowstride,
+ .get_width = riscos_bitmap_get_width,
+ .get_height = riscos_bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = riscos_bitmap_save,
+ .modified = riscos_bitmap_modified,
+};
+
+struct gui_bitmap_table *riscos_bitmap_table = &bitmap_table;
diff --git a/riscos/bitmap.h b/riscos/bitmap.h
index 1b7d1b9..1ae50fd 100644
--- a/riscos/bitmap.h
+++ b/riscos/bitmap.h
@@ -19,11 +19,15 @@
#ifndef _NETSURF_RISCOS_BITMAP_H_
#define _NETSURF_RISCOS_BITMAP_H_
+/** bitmap operations table */
+struct gui_bitmap_table *riscos_bitmap_table;
+
#include <stdbool.h>
#include "oslib/osspriteop.h"
#include "image/bitmap.h"
-#define BITMAP_SAVE_FULL_ALPHA (1 << 0) /** save with full alpha channel (if not opaque) */
+/** save with full alpha channel (if not opaque) */
+#define BITMAP_SAVE_FULL_ALPHA (1 << 0)
struct osspriteop_area;
@@ -36,6 +40,15 @@ struct bitmap {
osspriteop_area *sprite_area; /** Uncompressed data, or NULL */
};
-void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s);
+void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s);
+void riscos_bitmap_destroy(void *vbitmap);
+void *riscos_bitmap_create(int width, int height, unsigned int state);
+unsigned char *riscos_bitmap_get_buffer(void *vbitmap);
+void riscos_bitmap_modified(void *vbitmap);
+int riscos_bitmap_get_width(void *vbitmap);
+int riscos_bitmap_get_height(void *vbitmap);
+size_t riscos_bitmap_get_rowstride(void *vbitmap);
+bool riscos_bitmap_get_opaque(void *vbitmap);
+bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags);
#endif
diff --git a/riscos/gui.c b/riscos/gui.c
index 3fd113c..6a861c2 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -58,6 +58,7 @@
#include "content/backing_store.h"
#include "riscos/gui.h"
+#include "riscos/bitmap.h"
#include "riscos/wimputils.h"
#include "riscos/hotlist.h"
#include "riscos/buffer.h"
@@ -2446,6 +2447,7 @@ int main(int argc, char** argv)
.utf8 = riscos_utf8_table,
.search = riscos_search_table,
.llcache = filesystem_llcache_table,
+ .bitmap = riscos_bitmap_table,
};
ret = netsurf_register(&riscos_table);
diff --git a/riscos/plotters.c b/riscos/plotters.c
index d35d1f0..e23242e 100644
--- a/riscos/plotters.c
+++ b/riscos/plotters.c
@@ -519,7 +519,7 @@ bool ro_plot_bitmap(int x, int y, int width, int height,
{
const uint8_t *buffer;
- buffer = bitmap_get_buffer(bitmap);
+ buffer = riscos_bitmap_get_buffer(bitmap);
if (!buffer) {
LOG(("bitmap_get_buffer failed"));
return false;
@@ -534,6 +534,6 @@ bool ro_plot_bitmap(int x, int y, int width, int height,
bg,
flags & BITMAPF_REPEAT_X, flags & BITMAPF_REPEAT_Y,
flags & BITMAPF_REPEAT_X || flags & BITMAPF_REPEAT_Y,
- bitmap_get_opaque(bitmap) ? IMAGE_PLOT_TINCT_OPAQUE :
+ riscos_bitmap_get_opaque(bitmap) ? IMAGE_PLOT_TINCT_OPAQUE :
IMAGE_PLOT_TINCT_ALPHA);
}
diff --git a/riscos/save.c b/riscos/save.c
index 7b60239..6b27db4 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -1144,7 +1144,7 @@ bool ro_gui_save_object_native(hlcache_handle *h, char *path)
{
unsigned flags = (os_version == 0xA9) ?
BITMAP_SAVE_FULL_ALPHA : 0;
- bitmap_save(content_get_bitmap(h), path, flags);
+ riscos_bitmap_save(content_get_bitmap(h), path, flags);
}
break;
case osfile_TYPE_DRAW:
@@ -1370,14 +1370,14 @@ bool ro_gui_save_create_thumbnail(hlcache_handle *h, const char *name)
struct bitmap *bitmap;
osspriteop_area *area;
- bitmap = bitmap_create(34, 34, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
+ bitmap = riscos_bitmap_create(34, 34, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
if (!bitmap) {
LOG(("Thumbnail initialisation failed."));
return false;
}
thumbnail_create(h, bitmap);
area = thumbnail_convert_8bpp(bitmap);
- bitmap_destroy(bitmap);
+ riscos_bitmap_destroy(bitmap);
if (!area) {
LOG(("Thumbnail conversion failed."));
return false;
diff --git a/riscos/save_draw.c b/riscos/save_draw.c
index fe14071..bf81bca 100644
--- a/riscos/save_draw.c
+++ b/riscos/save_draw.c
@@ -400,7 +400,7 @@ bool ro_save_draw_bitmap(int x, int y, int width, int height,
pencil_code code;
const uint8_t *buffer;
- buffer = bitmap_get_buffer(bitmap);
+ buffer = riscos_bitmap_get_buffer(bitmap);
if (!buffer) {
warn_user("NoMemory", 0);
return false;
diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c
index 6613b0e..ee21747 100644
--- a/riscos/thumbnail.c
+++ b/riscos/thumbnail.c
@@ -108,7 +108,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap)
return false;
sprite_header = (osspriteop_header *)(sprite_area + 1);
} else {
- const uint8_t *pixbufp = bitmap_get_buffer(bitmap);
+ const uint8_t *pixbufp = riscos_bitmap_get_buffer(bitmap);
if (!pixbufp || !bitmap->sprite_area)
return false;
sprite_area = bitmap->sprite_area;
@@ -137,7 +137,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap)
/* if we changed to 8bpp then go back to 32bpp */
if (thumbnail_32bpp_available != 1) {
- const uint8_t *pixbufp = bitmap_get_buffer(bitmap);
+ const uint8_t *pixbufp = riscos_bitmap_get_buffer(bitmap);
_kernel_oserror *error;
if (!pixbufp || !bitmap->sprite_area) {
@@ -152,7 +152,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap)
return false;
}
- bitmap_modified(bitmap);
+ riscos_bitmap_modified(bitmap);
return true;
}
@@ -190,13 +190,13 @@ osspriteop_area *thumbnail_convert_8bpp(struct bitmap *bitmap)
if (sprite_header->image != sprite_header->mask) {
/* build the sprite mask from the alpha channel */
- void *buf = bitmap_get_buffer(bitmap);
+ void *buf = riscos_bitmap_get_buffer(bitmap);
unsigned *dp = (unsigned *) buf;
if (!dp)
return sprite_area;
- int w = bitmap_get_width(bitmap);
- int h = bitmap_get_height(bitmap);
- int dp_offset = bitmap_get_rowstride(bitmap) / 4 - w;
+ int w = riscos_bitmap_get_width(bitmap);
+ int h = riscos_bitmap_get_height(bitmap);
+ int dp_offset = riscos_bitmap_get_rowstride(bitmap) / 4 - w;
int mp_offset = ((sprite_header->width + 1) * 4) - w;
byte *mp = (byte*)sprite_header + sprite_header->mask;
bool alpha = ((unsigned)sprite_header->mode & 0x80000000U) != 0;
@@ -228,7 +228,7 @@ osspriteop_area *thumbnail_convert_8bpp(struct bitmap *bitmap)
osspriteop_area *thumbnail_create_8bpp(struct bitmap *bitmap)
{
unsigned image_size = ((bitmap->width + 3) & ~3) * bitmap->height;
- bool opaque = bitmap_get_opaque(bitmap);
+ bool opaque = riscos_bitmap_get_opaque(bitmap);
osspriteop_header *sprite_header = NULL;
osspriteop_area *sprite_area = NULL;
unsigned area_size;
diff --git a/riscos/window.c b/riscos/window.c
index fae7566..4f281b9 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -3411,7 +3411,7 @@ void ro_gui_window_iconise(struct gui_window *g,
}
/* create the thumbnail sprite */
- bitmap = bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE |
+ bitmap = riscos_bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE |
BITMAP_CLEAR_MEMORY);
if (!bitmap) {
LOG(("Thumbnail initialisation failed."));
@@ -3419,10 +3419,10 @@ void ro_gui_window_iconise(struct gui_window *g,
}
thumbnail_create(h, bitmap);
if (overlay) {
- bitmap_overlay_sprite(bitmap, overlay);
+ riscos_bitmap_overlay_sprite(bitmap, overlay);
}
area = thumbnail_convert_8bpp(bitmap);
- bitmap_destroy(bitmap);
+ riscos_bitmap_destroy(bitmap);
if (!area) {
LOG(("Thumbnail conversion failed."));
return;
diff --git a/windows/bitmap.c b/windows/bitmap.c
index c047e17..f010860 100644
--- a/windows/bitmap.c
+++ b/windows/bitmap.c
@@ -17,18 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "utils/config.h"
+
#include <inttypes.h>
#include <sys/types.h>
#include <string.h>
-
-#include "utils/config.h"
-
#include <windows.h>
+#include "utils/log.h"
#include "image/bitmap.h"
-#include "windows/bitmap.h"
-#include "utils/log.h"
+#include "windows/bitmap.h"
/**
* Create a bitmap.
@@ -38,8 +37,7 @@
* \param state a flag word indicating the initial state
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-
-void *bitmap_create(int width, int height, unsigned int state)
+void *win32_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
BITMAPV5HEADER *pbmi;
@@ -99,14 +97,13 @@ void *bitmap_create(int width, int height, unsigned int state)
/**
* Return a pointer to the pixel data in a bitmap.
*
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return pointer to the pixel buffer
- *
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return pointer to the pixel buffer
*/
-
-unsigned char *bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
if (bitmap == NULL) {
@@ -124,8 +121,7 @@ unsigned char *bitmap_get_buffer(void *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return width of a pixel row in the bitmap
*/
-
-size_t bitmap_get_rowstride(void *bitmap)
+static size_t bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -143,8 +139,7 @@ size_t bitmap_get_rowstride(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-
-void bitmap_destroy(void *bitmap)
+void win32_bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -167,8 +162,7 @@ void bitmap_destroy(void *bitmap)
* \param flags flags controlling how the bitmap is saved.
* \return true on success, false on error and error reported
*/
-
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
@@ -179,7 +173,7 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-void bitmap_modified(void *bitmap) {
+static void bitmap_modified(void *bitmap) {
}
/**
@@ -188,7 +182,7 @@ void bitmap_modified(void *bitmap) {
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
@@ -208,7 +202,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
int tst;
struct bitmap *bm = bitmap;
@@ -236,7 +230,7 @@ bool bitmap_test_opaque(void *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-bool bitmap_get_opaque(void *bitmap)
+static bool bitmap_get_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -248,7 +242,7 @@ bool bitmap_get_opaque(void *bitmap)
return bm->opaque;
}
-int bitmap_get_width(void *bitmap)
+static int bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -260,7 +254,7 @@ int bitmap_get_width(void *bitmap)
return(bm->width);
}
-int bitmap_get_height(void *bitmap)
+static int bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -272,7 +266,7 @@ int bitmap_get_height(void *bitmap)
return(bm->height);
}
-size_t bitmap_get_bpp(void *bitmap)
+static size_t bitmap_get_bpp(void *bitmap)
{
return 4;
}
@@ -350,3 +344,20 @@ struct bitmap *bitmap_pretile(struct bitmap *untiled, int width, int height,
ret->height = height;
return ret;
}
+
+static struct gui_bitmap_table bitmap_table = {
+ .create = win32_bitmap_create,
+ .destroy = win32_bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = bitmap_get_rowstride,
+ .get_width = bitmap_get_width,
+ .get_height = bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *win32_bitmap_table = &bitmap_table;
diff --git a/windows/bitmap.h b/windows/bitmap.h
index d05fef2..434c5e9 100644
--- a/windows/bitmap.h
+++ b/windows/bitmap.h
@@ -22,6 +22,8 @@
#include "desktop/plotters.h"
+struct gui_bitmap_table *win32_bitmap_table;
+
struct bitmap {
HBITMAP windib;
BITMAPV5HEADER *pbmi;
@@ -35,4 +37,7 @@ struct bitmap *bitmap_scale(struct bitmap *prescale, int width, int height);
struct bitmap *bitmap_pretile(struct bitmap *untiled, int width, int height,
bitmap_flags_t flags);
+void *win32_bitmap_create(int width, int height, unsigned int state);
+void win32_bitmap_destroy(void *bitmap);
+
#endif
diff --git a/windows/main.c b/windows/main.c
index c5bb240..4114297 100644
--- a/windows/main.c
+++ b/windows/main.c
@@ -43,6 +43,7 @@
#include "windows/font.h"
#include "windows/filetype.h"
#include "windows/pointers.h"
+#include "windows/bitmap.h"
#include "windows/gui.h"
static char **respaths; /** resource search path vector. */
@@ -130,6 +131,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
.fetch = win32_fetch_table,
.file = win32_file_table,
.utf8 = win32_utf8_table,
+ .bitmap = win32_bitmap_table,
};
win32_fetch_table->get_resource_url = gui_get_resource_url;
diff --git a/windows/thumbnail.c b/windows/thumbnail.c
index 1fee8cc..2cf6783 100644
--- a/windows/thumbnail.c
+++ b/windows/thumbnail.c
@@ -65,7 +65,7 @@ thumbnail_create(hlcache_handle *content,
}
/* create a full size bitmap and plot into it */
- fsbitmap = bitmap_create(width, height, BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE);
+ fsbitmap = win32_bitmap_create(width, height, BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE);
SelectObject(bufferdc, fsbitmap->windib);
@@ -83,7 +83,7 @@ thumbnail_create(hlcache_handle *content,
DeleteDC(bufferdc);
DeleteDC(minidc);
- bitmap_destroy(fsbitmap);
+ win32_bitmap_destroy(fsbitmap);
return true;
}
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-72-g7a28131
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7a28131e4953934150967...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7a28131e4953934150967eb...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7a28131e4953934150967eb78...
The branch, master has been updated
via 7a28131e4953934150967eb7886bc06678e249e8 (commit)
from 41331542154594970fb6c36bc1c147c244fe9279 (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=7a28131e49539341509...
commit 7a28131e4953934150967eb7886bc06678e249e8
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Fix win32 frontend bitmap creation with flags
The windows win32 frontend bitmap creation was ignoring the creation
flags, specifically those related to bitmap opacity so was plotting
images as transparent even if they had no alpha channel values set.
diff --git a/windows/bitmap.c b/windows/bitmap.c
index a12fc2d..c047e17 100644
--- a/windows/bitmap.c
+++ b/windows/bitmap.c
@@ -84,7 +84,11 @@ void *bitmap_create(int width, int height, unsigned int state)
bitmap->windib = windib;
bitmap->pbmi = pbmi;
bitmap->pixdata = pixdata;
- bitmap->opaque = false;
+ if ((state & BITMAP_OPAQUE) != 0) {
+ bitmap->opaque = true;
+ } else {
+ bitmap->opaque = false;
+ }
LOG(("bitmap %p", bitmap));
-----------------------------------------------------------------------
Summary of changes:
windows/bitmap.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/windows/bitmap.c b/windows/bitmap.c
index a12fc2d..c047e17 100644
--- a/windows/bitmap.c
+++ b/windows/bitmap.c
@@ -84,7 +84,11 @@ void *bitmap_create(int width, int height, unsigned int state)
bitmap->windib = windib;
bitmap->pbmi = pbmi;
bitmap->pixdata = pixdata;
- bitmap->opaque = false;
+ if ((state & BITMAP_OPAQUE) != 0) {
+ bitmap->opaque = true;
+ } else {
+ bitmap->opaque = false;
+ }
LOG(("bitmap %p", bitmap));
--
NetSurf Browser
8 years, 1 month
netsurf: branch master updated. release/3.3-71-g4133154
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/41331542154594970fb6c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/41331542154594970fb6c36...
...tree http://git.netsurf-browser.org/netsurf.git/tree/41331542154594970fb6c36bc...
The branch, master has been updated
via 41331542154594970fb6c36bc1c147c244fe9279 (commit)
from de09dc8efdfdb4ce27c85733cfec139a52d70776 (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=41331542154594970fb...
commit 41331542154594970fb6c36bc1c147c244fe9279
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix documentation errors in gtk introduced by recent updates.
diff --git a/gtk/compat.h b/gtk/compat.h
index e90cdc6..088cd79 100644
--- a/gtk/compat.h
+++ b/gtk/compat.h
@@ -172,7 +172,9 @@ enum {
*
* Compatability interface for original deprecated in GTK 3.10
*
- * \param stock_id the name of the stock item
+ * \param entry The entry widget to set the icon on.
+ * \param icon_pos The position of the icon.
+ * \param stock_id the name of the stock item.
*/
void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id);
@@ -181,7 +183,9 @@ void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon
*
* Compatability interface for original deprecated in GTK 3.10
*
- * \param stock_id the name of the stock item
+ * \param stock_id the name of the stock item.
+ * \param size The size of icon to create.
+ * \return The created image widget or NULL on error
*/
GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size);
@@ -195,12 +199,12 @@ GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size);
GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id);
/**
-
* Fills item with the registered values for stock_id.
*
* Compatability interface for original deprecated in GTK 3.10
*
- * \param stock_id the name of the stock item
+ * \param stock_id the name of the stock item.
+ * \param item The structure to update if the stock_id was known.
* \return TRUE if stock_id was known.
*/
gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item);
diff --git a/gtk/window.c b/gtk/window.c
index 685ff91..7fa089a 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -17,6 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Implementation of gtk windowing.
+ */
+
#include <inttypes.h>
#include <string.h>
#include <limits.h>
@@ -60,7 +65,8 @@ static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
gpointer user_data);
struct gui_window {
- /** The gtk scaffold object containing menu, buttons, url bar, [tabs],
+ /**
+ * The gtk scaffold object containing menu, buttons, url bar, [tabs],
* drawing area, etc that may contain one or more gui_windows.
*/
struct nsgtk_scaffolding *scaffold;
@@ -118,7 +124,10 @@ struct gui_window {
struct gui_window *next, *prev;
};
-struct gui_window *window_list = NULL; /**< first entry in win list*/
+/**< first entry in window list */
+struct gui_window *window_list = NULL;
+
+/** flag controlling opening of tabs in teh background */
int temp_open_background = -1;
struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
-----------------------------------------------------------------------
Summary of changes:
gtk/compat.h | 12 ++++++++----
gtk/window.c | 13 +++++++++++--
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/gtk/compat.h b/gtk/compat.h
index e90cdc6..088cd79 100644
--- a/gtk/compat.h
+++ b/gtk/compat.h
@@ -172,7 +172,9 @@ enum {
*
* Compatability interface for original deprecated in GTK 3.10
*
- * \param stock_id the name of the stock item
+ * \param entry The entry widget to set the icon on.
+ * \param icon_pos The position of the icon.
+ * \param stock_id the name of the stock item.
*/
void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id);
@@ -181,7 +183,9 @@ void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon
*
* Compatability interface for original deprecated in GTK 3.10
*
- * \param stock_id the name of the stock item
+ * \param stock_id the name of the stock item.
+ * \param size The size of icon to create.
+ * \return The created image widget or NULL on error
*/
GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size);
@@ -195,12 +199,12 @@ GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size);
GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id);
/**
-
* Fills item with the registered values for stock_id.
*
* Compatability interface for original deprecated in GTK 3.10
*
- * \param stock_id the name of the stock item
+ * \param stock_id the name of the stock item.
+ * \param item The structure to update if the stock_id was known.
* \return TRUE if stock_id was known.
*/
gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item);
diff --git a/gtk/window.c b/gtk/window.c
index 685ff91..7fa089a 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -17,6 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Implementation of gtk windowing.
+ */
+
#include <inttypes.h>
#include <string.h>
#include <limits.h>
@@ -60,7 +65,8 @@ static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
gpointer user_data);
struct gui_window {
- /** The gtk scaffold object containing menu, buttons, url bar, [tabs],
+ /**
+ * The gtk scaffold object containing menu, buttons, url bar, [tabs],
* drawing area, etc that may contain one or more gui_windows.
*/
struct nsgtk_scaffolding *scaffold;
@@ -118,7 +124,10 @@ struct gui_window {
struct gui_window *next, *prev;
};
-struct gui_window *window_list = NULL; /**< first entry in win list*/
+/**< first entry in window list */
+struct gui_window *window_list = NULL;
+
+/** flag controlling opening of tabs in teh background */
int temp_open_background = -1;
struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
--
NetSurf Browser
8 years, 1 month