blit
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
rop2.c File Reference

Binary raster operations. More...

#include <blit/phase_align.h>
#include <blit/rop2.h>
Include dependency graph for rop2.c:

Go to the source code of this file.

Macros

#define S   (fetch)
 8-bit source operand.
 
#define D   (store)
 8-bit destination operand.
 
#define ROP_REV_POLISH(revPolish, x)
 Macro to define a raster operation function.
 

Typedefs

typedef blit_scanline_t(* blit_rop2_func_t) (blit_scanline_t fetch, blit_scanline_t store)
 Type definition for raster operation function pointer.
 

Functions

 ROP_REV_POLISH (0, 0x00U)
 Raster operation: 0.
 
 ROP_REV_POLISH (DSon, ~(D|S))
 Raster operation: NOT (D OR S).
 
 ROP_REV_POLISH (DSna, D &~S)
 Raster operation: D AND NOT S.
 
 ROP_REV_POLISH (Sn, ~S)
 Raster operation: NOT S.
 
 ROP_REV_POLISH (SDna, S &~D)
 Raster operation: S AND NOT D.
 
 ROP_REV_POLISH (Dn, ~D)
 Raster operation: NOT D.
 
 ROP_REV_POLISH (DSx, D ^ S)
 Raster operation: D XOR S.
 
 ROP_REV_POLISH (DSan, ~(D &S))
 Raster operation: NOT (D AND S).
 
 ROP_REV_POLISH (DSa, D &S)
 Raster operation: D AND S.
 
 ROP_REV_POLISH (DSxn, ~(D ^ S))
 Raster operation: NOT (D XOR S).
 
 ROP_REV_POLISH (D, D)
 Raster operation: D.
 
 ROP_REV_POLISH (DSno, D|~S)
 Raster operation: D OR NOT S.
 
 ROP_REV_POLISH (S, S)
 Raster operation: S.
 
 ROP_REV_POLISH (SDno, S|~D)
 Raster operation: S OR NOT D.
 
 ROP_REV_POLISH (DSo, D|S)
 Raster operation: D OR S.
 
 ROP_REV_POLISH (1, 0xffU)
 Raster operation: 1.
 
bool blit_rgn1_rop2 (struct blit_scan *result, struct blit_rgn1 *x, struct blit_rgn1 *y, const struct blit_scan *source, enum blit_rop2 rop2)
 Perform raster operation with masking and store the result.
 
bool blit_rop2 (struct blit_scan *result, const int x, const int y, const int x_extent, const int y_extent, const struct blit_scan *source, const int x_source, const int y_source, enum blit_rop2 rop2)
 Convenience inline function for performing raster operations.
 

Detailed Description

Binary raster operations.

This source file implements the functions for performing binary raster operations on scan structures, as declared in the blit/rop2.h header file. These operations combine source and destination pixel values using bitwise operations. The implementation includes functions for various raster operations, such as copy, invert, and, or, xor, and others.

Definition in file rop2.c.

Macro Definition Documentation

◆ D

#define D   (store)

8-bit destination operand.

Definition at line 26 of file rop2.c.

◆ ROP_REV_POLISH

#define ROP_REV_POLISH (   revPolish,
 
)
Value:
static blit_scanline_t rop##revPolish(blit_scanline_t fetch, \
blit_scanline_t store); \
blit_scanline_t rop##revPolish(blit_scanline_t fetch, \
blit_scanline_t store) { \
return x; \
}
uint8_t blit_scanline_t
Type definition for a scanline element.
Definition scan.h:24

Macro to define a raster operation function.

The macro ROP_REV_POLISH is used to define the raster operation functions below. Each function takes a fetch function to get the source operand (S) and a pointer to the destination operand (D). The operations are defined using standard bitwise operations.

The defined raster operations include:

  • 0: Always returns 0.
  • DSon: NOT (D OR S).
  • DSna: D AND NOT S.
  • Sn: NOT S.
  • SDna: S AND NOT D.
  • Dn: NOT D.
  • DSx: D XOR S.
  • DSan: NOT (D AND S).
  • DSa: D AND S.
  • DSxn: NOT (D XOR S).
  • D: D.
  • DSno: D OR NOT S.
  • S: S.
  • SDno: S OR NOT D.
  • DSo: D OR S.
  • 1: Always returns 1 (0xffU).

Each operation is implemented as a static function returning the result of the specified bitwise expression.

Parameters
revPolishThe reverse polish notation name of the raster operation.
xThe expression defining the raster operation using D and S.

Definition at line 69 of file rop2.c.

◆ S

#define S   (fetch)

8-bit source operand.

Definition at line 21 of file rop2.c.

Typedef Documentation

◆ blit_rop2_func_t

typedef blit_scanline_t(* blit_rop2_func_t) (blit_scanline_t fetch, blit_scanline_t store)

Type definition for raster operation function pointer.

This type defines a function pointer for raster operation functions. Each raster operation function takes two 8-bit operands: the source operand (fetch) and the destination operand (store). The function returns an 8-bit result of the raster operation.

Definition at line 35 of file rop2.c.

Function Documentation

◆ blit_rgn1_rop2()

bool blit_rgn1_rop2 ( struct blit_scan result,
struct blit_rgn1 x,
struct blit_rgn1 y,
const struct blit_scan source,
enum blit_rop2  rop2 
)

Perform raster operation with masking and store the result.

This function performs a raster operation defined by the rop2 parameter on a specified region of the source and destination scan structures. It uses one-dimensional region structures for both the x and y axes to define the area of operation. The function handles phase alignment of the source data to ensure correct bit alignment during the operation.

Parameters
resultPointer to the destination scan structure.
xPointer to the one-dimensional region structure for the x-axis.
yPointer to the one-dimensional region structure for the y-axis.
sourcePointer to the source scan structure.
rop2The raster operation code.
Returns
true if the operation was successful, false otherwise.

Definition at line 195 of file rop2.c.

◆ blit_rop2()

bool blit_rop2 ( struct blit_scan result,
const int  x,
const int  y,
const int  x_extent,
const int  y_extent,
const struct blit_scan source,
const int  x_source,
const int  y_source,
enum blit_rop2  rop2 
)

Convenience inline function for performing raster operations.

This inline function provides a convenient way to perform raster operations on specified regions of the source and destination scan structures. It constructs one-dimensional region structures for both the x and y axes based on the provided parameters and then calls the blit_rgn1_rop2 function to perform the operation.

Use this version when you don't need to inspect the modified region structures that carry the clipped origins and extents. They are created on the stack and passed to the underlying function.

Parameters
resultPointer to the destination scan structure.
xThe x-coordinate of the origin of the region in the destination.
yThe y-coordinate of the origin of the region in the destination.
x_extentThe extent of the region in the x-axis.
y_extentThe extent of the region in the y-axis.
sourcePointer to the source scan structure.
x_sourceThe x-coordinate of the origin of the region in the source.
y_sourceThe y-coordinate of the origin of the region in the source.
rop2The raster operation code to apply.

Definition at line 300 of file rop2.c.