NetSurf
Data Structures | Macros | Functions | Variables
bitmap.cpp File Reference

BeOS implementation of generic bitmaps. More...

#include <assert.h>
#include <sys/param.h>
#include <string.h>
#include <Bitmap.h>
#include <BitmapStream.h>
#include <File.h>
#include <GraphicsDefs.h>
#include <TranslatorFormats.h>
#include <TranslatorRoster.h>
#include <View.h>
#include <stdlib.h>
#include "utils/log.h"
#include "netsurf/plotters.h"
#include "netsurf/content_type.h"
#include "netsurf/browser_window.h"
#include "netsurf/bitmap.h"
#include "netsurf/content.h"
#include "beos/bitmap.h"
#include "beos/gui.h"
#include "beos/scaffolding.h"
#include "beos/plotters.h"
Include dependency graph for bitmap.cpp:

Go to the source code of this file.

Data Structures

struct  bitmap
 RISC OS wimp toolkit bitmap. More...
 

Macros

#define __STDBOOL_H__   1
 
#define MIN_PRETILE_WIDTH   256
 
#define MIN_PRETILE_HEIGHT   256
 
#define FREE_TILE(XY)   if (bitmap->pretile_##XY) delete (bitmap->pretile_##XY); bitmap->pretile_##XY = NULL
 

Functions

static void nsbeos_rgba_to_bgra (void *src, void *dst, int width, int height, size_t rowstride)
 Convert to BeOS RGBA32_LITTLE (strictly BGRA) from NetSurf's favoured ABGR format. More...
 
static void * bitmap_create (int width, int height, enum gui_bitmap_flags flags)
 Create a bitmap. More...
 
static void bitmap_set_opaque (void *vbitmap, bool opaque)
 Sets whether a bitmap should be plotted opaque. More...
 
static bool bitmap_get_opaque (void *vbitmap)
 Gets whether a bitmap should be plotted opaque. More...
 
static unsigned char * bitmap_get_buffer (void *vbitmap)
 Return a pointer to the pixel data in a bitmap. More...
 
static size_t bitmap_get_rowstride (void *vbitmap)
 Find the width of a pixel row in bytes. More...
 
static void nsbeos_bitmap_free_pretiles (struct bitmap *bitmap)
 Free pretiles of a bitmap. More...
 
static void bitmap_destroy (void *vbitmap)
 Free a bitmap. More...
 
void bitmap_modified (void *vbitmap)
 The bitmap image has changed, so flush any persistant cache. More...
 
static int bitmap_get_width (void *vbitmap)
 
static int bitmap_get_height (void *vbitmap)
 
static BBitmap * nsbeos_bitmap_generate_pretile (BBitmap *primary, int repeat_x, int repeat_y)
 
BBitmap * nsbeos_bitmap_get_primary (struct bitmap *bitmap)
 The primary image associated with this bitmap object. More...
 
BBitmap * nsbeos_bitmap_get_pretile_x (struct bitmap *bitmap)
 The X-pretiled image associated with this bitmap object. More...
 
BBitmap * nsbeos_bitmap_get_pretile_y (struct bitmap *bitmap)
 The Y-pretiled image associated with this bitmap object. More...
 
BBitmap * nsbeos_bitmap_get_pretile_xy (struct bitmap *bitmap)
 The XY-pretiled image associated with this bitmap object. More...
 
static nserror bitmap_render (struct bitmap *bitmap, hlcache_handle *content)
 Create a thumbnail of a page. More...
 

Variables

static struct gui_bitmap_table bitmap_table
 
struct gui_bitmap_tablebeos_bitmap_table = &bitmap_table
 

Detailed Description

BeOS implementation of generic bitmaps.

This implements the interface given by image/bitmap.h using BBitmap.

Definition in file bitmap.cpp.

Macro Definition Documentation

◆ __STDBOOL_H__

#define __STDBOOL_H__   1

Definition at line 26 of file bitmap.cpp.

◆ FREE_TILE

#define FREE_TILE (   XY)    if (bitmap->pretile_##XY) delete (bitmap->pretile_##XY); bitmap->pretile_##XY = NULL

◆ MIN_PRETILE_HEIGHT

#define MIN_PRETILE_HEIGHT   256

Definition at line 64 of file bitmap.cpp.

◆ MIN_PRETILE_WIDTH

#define MIN_PRETILE_WIDTH   256

Definition at line 63 of file bitmap.cpp.

Function Documentation

◆ bitmap_create()

static void * bitmap_create ( int  width,
int  height,
enum gui_bitmap_flags  flags 
)
static

Create a bitmap.

Parameters
widthwidth of image in pixels
heightheight of image in pixels
bflagsflags for bitmap creation
Returns
an opaque struct bitmap, or NULL on memory exhaustion

Definition at line 121 of file bitmap.cpp.

References BITMAP_CLEAR, BITMAP_OPAQUE, height, bitmap::opaque, bitmap::pretile_x, bitmap::pretile_xy, bitmap::pretile_y, bitmap::primary, bitmap::shadow, and width.

◆ bitmap_destroy()

static void bitmap_destroy ( void *  vbitmap)
static

Free a bitmap.

Parameters
vbitmapa bitmap, as returned by bitmap_create()

Definition at line 223 of file bitmap.cpp.

References nsbeos_bitmap_free_pretiles(), bitmap::primary, and bitmap::shadow.

Here is the call graph for this function:

◆ bitmap_get_buffer()

static unsigned char * bitmap_get_buffer ( void *  vbitmap)
static

Return a pointer to the pixel data in a bitmap.

Parameters
vbitmapa bitmap, as returned by bitmap_create()
Returns
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().

Definition at line 181 of file bitmap.cpp.

References bitmap::shadow.

◆ bitmap_get_height()

static int bitmap_get_height ( void *  vbitmap)
static

Definition at line 258 of file bitmap.cpp.

References bitmap::primary.

◆ bitmap_get_opaque()

static bool bitmap_get_opaque ( void *  vbitmap)
static

Gets whether a bitmap should be plotted opaque.

Parameters
vbitmapa bitmap, as returned by bitmap_create()

Definition at line 163 of file bitmap.cpp.

References bitmap::opaque.

◆ bitmap_get_rowstride()

static size_t bitmap_get_rowstride ( void *  vbitmap)
static

Find the width of a pixel row in bytes.

Parameters
vbitmapa bitmap, as returned by bitmap_create()
Returns
width of a pixel row in the bitmap

Definition at line 195 of file bitmap.cpp.

References bitmap::primary.

◆ bitmap_get_width()

static int bitmap_get_width ( void *  vbitmap)
static

Definition at line 251 of file bitmap.cpp.

References bitmap::primary.

◆ bitmap_modified()

void bitmap_modified ( void *  vbitmap)

The bitmap image has changed, so flush any persistant cache.

Parameters
vbitmapa bitmap, as returned by bitmap_create()

Definition at line 239 of file bitmap.cpp.

References nsbeos_bitmap_free_pretiles(), nsbeos_rgba_to_bgra(), bitmap::primary, and bitmap::shadow.

Referenced by bitmap_render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bitmap_render()

static nserror bitmap_render ( struct bitmap bitmap,
hlcache_handle content 
)
static

Create a thumbnail of a page.

Parameters
bitmapthe bitmap to draw to
contentcontent structure to thumbnail
Returns
true on success and bitmap updated else false

Definition at line 379 of file bitmap.cpp.

References redraw_context::background_images, bitmap_modified(), content_get_width(), content_scaled_redraw(), height, redraw_context::interactive, MIN, nsbeos_bitmap_get_primary(), nsbeos_current_gc(), nsbeos_current_gc_set(), nsbeos_plotters, NSERROR_NOMEM, NSERROR_OK, redraw_context::plot, view, and width.

Here is the call graph for this function:

◆ bitmap_set_opaque()

static void bitmap_set_opaque ( void *  vbitmap,
bool  opaque 
)
static

Sets whether a bitmap should be plotted opaque.

Parameters
vbitmapa bitmap, as returned by bitmap_create()
opaquewhether the bitmap should be plotted opaque

Definition at line 150 of file bitmap.cpp.

References bitmap::opaque.

◆ nsbeos_bitmap_free_pretiles()

static void nsbeos_bitmap_free_pretiles ( struct bitmap bitmap)
static

Free pretiles of a bitmap.

Parameters
bitmapThe bitmap to free the pretiles of.

Definition at line 208 of file bitmap.cpp.

References FREE_TILE.

Referenced by bitmap_destroy(), and bitmap_modified().

Here is the caller graph for this function:

◆ nsbeos_bitmap_generate_pretile()

static BBitmap * nsbeos_bitmap_generate_pretile ( BBitmap *  primary,
int  repeat_x,
int  repeat_y 
)
static

Definition at line 266 of file bitmap.cpp.

References height, bitmap::primary, result, and width.

Referenced by nsbeos_bitmap_get_pretile_x(), nsbeos_bitmap_get_pretile_xy(), and nsbeos_bitmap_get_pretile_y().

Here is the caller graph for this function:

◆ nsbeos_bitmap_get_pretile_x()

BBitmap * nsbeos_bitmap_get_pretile_x ( struct bitmap bitmap)

The X-pretiled image associated with this bitmap object.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 320 of file bitmap.cpp.

References MIN_PRETILE_WIDTH, nsbeos_bitmap_generate_pretile(), NSLOG, bitmap::pretile_x, bitmap::primary, and width.

Referenced by nsbeos_plot_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsbeos_bitmap_get_pretile_xy()

BBitmap * nsbeos_bitmap_get_pretile_xy ( struct bitmap bitmap)

The XY-pretiled image associated with this bitmap object.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 357 of file bitmap.cpp.

References height, MIN_PRETILE_HEIGHT, MIN_PRETILE_WIDTH, nsbeos_bitmap_generate_pretile(), NSLOG, bitmap::pretile_xy, bitmap::primary, and width.

Referenced by nsbeos_plot_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsbeos_bitmap_get_pretile_y()

BBitmap * nsbeos_bitmap_get_pretile_y ( struct bitmap bitmap)

The Y-pretiled image associated with this bitmap object.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 339 of file bitmap.cpp.

References height, MIN_PRETILE_HEIGHT, nsbeos_bitmap_generate_pretile(), NSLOG, bitmap::pretile_y, and bitmap::primary.

Referenced by nsbeos_plot_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsbeos_bitmap_get_primary()

BBitmap * nsbeos_bitmap_get_primary ( struct bitmap bitmap)

The primary image associated with this bitmap object.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 308 of file bitmap.cpp.

References bitmap::primary.

Referenced by bitmap_render(), gui_window_set_icon(), and nsbeos_plot_bitmap().

Here is the caller graph for this function:

◆ nsbeos_rgba_to_bgra()

static void nsbeos_rgba_to_bgra ( void *  src,
void *  dst,
int  width,
int  height,
size_t  rowstride 
)
inlinestatic

Convert to BeOS RGBA32_LITTLE (strictly BGRA) from NetSurf's favoured ABGR format.

Copies the converted data elsewhere. Operation is rotate left 8 bits.

Parameters
srcSource 32-bit pixels arranged in ABGR order.
dstOutput data in BGRA order.
widthWidth of the bitmap
heightHeight of the bitmap
rowstrideNumber of bytes to skip after each row (this implementation requires this to be a multiple of 4.)

Definition at line 82 of file bitmap.cpp.

References from, height, to, and width.

Referenced by bitmap_modified().

Here is the caller graph for this function:

Variable Documentation

◆ beos_bitmap_table

struct gui_bitmap_table* beos_bitmap_table = &bitmap_table

Definition at line 499 of file bitmap.cpp.

Referenced by gui_init_replicant(), and main().

◆ bitmap_table

struct gui_bitmap_table bitmap_table
static
Initial value:
= {
}
static void bitmap_set_opaque(void *vbitmap, bool opaque)
Sets whether a bitmap should be plotted opaque.
Definition: bitmap.cpp:150
static bool bitmap_get_opaque(void *vbitmap)
Gets whether a bitmap should be plotted opaque.
Definition: bitmap.cpp:163
static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
Create a thumbnail of a page.
Definition: bitmap.cpp:379
static unsigned char * bitmap_get_buffer(void *vbitmap)
Return a pointer to the pixel data in a bitmap.
Definition: bitmap.cpp:181
static int bitmap_get_height(void *vbitmap)
Definition: bitmap.cpp:258
void bitmap_modified(void *vbitmap)
The bitmap image has changed, so flush any persistant cache.
Definition: bitmap.cpp:239
static size_t bitmap_get_rowstride(void *vbitmap)
Find the width of a pixel row in bytes.
Definition: bitmap.cpp:195
static void * bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
Definition: bitmap.cpp:121
static int bitmap_get_width(void *vbitmap)
Definition: bitmap.cpp:251
static void bitmap_destroy(void *vbitmap)
Free a bitmap.
Definition: bitmap.cpp:223

Definition at line 486 of file bitmap.cpp.