worked on raters; fixed a few issues
This commit is contained in:
114
src/texture.cpp
114
src/texture.cpp
@ -454,118 +454,4 @@ Texture::streamGetSizeNative(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Raster
|
||||
//
|
||||
|
||||
Raster*
|
||||
Raster::create(int32 width, int32 height, int32 depth, int32 format, int32 platform)
|
||||
{
|
||||
// TODO: pass arguments through to the driver and create the raster there
|
||||
Raster *raster = (Raster*)rwMalloc(s_plglist.size, MEMDUR_EVENT); // TODO
|
||||
assert(raster != nil);
|
||||
raster->parent = raster;
|
||||
raster->offsetX = 0;
|
||||
raster->offsetY = 0;
|
||||
raster->platform = platform ? platform : rw::platform;
|
||||
raster->type = format & 0x7;
|
||||
raster->flags = format & 0xF8;
|
||||
raster->privateFlags = 0;
|
||||
raster->format = format & 0xFF00;
|
||||
raster->width = width;
|
||||
raster->height = height;
|
||||
raster->depth = depth;
|
||||
raster->pixels = raster->palette = nil;
|
||||
s_plglist.construct(raster);
|
||||
|
||||
// printf("%d %d %d %d\n", raster->type, raster->width, raster->height, raster->depth);
|
||||
engine->driver[raster->platform]->rasterCreate(raster);
|
||||
return raster;
|
||||
}
|
||||
|
||||
void
|
||||
Raster::subRaster(Raster *parent, Rect *r)
|
||||
{
|
||||
if((this->flags & DONTALLOCATE) == 0)
|
||||
return;
|
||||
this->width = r->w;
|
||||
this->height = r->h;
|
||||
this->offsetX += r->x;
|
||||
this->offsetY += r->y;
|
||||
this->parent = parent->parent;
|
||||
}
|
||||
|
||||
void
|
||||
Raster::destroy(void)
|
||||
{
|
||||
s_plglist.destruct(this);
|
||||
// delete[] this->texels;
|
||||
// delete[] this->palette;
|
||||
rwFree(this);
|
||||
}
|
||||
|
||||
uint8*
|
||||
Raster::lock(int32 level, int32 lockMode)
|
||||
{
|
||||
return engine->driver[this->platform]->rasterLock(this, level, lockMode);
|
||||
}
|
||||
|
||||
void
|
||||
Raster::unlock(int32 level)
|
||||
{
|
||||
engine->driver[this->platform]->rasterUnlock(this, level);
|
||||
}
|
||||
|
||||
uint8*
|
||||
Raster::lockPalette(int32 lockMode)
|
||||
{
|
||||
return engine->driver[this->platform]->rasterLockPalette(this, lockMode);
|
||||
}
|
||||
|
||||
void
|
||||
Raster::unlockPalette(void)
|
||||
{
|
||||
engine->driver[this->platform]->rasterUnlockPalette(this);
|
||||
}
|
||||
|
||||
int32
|
||||
Raster::getNumLevels(void)
|
||||
{
|
||||
return engine->driver[this->platform]->rasterNumLevels(this);
|
||||
}
|
||||
|
||||
int32
|
||||
Raster::calculateNumLevels(int32 width, int32 height)
|
||||
{
|
||||
int32 size = width >= height ? width : height;
|
||||
int32 n;
|
||||
for(n = 0; size != 0; n++)
|
||||
size /= 2;
|
||||
return n;
|
||||
}
|
||||
|
||||
bool
|
||||
Raster::formatHasAlpha(int32 format)
|
||||
{
|
||||
return (format & 0xF00) == Raster::C8888 ||
|
||||
(format & 0xF00) == Raster::C1555 ||
|
||||
(format & 0xF00) == Raster::C4444;
|
||||
}
|
||||
|
||||
Raster*
|
||||
Raster::createFromImage(Image *image, int32 platform)
|
||||
{
|
||||
Raster *raster = Raster::create(image->width, image->height,
|
||||
image->depth, TEXTURE | DONTALLOCATE,
|
||||
platform);
|
||||
engine->driver[raster->platform]->rasterFromImage(raster, image);
|
||||
return raster;
|
||||
}
|
||||
|
||||
Image*
|
||||
Raster::toImage(void)
|
||||
{
|
||||
return engine->driver[this->platform]->rasterToImage(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user