Symbian^3 port

This commit is contained in:
Shinovon 2026-04-29 05:15:13 +05:00
parent 77cdaaf97e
commit 3eb71f2cc5
106 changed files with 2098 additions and 745 deletions

View file

@ -28,6 +28,99 @@
float texLoadTime;
int32 texNumLoaded;
static RwImage* resizeImage(RwImage *image, int newWidth, int newHeight)
{
image->convertTo32();
RwImage *resized = RwImageCreate(newWidth, newHeight, 32);
if (resized == nil) return nil;
RwImageAllocatePixels(resized);
if (resized->pixels == nil) {
RwImageDestroy(resized);
return nil;
}
for (int y = 0; y < newHeight; y++) {
uint8 *dst = resized->pixels + y*resized->stride;
int y0 = y*image->height/newHeight;
int y1 = (y + 1)*image->height/newHeight;
if (y1 <= y0)
y1 = y0 + 1;
for (int x = 0; x < newWidth; x++) {
int x0 = x*image->width/newWidth;
int x1 = (x + 1)*image->width/newWidth;
if (x1 <= x0)
x1 = x0 + 1;
uint r = 0;
uint g = 0;
uint b = 0;
uint a = 0;
uint samples = 0;
for (int sy = y0; sy < y1; sy++) {
const uint8 *src = image->pixels + sy*image->stride + x0*4;
for (int sx = x0; sx < x1; sx++) {
r += src[0];
g += src[1];
b += src[2];
a += src[3];
samples++;
src += 4;
}
}
dst[0] = r / samples;
dst[1] = g / samples;
dst[2] = b / samples;
dst[3] = a / samples;
dst += 4;
}
}
return resized;
}
static int clamp(int32 size)
{
while (size > 32 && size > 1) {
size = (size + 1) / 2;
}
return size;
}
static void downscaleTexture(RwTexture *texture)
{
RwRaster *oldRaster = RwTextureGetRaster(texture);
if (oldRaster == nil)
return;
int oldWidth = RwRasterGetWidth(oldRaster);
int oldHeight = RwRasterGetHeight(oldRaster);
if (oldWidth <= 32 && oldHeight <= 32) return;
int newWidth = clamp(oldWidth);
int newHeight = clamp(oldHeight);
if (newWidth == oldWidth && newHeight == oldHeight) return;
RwImage *image = oldRaster->toImage();
if (image == nil) return;
RwImage *resized = resizeImage(image, newWidth, newHeight);
RwImageDestroy(image);
if (resized == nil) return;
RwRaster *newRaster = rw::Raster::createFromImage(resized);
RwImageDestroy(resized);
if (newRaster == nil) return;
RwTextureSetRaster(texture, newRaster);
RwRasterDestroy(oldRaster);
}
#ifdef LIBRW
#define READNATIVE(stream, tex, size) rwNativeTextureHackRead(stream, tex, size)
#else
@ -164,7 +257,7 @@ RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict)
#ifdef LIBRW
#define CAPSVERSION 0
#define CAPSVERSION 1
struct GPUcaps
{
@ -397,7 +490,11 @@ CreateTxdImageForVideoCard()
sprintf(filename, "%s.txd", CTxdStore::GetTxdName(i));
if (CTxdStore::GetSlot(i)->texDict) {
RwTexDictionary *texDict = CTxdStore::GetSlot(i)->texDict;
FORLIST(lnk, texDict->textures){
rw::Texture *texture = rw::Texture::fromDict(lnk);
downscaleTexture(texture);
}
int32 pos = STREAMTELL(img);
if (RwTexDictionaryStreamWrite(CTxdStore::GetSlot(i)->texDict, img) == nil) {