Leptonica 1.68
C Image Processing Library

roplow.c File Reference

Low-level general rasterop implementation. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "allheaders.h"

Go to the source code of this file.

Defines

#define COMBINE_PARTIAL(d, s, m)   ( ((d) & ~(m)) | ((s) & (m)) )

Functions

static void rasteropUniWordAlignedLow (l_uint32 *datad, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op)
static void rasteropUniGeneralLow (l_uint32 *datad, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op)
static void rasteropWordAlignedLow (l_uint32 *datad, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, l_uint32 *datas, l_int32 swpl, l_int32 sx, l_int32 sy)
static void rasteropVAlignedLow (l_uint32 *datad, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, l_uint32 *datas, l_int32 swpl, l_int32 sx, l_int32 sy)
static void rasteropGeneralLow (l_uint32 *datad, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, l_uint32 *datas, l_int32 swpl, l_int32 sx, l_int32 sy)
void rasteropUniLow (l_uint32 *datad, l_int32 dpixw, l_int32 dpixh, l_int32 depth, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op)
void rasteropLow (l_uint32 *datad, l_int32 dpixw, l_int32 dpixh, l_int32 depth, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, l_uint32 *datas, l_int32 spixw, l_int32 spixh, l_int32 swpl, l_int32 sx, l_int32 sy)

Variables

static const l_int32 SHIFT_LEFT = 0
static const l_int32 SHIFT_RIGHT = 1
static const l_uint32 lmask32 []
static const l_uint32 rmask32 []

Detailed Description

Low-level general rasterop implementation.

    Low level dest-only
         void            rasteropUniLow()
         static void     rasteropUniWordAlignedlLow()
         static void     rasteropUniGeneralLow()

    Low level src and dest
         void            rasteropLow()
         static void     rasteropWordAlignedLow()
         static void     rasteropVAlignedLow()
         static void     rasteropGeneralLow()

Definition in file roplow.c.


Define Documentation

#define COMBINE_PARTIAL (   d,
  s,
 
)    ( ((d) & ~(m)) | ((s) & (m)) )

Function Documentation

static void rasteropUniWordAlignedLow ( l_uint32 datad,
l_int32  dwpl,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
l_int32  op 
) [static]

rasteropUniWordAlignedLow()

Input: datad (ptr to dest image data) dwpl (wpl of dest) dx (x val of UL corner of dest rectangle) dy (y val of UL corner of dest rectangle) dw (width of dest rectangle) dh (height of dest rectangle) op (op code) Return: void

This is called when the dest rect is left aligned on (32-bit) word boundaries. That is: dx & 31 == 0.

We make an optimized implementation of this because it is a common case: e.g., operating on a full dest image.

Definition at line 190 of file roplow.c.

References COMBINE_PARTIAL, lmask32, PIX_CLR, PIX_DST, PIX_NOT, PIX_SET, and x0.

Referenced by rasteropUniLow().

static void rasteropUniGeneralLow ( l_uint32 datad,
l_int32  dwpl,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
l_int32  op 
) [static]

rasteropUniGeneralLow()

Input: datad (ptr to dest image data) dwpl (wpl of dest) dx (x val of UL corner of dest rectangle) dy (y val of UL corner of dest rectangle) dw (width of dest rectangle) dh (height of dest rectangle) op (op code) Return: void

Definition at line 273 of file roplow.c.

References COMBINE_PARTIAL, lmask32, PIX_CLR, PIX_DST, PIX_NOT, PIX_SET, rmask32, and x0.

Referenced by rasteropUniLow().

static void rasteropWordAlignedLow ( l_uint32 datad,
l_int32  dwpl,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
l_int32  op,
l_uint32 datas,
l_int32  swpl,
l_int32  sx,
l_int32  sy 
) [static]

rasteropWordAlignedLow()

Input: datad (ptr to dest image data) dwpl (wpl of dest) dx (x val of UL corner of dest rectangle) dy (y val of UL corner of dest rectangle) dw (width of dest rectangle) dh (height of dest rectangle) op (op code) datas (ptr to src image data) swpl (wpl of src) sx (x val of UL corner of src rectangle) sy (y val of UL corner of src rectangle) Return: void

This is called when both the src and dest rects are left aligned on (32-bit) word boundaries. That is: dx & 31 == 0 and sx & 31 == 0

We make an optimized implementation of this because it is a common case: e.g., two images are rasterop'd starting from their UL corners (0,0).

Definition at line 592 of file roplow.c.

References COMBINE_PARTIAL, lmask32, PIX_DST, PIX_NOT, and PIX_SRC.

Referenced by rasteropLow().

static void rasteropVAlignedLow ( l_uint32 datad,
l_int32  dwpl,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
l_int32  op,
l_uint32 datas,
l_int32  swpl,
l_int32  sx,
l_int32  sy 
) [static]

rasteropVAlignedLow()

Input: datad (ptr to dest image data) dwpl (wpl of dest) dx (x val of UL corner of dest rectangle) dy (y val of UL corner of dest rectangle) dw (width of dest rectangle) dh (height of dest rectangle) op (op code) datas (ptr to src image data) swpl (wpl of src) sx (x val of UL corner of src rectangle) sy (y val of UL corner of src rectangle) Return: void

This is called when the left side of the src and dest rects have the same alignment relative to (32-bit) word boundaries; i.e., (dx & 31) == (sx & 31)

Definition at line 818 of file roplow.c.

References COMBINE_PARTIAL, lmask32, PIX_DST, PIX_NOT, PIX_SRC, and rmask32.

Referenced by rasteropLow().

static void rasteropGeneralLow ( l_uint32 datad,
l_int32  dwpl,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
l_int32  op,
l_uint32 datas,
l_int32  swpl,
l_int32  sx,
l_int32  sy 
) [static]

rasteropGeneralLow()

Input: datad (ptr to dest image data) dwpl (wpl of dest) dx (x val of UL corner of dest rectangle) dy (y val of UL corner of dest rectangle) dw (width of dest rectangle) dh (height of dest rectangle) op (op code) datas (ptr to src image data) swpl (wpl of src) sx (x val of UL corner of src rectangle) sy (y val of UL corner of src rectangle) Return: void

This is called when the src and dest rects are do not have the same (32-bit) word alignment.

The method is a generalization of rasteropVAlignLow(). There, the src image pieces were directly merged with the dest. Here, we shift the source bits to fill words that are aligned with the dest, and then use those "source words" exactly in place of the source words that were used in rasteropVAlignLow().

The critical parameter is thus the shift required for the src. Consider the left edge of the rectangle. The overhang into the src and dest words are found, and the difference is exactly this shift. There are two separate cases, depending on whether the src pixels are shifted left or right. If the src overhang is larger than the dest overhang, the src is shifted to the right, a number of pixels equal to the shift are left over for filling the next dest word, if necessary. But if the dest overhang is larger than the src, the src is shifted to the left, and it may also be necessary to shift an equal number of pixels in from the next src word. However, in both cases, after the first partial (or complete) dest word has been filled, the next src pixels will come from a left shift that exhausts the pixels in the src word.

Definition at line 1341 of file roplow.c.

References COMBINE_PARTIAL, lmask32, PIX_DST, PIX_NOT, PIX_SRC, rmask32, SHIFT_LEFT, and SHIFT_RIGHT.

Referenced by rasteropLow().

void rasteropUniLow ( l_uint32 datad,
l_int32  dpixw,
l_int32  dpixh,
l_int32  depth,
l_int32  dwpl,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
l_int32  op 
)

rasteropUniLow()

Input: datad (ptr to dest image data) dpixw (width of dest) dpixh (height of dest) depth (depth of src and dest) dwpl (wpl of dest) dx (x val of UL corner of dest rectangle) dy (y val of UL corner of dest rectangle) dw (width of dest rectangle) dh (height of dest rectangle) op (op code) Return: void

Action: scales width, performs clipping, checks alignment, and dispatches for the rasterop.

Definition at line 109 of file roplow.c.

References rasteropUniGeneralLow(), and rasteropUniWordAlignedLow().

Referenced by pixRasterop().

void rasteropLow ( l_uint32 datad,
l_int32  dpixw,
l_int32  dpixh,
l_int32  depth,
l_int32  dwpl,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
l_int32  op,
l_uint32 datas,
l_int32  spixw,
l_int32  spixh,
l_int32  swpl,
l_int32  sx,
l_int32  sy 
)

rasteropLow()

Input: datad (ptr to dest image data) dpixw (width of dest) dpixh (height of dest) depth (depth of src and dest) dwpl (wpl of dest) dx (x val of UL corner of dest rectangle) dy (y val of UL corner of dest rectangle) dw (width of dest rectangle) dh (height of dest rectangle) op (op code) datas (ptr to src image data) spixw (width of src) spixh (height of src) swpl (wpl of src) sx (x val of UL corner of src rectangle) sy (y val of UL corner of src rectangle) Return: void

Action: Scales width, performs clipping, checks alignment, and dispatches for the rasterop.

Warning: the two images must have equal depth. This is not checked.

Definition at line 473 of file roplow.c.

References rasteropGeneralLow(), rasteropVAlignedLow(), and rasteropWordAlignedLow().

Referenced by pixRasterop().


Variable Documentation

const l_int32 SHIFT_LEFT = 0 [static]

Definition at line 39 of file roplow.c.

Referenced by rasteropGeneralLow().

const l_int32 SHIFT_RIGHT = 1 [static]

Definition at line 40 of file roplow.c.

Referenced by rasteropGeneralLow().

const l_uint32 lmask32[] [static]
Initial value:
 {0x0,
    0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
    0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
    0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
    0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
    0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000,
    0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
    0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0,
    0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff}

Definition at line 66 of file roplow.c.

Referenced by rasteropGeneralLow(), rasteropUniGeneralLow(), rasteropUniWordAlignedLow(), rasteropVAlignedLow(), and rasteropWordAlignedLow().

const l_uint32 rmask32[] [static]
Initial value:
 {0x0,
    0x00000001, 0x00000003, 0x00000007, 0x0000000f,
    0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
    0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
    0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
    0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
    0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
    0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
    0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff}

Definition at line 76 of file roplow.c.

Referenced by rasteropGeneralLow(), rasteropUniGeneralLow(), and rasteropVAlignedLow().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines