Decouple <cstdint>

This commit is contained in:
Martin Natano
2023-04-21 22:13:41 +02:00
parent bcea05dd67
commit aa87f85eef
167 changed files with 1533 additions and 1307 deletions
+19 -18
View File
@@ -5,6 +5,7 @@
#include "RageUtil.h"
#include <cmath>
#include <cstdint>
#include <vector>
/* Coordinate 0x0 represents the exact top-left corner of a bitmap. .5x.5
@@ -14,7 +15,7 @@
* (Look at a grid: map coordinates to the lines, not the squares between the
* lines.) */
static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector<uint32_t> &percent, int src, int dst )
static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector<std::uint32_t> &percent, int src, int dst )
{
if( src >= dst )
{
@@ -51,7 +52,7 @@ static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector
/* sax is somewhere between the centers of both sampled
* pixels; find the percentage: */
const float p = (1.0f - (sax - fleft) / xdist) * 16777216.0f;
percent.push_back( uint32_t(p) );
percent.push_back( std::uint32_t(p) );
}
}
}
@@ -74,7 +75,7 @@ static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector
s1.push_back( clamp(int(sax+1), 0, src-1) );
const float p = (1.0f - (sax - std::floor(sax))) * 16777216.0f;
percent.push_back( uint32_t(p) );
percent.push_back( std::uint32_t(p) );
}
}
}
@@ -84,42 +85,42 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst )
/* For each destination coordinate, two source rows, two source columns
* and the percentage of the first row and first column: */
std::vector<int> esx0, esx1, esy0, esy1;
std::vector<uint32_t> ex0, ey0;
std::vector<std::uint32_t> ex0, ey0;
InitVectors( esx0, esx1, ex0, src->w, dst->w );
InitVectors( esy0, esy1, ey0, src->h, dst->h );
// This is where all of the real work is done.
const uint8_t *sp = (uint8_t *) src->pixels;
const std::uint8_t *sp = (std::uint8_t *) src->pixels;
const int height = dst->h;
const int width = dst->w;
for( int y = 0; y < height; y++ )
{
uint8_t *dp = (uint8_t *) (dst->pixels + dst->pitch*y);
std::uint8_t *dp = (std::uint8_t *) (dst->pixels + dst->pitch*y);
/* current source pointer and next source pointer (first and second
* rows sampled for this row): */
const uint8_t *csp = sp + esy0[y] * src->pitch;
const uint8_t *ncsp = sp + esy1[y] * src->pitch;
const std::uint8_t *csp = sp + esy0[y] * src->pitch;
const std::uint8_t *ncsp = sp + esy1[y] * src->pitch;
for( int x = 0; x < width; x++ )
{
// Grab pointers to the sampled pixels:
const uint8_t *c00 = csp + esx0[x]*4;
const uint8_t *c01 = csp + esx1[x]*4;
const uint8_t *c10 = ncsp + esx0[x]*4;
const uint8_t *c11 = ncsp + esx1[x]*4;
const std::uint8_t *c00 = csp + esx0[x]*4;
const std::uint8_t *c01 = csp + esx1[x]*4;
const std::uint8_t *c10 = ncsp + esx0[x]*4;
const std::uint8_t *c11 = ncsp + esx1[x]*4;
for( int c = 0; c < 4; ++c )
{
uint32_t x0 = uint32_t(c00[c]) * ex0[x];
x0 += uint32_t(c01[c]) * (16777216 - ex0[x]);
std::uint32_t x0 = std::uint32_t(c00[c]) * ex0[x];
x0 += std::uint32_t(c01[c]) * (16777216 - ex0[x]);
x0 >>= 24;
uint32_t x1 = uint32_t(c10[c]) * ex0[x];
x1 += uint32_t(c11[c]) * (16777216 - ex0[x]);
std::uint32_t x1 = std::uint32_t(c10[c]) * ex0[x];
x1 += std::uint32_t(c11[c]) * (16777216 - ex0[x]);
x1 >>= 24;
const uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24;
dp[c] = uint8_t(res);
const std::uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24;
dp[c] = std::uint8_t(res);
}
// Advance destination pointer.