Commit 6ada6367 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Vitaly Lipatov

gdiplus: Remove ceilf/floorf calls from bilinear scaler. (v2)

This improves performance by about 55%.
parent ea4f8f13
...@@ -605,7 +605,7 @@ static ARGB blend_colors(ARGB start, ARGB end, REAL position) ...@@ -605,7 +605,7 @@ static ARGB blend_colors(ARGB start, ARGB end, REAL position)
INT start_a, end_a, final_a; INT start_a, end_a, final_a;
INT pos; INT pos;
pos = gdip_round(position * 0xff); pos = (INT)(position * 255.0f + 0.5f);
start_a = ((start >> 24) & 0xff) * (pos ^ 0xff); start_a = ((start >> 24) & 0xff) * (pos ^ 0xff);
end_a = ((end >> 24) & 0xff) * pos; end_a = ((end >> 24) & 0xff) * pos;
...@@ -1011,6 +1011,11 @@ static ARGB sample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT wi ...@@ -1011,6 +1011,11 @@ static ARGB sample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT wi
return ((DWORD*)(bits))[(x - src_rect->X) + (y - src_rect->Y) * src_rect->Width]; return ((DWORD*)(bits))[(x - src_rect->X) + (y - src_rect->Y) * src_rect->Width];
} }
static FORCEINLINE int positive_ceilf(float f)
{
return f - (int)f > 0.0f ? f + 1.0f : f;
}
static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT width, static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT width,
UINT height, GpPointF *point, GDIPCONST GpImageAttributes *attributes, UINT height, GpPointF *point, GDIPCONST GpImageAttributes *attributes,
InterpolationMode interpolation, PixelOffsetMode offset_mode) InterpolationMode interpolation, PixelOffsetMode offset_mode)
...@@ -1031,12 +1036,12 @@ static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT ...@@ -1031,12 +1036,12 @@ static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT
ARGB top, bottom; ARGB top, bottom;
float x_offset; float x_offset;
leftxf = floorf(point->X); leftx = (INT)point->X;
leftx = (INT)leftxf; leftxf = (REAL)leftx;
rightx = (INT)ceilf(point->X); rightx = positive_ceilf(point->X);
topyf = floorf(point->Y); topy = (INT)point->Y;
topy = (INT)topyf; topyf = (REAL)topy;
bottomy = (INT)ceilf(point->Y); bottomy = positive_ceilf(point->Y);
if (leftx == rightx && topy == bottomy) if (leftx == rightx && topy == bottomy)
return sample_bitmap_pixel(src_rect, bits, width, height, return sample_bitmap_pixel(src_rect, bits, width, height,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment