NetSurf
|
RISC OS implementation of bitmap operations. More...
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include <swis.h>
#include <rufl.h>
#include <unixlib/local.h>
#include <oslib/colourtrans.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/messages.h"
#include "netsurf/plotters.h"
#include "netsurf/content.h"
#include "riscos/gui.h"
#include "riscos/image.h"
#include "riscos/palettes.h"
#include "riscos/content-handlers/sprite.h"
#include "riscos/tinct.h"
#include "riscos/bitmap.h"
Go to the source code of this file.
Data Structures | |
struct | thumbnail_save_area |
Sprite output context saving. More... | |
Macros | |
#define | OVERLAY_INDEX 0xfe |
Colour in the overlay sprite that allows the bitmap to show through. More... | |
#define | SAVE_CHUNK_SIZE 4096 |
Size of buffer used when constructing mask data to be saved. More... | |
Functions | |
static bool | bitmap_initialise (struct bitmap *bitmap) |
Initialise a bitmaps sprite area. More... | |
void * | riscos_bitmap_create (int width, int height, enum gui_bitmap_flags flags) |
Create a bitmap. More... | |
unsigned char * | riscos_bitmap_get_buffer (void *vbitmap) |
Return a pointer to the pixel data in a bitmap. More... | |
static void | bitmap_set_opaque (void *vbitmap, bool opaque) |
Sets whether a bitmap should be plotted opaque. More... | |
static size_t | bitmap_get_rowstride (void *vbitmap) |
Find the width of a pixel row in bytes. More... | |
bool | riscos_bitmap_get_opaque (void *vbitmap) |
Gets whether a bitmap should be plotted opaque. More... | |
void | riscos_bitmap_destroy (void *vbitmap) |
Free a bitmap. More... | |
bool | riscos_bitmap_save (void *vbitmap, const char *path, unsigned flags) |
Save a bitmap in the platform's native format. More... | |
static void | bitmap_modified (void *vbitmap) |
The bitmap image has changed, so flush any persistent cache. More... | |
static int | bitmap_get_width (void *vbitmap) |
Get the width of a bitmap. More... | |
static int | bitmap_get_height (void *vbitmap) |
Get the height of a bitmap. More... | |
void | riscos_bitmap_overlay_sprite (struct bitmap *bitmap, const osspriteop_header *s) |
static osspriteop_area * | thumbnail_create_8bpp (struct bitmap *bitmap) |
Creates an 8bpp canvas. More... | |
static struct thumbnail_save_area * | thumbnail_switch_output (osspriteop_area *sprite_area, osspriteop_header *sprite_header) |
Switches output to the specified sprite and returns the previous context. More... | |
static void | thumbnail_restore_output (struct thumbnail_save_area *save_area) |
Restores output to the specified context, and destroys it. More... | |
osspriteop_area * | riscos_bitmap_convert_8bpp (struct bitmap *bitmap) |
Convert a bitmap to 8bpp. More... | |
static void | thumbnail_test (void) |
Check to see whether 32bpp sprites are available. More... | |
nserror | riscos_bitmap_render (struct bitmap *bitmap, struct hlcache_handle *content) |
Render content into bitmap. More... | |
Variables | |
static int | thumbnail_32bpp_available = -1 |
Whether we can use 32bpp sprites. More... | |
static struct gui_bitmap_table | bitmap_table |
struct gui_bitmap_table * | riscos_bitmap_table = &bitmap_table |
bitmap operations table More... | |
RISC OS implementation of bitmap operations.
This implements the interface given by image/bitmap.h using RISC OS sprites.
Definition in file bitmap.c.
#define OVERLAY_INDEX 0xfe |
#define SAVE_CHUNK_SIZE 4096 |
|
static |
Get the height of a bitmap.
vbitmap | A bitmap, as returned by bitmap_create() |
Definition at line 423 of file bitmap.c.
References bitmap::height.
|
static |
Find the width of a pixel row in bytes.
vbitmap | A bitmap, as returned by riscos_bitmap_create() |
Definition at line 185 of file bitmap.c.
References bitmap::width.
Referenced by riscos_bitmap_convert_8bpp(), and riscos_bitmap_overlay_sprite().
|
static |
Get the width of a bitmap.
vbitmap | A bitmap, as returned by bitmap_create() |
Definition at line 410 of file bitmap.c.
References bitmap::width.
|
static |
Initialise a bitmaps sprite area.
bitmap | the bitmap to initialise |
Definition at line 84 of file bitmap.c.
References bitmap::clear, bitmap::height, bitmap::sprite_area, tinct_SPRITE_MODE, and bitmap::width.
Referenced by riscos_bitmap_get_buffer().
|
static |
The bitmap image has changed, so flush any persistent cache.
vbitmap | a bitmap, as returned by bitmap_create() |
Definition at line 398 of file bitmap.c.
Referenced by riscos_bitmap_render().
|
static |
Sets whether a bitmap should be plotted opaque.
vbitmap | a bitmap, as returned by bitmap_create() |
opaque | whether the bitmap should be plotted opaque |
Definition at line 170 of file bitmap.c.
References bitmap::opaque.
Referenced by riscos_bitmap_overlay_sprite().
osspriteop_area * riscos_bitmap_convert_8bpp | ( | struct bitmap * | bitmap | ) |
Convert a bitmap to 8bpp.
Convert bitmap to 8bpp sprite.
bitmap | the bitmap to convert |
Definition at line 633 of file bitmap.c.
References bitmap_get_height(), bitmap_get_rowstride(), bitmap_get_width(), riscos_bitmap_get_buffer(), save_area, bitmap::sprite_area, thumbnail_32bpp_available, thumbnail_create_8bpp(), thumbnail_restore_output(), thumbnail_switch_output(), tinct_ERROR_DIFFUSE, and Tinct_Plot.
Referenced by ro_gui_save_create_thumbnail(), and ro_gui_window_iconise().
void * riscos_bitmap_create | ( | int | width, |
int | height, | ||
enum gui_bitmap_flags | flags | ||
) |
Create a bitmap.
width | width of image in pixels |
height | height of image in pixels |
flags | flags for bitmap creation. |
Definition at line 125 of file bitmap.c.
References bitmap(), BITMAP_CLEAR, BITMAP_OPAQUE, bitmap::clear, bitmap::height, height, bitmap::opaque, bitmap::width, and width.
Referenced by ro_gui_save_create_thumbnail(), and ro_gui_window_iconise().
void riscos_bitmap_destroy | ( | void * | vbitmap | ) |
Free a bitmap.
vbitmap | a bitmap, as returned by bitmap_create() |
Definition at line 202 of file bitmap.c.
References bitmap::sprite_area.
Referenced by ro_gui_save_create_thumbnail(), and ro_gui_window_iconise().
unsigned char * riscos_bitmap_get_buffer | ( | 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().
vbitmap | A bitmap as returned by riscos_bitmap_create() |
Definition at line 145 of file bitmap.c.
References bitmap_initialise(), and bitmap::sprite_area.
Referenced by riscos_bitmap_convert_8bpp(), riscos_bitmap_overlay_sprite(), riscos_bitmap_render(), riscos_bitmap_save(), and ro_plot_bitmap().
bool riscos_bitmap_get_opaque | ( | void * | vbitmap | ) |
Gets whether a bitmap should be plotted opaque.
vbitmap | A bitmap, as returned by riscos_bitmap_create() |
Definition at line 193 of file bitmap.c.
References bitmap::opaque.
Referenced by riscos_bitmap_save(), ro_plot_bitmap(), and thumbnail_create_8bpp().
void riscos_bitmap_overlay_sprite | ( | struct bitmap * | bitmap, |
const osspriteop_header * | s | ||
) |
Definition at line 431 of file bitmap.c.
References bitmap_get_rowstride(), bitmap_set_opaque(), default_palette8, bitmap::height, NSLOG, OVERLAY_INDEX, riscos_bitmap_get_buffer(), sprite_bpp(), and bitmap::width.
Referenced by ro_gui_window_iconise().
nserror riscos_bitmap_render | ( | struct bitmap * | bitmap, |
struct hlcache_handle * | content | ||
) |
Render content into bitmap.
bitmap | the bitmap to draw to |
content | content structure to render |
Definition at line 724 of file bitmap.c.
References bitmap_modified(), colourtrans_SET_BG_GCOL, content_scaled_redraw(), bitmap::height, redraw_context::interactive, NSERROR_OK, NSLOG, riscos_bitmap_get_buffer(), ro_plot_origin_x, ro_plot_origin_y, ro_plotters, save_area, bitmap::sprite_area, thumbnail_32bpp_available, thumbnail_create_8bpp(), thumbnail_restore_output(), thumbnail_switch_output(), thumbnail_test(), Tinct_ConvertSprite, and bitmap::width.
Referenced by ro_gui_save_create_thumbnail(), and ro_gui_window_iconise().
bool riscos_bitmap_save | ( | void * | vbitmap, |
const char * | path, | ||
unsigned | flags | ||
) |
Save a bitmap in the platform's native format.
vbitmap | a bitmap, as returned by bitmap_create() |
path | pathname for file |
flags | modify the behaviour of the save |
Definition at line 218 of file bitmap.c.
References BITMAP_SAVE_FULL_ALPHA, height, messages_get(), NSLOG, path(), riscos_bitmap_get_buffer(), riscos_bitmap_get_opaque(), ro_warn_user(), SAVE_CHUNK_SIZE, bitmap::sprite_area, and width.
Referenced by ro_gui_save_object_native().
|
static |
Creates an 8bpp canvas.
bitmap | the bitmap to clone the size of |
Definition at line 520 of file bitmap.c.
References bitmap::height, NSLOG, bitmap::opaque, riscos_bitmap_get_opaque(), bitmap::sprite_area, and bitmap::width.
Referenced by riscos_bitmap_convert_8bpp(), and riscos_bitmap_render().
|
static |
Restores output to the specified context, and destroys it.
Definition at line 614 of file bitmap.c.
References save_area.
Referenced by riscos_bitmap_convert_8bpp(), and riscos_bitmap_render().
|
static |
Switches output to the specified sprite and returns the previous context.
Definition at line 573 of file bitmap.c.
References save_area.
Referenced by riscos_bitmap_convert_8bpp(), and riscos_bitmap_render().
|
static |
Check to see whether 32bpp sprites are available.
Rather than using Wimp_ReadSysInfo we test if 32bpp sprites are available in case the user has a 3rd party patch to enable them.
Definition at line 697 of file bitmap.c.
References NSLOG, thumbnail_32bpp_available, and tinct_SPRITE_MODE.
Referenced by riscos_bitmap_render().
|
static |
struct gui_bitmap_table* riscos_bitmap_table = &bitmap_table |
|
static |
Whether we can use 32bpp sprites.
Definition at line 65 of file bitmap.c.
Referenced by riscos_bitmap_convert_8bpp(), riscos_bitmap_render(), and thumbnail_test().