NetSurf
Functions | Variables
bitmap.c File Reference

GTK bitmap handling. More...

#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <cairo.h>
#include <gtk/gtk.h>
#include "utils/utils.h"
#include "utils/errors.h"
#include "netsurf/content.h"
#include "netsurf/bitmap.h"
#include "netsurf/plotters.h"
#include "gtk/scaffolding.h"
#include "gtk/plotters.h"
#include "gtk/bitmap.h"
Include dependency graph for bitmap.c:

Go to the source code of this file.

Functions

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 bitmap_destroy (void *vbitmap)
 Free a bitmap. More...
 
static void bitmap_modified (void *vbitmap)
 The bitmap image has changed, so flush any persistant cache. More...
 
int nsgtk_bitmap_get_width (void *vbitmap)
 
int nsgtk_bitmap_get_height (void *vbitmap)
 
static nserror bitmap_render (struct bitmap *bitmap, struct hlcache_handle *content)
 Render content into a bitmap. More...
 

Variables

static struct gui_bitmap_table bitmap_table
 
struct gui_bitmap_tablensgtk_bitmap_table = &bitmap_table
 

Detailed Description

GTK bitmap handling.

This implements the bitmap interface using cairo image surfaces

Definition in file bitmap.c.

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
flagsflags for bitmap creation
Returns
an opaque struct bitmap, or NULL on memory exhaustion

Definition at line 52 of file bitmap.c.

References BITMAP_OPAQUE, height, bitmap::opaque, bitmap::surface, 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 148 of file bitmap.c.

References bitmap::scsurface, and bitmap::surface.

◆ 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 114 of file bitmap.c.

References bitmap::surface.

◆ 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 97 of file bitmap.c.

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 134 of file bitmap.c.

References bitmap::surface.

◆ bitmap_modified()

static void bitmap_modified ( void *  vbitmap)
static

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

Parameters
vbitmapa bitmap, as returned by bitmap_create()

Definition at line 168 of file bitmap.c.

References bitmap::surface.

◆ bitmap_render()

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

Render content into a bitmap.

Parameters
bitmapThe bitmap to draw to
contentThe content to render
Returns
true on success and bitmap updated else false

Definition at line 203 of file bitmap.c.

References content_get_width(), content_scaled_redraw(), current_cr, redraw_context::interactive, max, min, NSERROR_OK, nsgtk_plotters, and bitmap::surface.

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 84 of file bitmap.c.

References bitmap::opaque.

◆ nsgtk_bitmap_get_height()

int nsgtk_bitmap_get_height ( void *  vbitmap)

Definition at line 187 of file bitmap.c.

References bitmap::surface.

Referenced by nsgtk_print_plot_bitmap().

Here is the caller graph for this function:

◆ nsgtk_bitmap_get_width()

int nsgtk_bitmap_get_width ( void *  vbitmap)

Definition at line 178 of file bitmap.c.

References bitmap::surface.

Referenced by nsgtk_print_plot_bitmap().

Here is the caller graph for this function:

Variable Documentation

◆ bitmap_table

struct gui_bitmap_table bitmap_table
static
Initial value:
= {
.create = bitmap_create,
.destroy = bitmap_destroy,
.set_opaque = bitmap_set_opaque,
.get_opaque = bitmap_get_opaque,
.get_buffer = bitmap_get_buffer,
.get_rowstride = bitmap_get_rowstride,
.get_width = nsgtk_bitmap_get_width,
.get_height = nsgtk_bitmap_get_height,
.modified = bitmap_modified,
.render = bitmap_render,
}
static void bitmap_set_opaque(void *vbitmap, bool opaque)
Sets whether a bitmap should be plotted opaque.
Definition: bitmap.c:84
static void bitmap_modified(void *vbitmap)
The bitmap image has changed, so flush any persistant cache.
Definition: bitmap.c:168
static bool bitmap_get_opaque(void *vbitmap)
Gets whether a bitmap should be plotted opaque.
Definition: bitmap.c:97
static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
Render content into a bitmap.
Definition: bitmap.c:203
int nsgtk_bitmap_get_height(void *vbitmap)
Definition: bitmap.c:187
static unsigned char * bitmap_get_buffer(void *vbitmap)
Return a pointer to the pixel data in a bitmap.
Definition: bitmap.c:114
static size_t bitmap_get_rowstride(void *vbitmap)
Find the width of a pixel row in bytes.
Definition: bitmap.c:134
static void * bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
Definition: bitmap.c:52
int nsgtk_bitmap_get_width(void *vbitmap)
Definition: bitmap.c:178
static void bitmap_destroy(void *vbitmap)
Free a bitmap.
Definition: bitmap.c:148

Definition at line 281 of file bitmap.c.

◆ nsgtk_bitmap_table

struct gui_bitmap_table* nsgtk_bitmap_table = &bitmap_table

Definition at line 294 of file bitmap.c.

Referenced by main().