Skip to content

Commit

Permalink
rasterizer: Use GDALRasterInfo* instead of void*
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Feb 4, 2025
1 parent 0354358 commit c4d4c62
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
23 changes: 11 additions & 12 deletions alg/gdal_alg_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,31 @@ typedef enum
/* Low level rasterizer API. */
/************************************************************************/

typedef void (*llScanlineFunc)(void *, int, int, int, double);
typedef void (*llPointFunc)(void *, int, int, double);
typedef void (*llScanlineFunc)(GDALRasterizeInfo *, int, int, int, double);
typedef void (*llPointFunc)(GDALRasterizeInfo *, int, int, double);

void GDALdllImagePoint(int nRasterXSize, int nRasterYSize, int nPartCount,
const int *panPartSize, const double *padfX,
const double *padfY, const double *padfVariant,
llPointFunc pfnPointFunc, void *pCBData);
llPointFunc pfnPointFunc, GDALRasterizeInfo *pCBData);

void GDALdllImageLine(int nRasterXSize, int nRasterYSize, int nPartCount,
const int *panPartSize, const double *padfX,
const double *padfY, const double *padfVariant,
llPointFunc pfnPointFunc, void *pCBData);
llPointFunc pfnPointFunc, GDALRasterizeInfo *pCBData);

void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize,
int nPartCount, const int *panPartSize,
const double *padfX, const double *padfY,
const double *padfVariant,
llPointFunc pfnPointFunc, void *pCBData,
bool bAvoidBurningSamePoints,
bool bIntersectOnly);
void GDALdllImageLineAllTouched(
int nRasterXSize, int nRasterYSize, int nPartCount, const int *panPartSize,
const double *padfX, const double *padfY, const double *padfVariant,
llPointFunc pfnPointFunc, GDALRasterizeInfo *pCBData,
bool bAvoidBurningSamePoints, bool bIntersectOnly);

void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize,
int nPartCount, const int *panPartSize,
const double *padfX, const double *padfY,
const double *padfVariant,
llScanlineFunc pfnScanlineFunc, void *pCBData,
llScanlineFunc pfnScanlineFunc,
GDALRasterizeInfo *pCBData,
bool bAvoidBurningSamePoints);

CPL_C_END
Expand Down
10 changes: 4 additions & 6 deletions alg/gdalrasterize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,10 @@ static inline void gvBurnScanlineInt64UserBurnValue(GDALRasterizeInfo *psInfo,
/************************************************************************/
/* gvBurnScanline() */
/************************************************************************/
static void gvBurnScanline(void *pCBData, int nY, int nXStart, int nXEnd,
double dfVariant)
static void gvBurnScanline(GDALRasterizeInfo *psInfo, int nY, int nXStart,
int nXEnd, double dfVariant)

{
GDALRasterizeInfo *psInfo = static_cast<GDALRasterizeInfo *>(pCBData);

if (nXStart > nXEnd)
return;

Expand Down Expand Up @@ -313,10 +311,10 @@ static inline void gvBurnPointInt64UserBurnValue(GDALRasterizeInfo *psInfo,
/************************************************************************/
/* gvBurnPoint() */
/************************************************************************/
static void gvBurnPoint(void *pCBData, int nY, int nX, double dfVariant)
static void gvBurnPoint(GDALRasterizeInfo *psInfo, int nY, int nX,
double dfVariant)

{
GDALRasterizeInfo *psInfo = static_cast<GDALRasterizeInfo *>(pCBData);

CPLAssert(nY >= 0 && nY < psInfo->nYSize);
CPLAssert(nX >= 0 && nX < psInfo->nXSize);
Expand Down
22 changes: 10 additions & 12 deletions alg/llrasterize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize,
int nPartCount, const int *panPartSize,
const double *padfX, const double *padfY,
const double *dfVariant,
llScanlineFunc pfnScanlineFunc, void *pCBData,
llScanlineFunc pfnScanlineFunc,
GDALRasterizeInfo *pCBData,
bool bAvoidBurningSamePoints)
{
if (!nPartCount)
Expand Down Expand Up @@ -232,7 +233,7 @@ void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize,
void GDALdllImagePoint(int nRasterXSize, int nRasterYSize, int nPartCount,
const int * /*panPartSize*/, const double *padfX,
const double *padfY, const double *padfVariant,
llPointFunc pfnPointFunc, void *pCBData)
llPointFunc pfnPointFunc, GDALRasterizeInfo *pCBData)
{
for (int i = 0; i < nPartCount; i++)
{
Expand All @@ -254,7 +255,7 @@ void GDALdllImagePoint(int nRasterXSize, int nRasterYSize, int nPartCount,
void GDALdllImageLine(int nRasterXSize, int nRasterYSize, int nPartCount,
const int *panPartSize, const double *padfX,
const double *padfY, const double *padfVariant,
llPointFunc pfnPointFunc, void *pCBData)
llPointFunc pfnPointFunc, GDALRasterizeInfo *pCBData)
{
if (!nPartCount)
return;
Expand All @@ -272,8 +273,7 @@ void GDALdllImageLine(int nRasterXSize, int nRasterYSize, int nPartCount,
double dfVariant = 0.0;
double dfVariant1 = 0.0;
if (padfVariant != nullptr &&
static_cast<GDALRasterizeInfo *>(pCBData)->eBurnValueSource !=
GBV_UserBurnValue)
pCBData->eBurnValueSource != GBV_UserBurnValue)
{
dfVariant = padfVariant[n + j - 1];
dfVariant1 = padfVariant[n + j];
Expand Down Expand Up @@ -380,13 +380,11 @@ void GDALdllImageLine(int nRasterXSize, int nRasterYSize, int nPartCount,
/* will be drawn with the burn value. */
/************************************************************************/

void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize,
int nPartCount, const int *panPartSize,
const double *padfX, const double *padfY,
const double *padfVariant,
llPointFunc pfnPointFunc, void *pCBData,
bool bAvoidBurningSamePoints,
bool bIntersectOnly)
void GDALdllImageLineAllTouched(
int nRasterXSize, int nRasterYSize, int nPartCount, const int *panPartSize,
const double *padfX, const double *padfY, const double *padfVariant,
llPointFunc pfnPointFunc, GDALRasterizeInfo *pCBData,
bool bAvoidBurningSamePoints, bool bIntersectOnly)

{
// This is an epsilon to detect geometries that are aligned with pixel
Expand Down

0 comments on commit c4d4c62

Please sign in to comment.