mirror of
https://github.com/aap/librw.git
synced 2025-12-20 09:29:49 +00:00
work on rasters
This commit is contained in:
@@ -309,8 +309,10 @@ createTexture(int32 width, int32 height, int32 numlevels, uint32 format)
|
||||
}
|
||||
|
||||
uint8*
|
||||
lockTexture(void *texture, int32 level)
|
||||
lockTexture(void *texture, int32 level, int32 lockMode)
|
||||
{
|
||||
// TODO: don't ignore this
|
||||
(void)lockMode;
|
||||
#ifdef RW_D3D9
|
||||
IDirect3DTexture9 *tex = (IDirect3DTexture9*)texture;
|
||||
D3DLOCKED_RECT lr;
|
||||
@@ -458,10 +460,10 @@ rasterCreate(Raster *raster)
|
||||
}
|
||||
|
||||
uint8*
|
||||
rasterLock(Raster *raster, int32 level)
|
||||
rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||
{
|
||||
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
|
||||
return lockTexture(natras->texture, level);
|
||||
return lockTexture(natras->texture, level, lockMode);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -546,7 +548,7 @@ rasterFromImage(Raster *raster, Image *image)
|
||||
|
||||
int32 inc = image->bpp;
|
||||
in = image->pixels;
|
||||
out = raster->lock(0);
|
||||
out = raster->lock(0, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||
if(pallength)
|
||||
memcpy(out, in, raster->width*raster->height);
|
||||
else
|
||||
@@ -592,7 +594,7 @@ rasterToImage(Raster *raster)
|
||||
if(natras->customFormat){
|
||||
image = Image::create(raster->width, raster->height, 32);
|
||||
image->allocate();
|
||||
uint8 *pix = raster->lock(0);
|
||||
uint8 *pix = raster->lock(0, Raster::LOCKREAD);
|
||||
switch(natras->format){
|
||||
case D3DFMT_DXT1:
|
||||
image->setPixelsDXT(1, pix);
|
||||
@@ -660,7 +662,7 @@ rasterToImage(Raster *raster)
|
||||
}
|
||||
|
||||
out = image->pixels;
|
||||
in = raster->lock(0);
|
||||
in = raster->lock(0, Raster::LOCKREAD);
|
||||
if(pallength)
|
||||
memcpy(out, in, raster->width*raster->height);
|
||||
else
|
||||
@@ -745,7 +747,7 @@ setPalette(Raster *raster, void *palette, int32 size)
|
||||
void
|
||||
setTexels(Raster *raster, void *texels, int32 level)
|
||||
{
|
||||
uint8 *dst = raster->lock(level);
|
||||
uint8 *dst = raster->lock(level, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||
memcpy(dst, texels, getLevelSize(raster, level));
|
||||
raster->unlock(level);
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ readNativeTexture(Stream *stream)
|
||||
for(int32 i = 0; i < numLevels; i++){
|
||||
size = stream->readU32();
|
||||
if(i < raster->getNumLevels()){
|
||||
data = raster->lock(i);
|
||||
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||
stream->read(data, size);
|
||||
raster->unlock(i);
|
||||
}else
|
||||
@@ -612,7 +612,7 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||
for(int32 i = 0; i < numLevels; i++){
|
||||
size = getLevelSize(raster, i);
|
||||
stream->writeU32(size);
|
||||
data = raster->lock(i);
|
||||
data = raster->lock(i, Raster::LOCKREAD);
|
||||
stream->write(data, size);
|
||||
raster->unlock(i);
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ readNativeTexture(Stream *stream)
|
||||
for(int32 i = 0; i < numLevels; i++){
|
||||
size = stream->readU32();
|
||||
if(i < raster->getNumLevels()){
|
||||
data = raster->lock(i);
|
||||
data = raster->lock(i, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||
stream->read(data, size);
|
||||
raster->unlock(i);
|
||||
}else
|
||||
@@ -719,7 +719,7 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||
for(int32 i = 0; i < numLevels; i++){
|
||||
size = getLevelSize(raster, i);
|
||||
stream->writeU32(size);
|
||||
data = raster->lock(i);
|
||||
data = raster->lock(i, Raster::LOCKREAD);
|
||||
stream->write(data, size);
|
||||
raster->unlock(i);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void im3DEnd(void);
|
||||
#endif
|
||||
|
||||
void rasterCreate(Raster *raster);
|
||||
uint8 *rasterLock(Raster *raster, int32 level);
|
||||
uint8 *rasterLock(Raster *raster, int32 level, int32 lockMode);
|
||||
void rasterUnlock(Raster *raster, int32 level);
|
||||
int32 rasterNumLevels(Raster *raster);
|
||||
void rasterFromImage(Raster *raster, Image *image);
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace rw {
|
||||
namespace xbox {
|
||||
|
||||
void rasterCreate(Raster *raster);
|
||||
uint8 *rasterLock(Raster *raster, int32 level);
|
||||
uint8 *rasterLock(Raster *raster, int32 level, int32 lockMode);
|
||||
void rasterUnlock(Raster*, int32);
|
||||
int32 rasterNumLevels(Raster *raster);
|
||||
Image *rasterToImage(Raster *raster);
|
||||
|
||||
@@ -580,8 +580,11 @@ rasterCreate(Raster *raster)
|
||||
}
|
||||
|
||||
uint8*
|
||||
rasterLock(Raster *raster, int32 level)
|
||||
rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||
{
|
||||
// TODO?
|
||||
(void)lockMode;
|
||||
|
||||
XboxRaster *natras = PLUGINOFFSET(XboxRaster, raster, nativeRasterOffset);
|
||||
RasterLevels *levels = (RasterLevels*)natras->texture;
|
||||
return levels->levels[level].data;
|
||||
@@ -644,7 +647,7 @@ rasterToImage(Raster *raster)
|
||||
if(natras->format){
|
||||
image = Image::create(raster->width, raster->height, 32);
|
||||
image->allocate();
|
||||
uint8 *pix = raster->lock(0);
|
||||
uint8 *pix = raster->lock(0, Raster::LOCKREAD);
|
||||
switch(natras->format){
|
||||
case D3DFMT_DXT1:
|
||||
image->setPixelsDXT(1, pix);
|
||||
@@ -715,7 +718,7 @@ rasterToImage(Raster *raster)
|
||||
}
|
||||
|
||||
out = image->pixels;
|
||||
in = raster->lock(0);
|
||||
in = raster->lock(0, Raster::LOCKREAD);
|
||||
|
||||
unswizzle(out, in, image->width, image->height, depth < 8 ? 1 : depth/8);
|
||||
// Fix RGB order
|
||||
@@ -854,7 +857,7 @@ readNativeTexture(Stream *stream)
|
||||
stream->read(ras->palette, 4*256);
|
||||
|
||||
// exploit the fact that mipmaps are allocated consecutively
|
||||
uint8 *data = raster->lock(0);
|
||||
uint8 *data = raster->lock(0, Raster::LOCKWRITE|Raster::LOCKNOFETCH);
|
||||
stream->read(data, totalSize);
|
||||
raster->unlock(0);
|
||||
|
||||
@@ -899,7 +902,7 @@ writeNativeTexture(Texture *tex, Stream *stream)
|
||||
stream->write(ras->palette, 4*256);
|
||||
|
||||
// exploit the fact that mipmaps are allocated consecutively
|
||||
uint8 *data = raster->lock(0);
|
||||
uint8 *data = raster->lock(0, Raster::LOCKREAD);
|
||||
stream->write(data, totalSize);
|
||||
raster->unlock(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user