File: libnsfb_plot_util.h

package info (click to toggle)
netsurf 3.11-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 87,296 kB
  • sloc: ansic: 403,115; xml: 81,988; cpp: 6,246; perl: 4,605; makefile: 2,907; yacc: 2,246; python: 2,057; sh: 1,500; jsp: 1,156; lex: 623; javascript: 551; ruby: 329; asm: 326; lisp: 151; php: 6
file content (48 lines) | stat: -rw-r--r-- 1,457 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * Copyright 2009 Vincent Sanders <vince@simtec.co.uk>
 *
 * This file is part of libnsfb, http://www.netsurf-browser.org/
 * Licenced under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 *
 * This is the exported interface for the libnsfb graphics library. 
 */

#ifndef _LIBNSFB_PLOT_UTIL_H
#define _LIBNSFB_PLOT_UTIL_H 1


/* alpha blend two pixels together */
static inline nsfb_colour_t 
nsfb_plot_ablend(nsfb_colour_t pixel, nsfb_colour_t scrpixel)
{
    int opacity = pixel >> 24;
    int transp = 0x100 - opacity;
    uint32_t rb, g;

    rb = ((pixel & 0xFF00FF) * opacity +
          (scrpixel & 0xFF00FF) * transp) >> 8;
    g  = ((pixel & 0x00FF00) * opacity +
          (scrpixel & 0x00FF00) * transp) >> 8;

    return (rb & 0xFF00FF) | (g & 0xFF00);
}


bool nsfb_plot_clip(const nsfb_bbox_t * restrict clip, nsfb_bbox_t * restrict rect);

bool nsfb_plot_clip_ctx(nsfb_t *nsfb, nsfb_bbox_t * restrict rect);

bool nsfb_plot_clip_line(const nsfb_bbox_t * restrict clip, nsfb_bbox_t * restrict line);

bool nsfb_plot_clip_line_ctx(nsfb_t *nsfb, nsfb_bbox_t * restrict line);

/** Obtain a bounding box which is the superset of two source boxes.
 *
 */
bool nsfb_plot_add_rect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2, nsfb_bbox_t *result);

/** Find if two boxes intersect. */
bool nsfb_plot_bbox_intersect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2);

#endif /* _LIBNSFB_PLOT_UTIL_H */