|
|
@ -60,6 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
#include "../plPipeline/hsGDeviceRef.h" |
|
|
|
#include "../plPipeline/hsGDeviceRef.h" |
|
|
|
#include "plProfile.h" |
|
|
|
#include "plProfile.h" |
|
|
|
#include "../plJPEG/plJPEG.h" |
|
|
|
#include "../plJPEG/plJPEG.h" |
|
|
|
|
|
|
|
#include "plPNG.h" |
|
|
|
|
|
|
|
|
|
|
|
plProfile_CreateMemCounter("Mipmaps", "Memory", MemMipmaps); |
|
|
|
plProfile_CreateMemCounter("Mipmaps", "Memory", MemMipmaps); |
|
|
|
|
|
|
|
|
|
|
@ -122,11 +123,8 @@ void plMipmap::Create( UInt32 width, UInt32 height, unsigned config, UInt8 numLe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fCompressionType = compType; |
|
|
|
fCompressionType = compType; |
|
|
|
if( compType == kUncompressed ) |
|
|
|
if( compType == kUncompressed || compType == kJPEGCompression || |
|
|
|
{ |
|
|
|
compType == kPNGCompression ) |
|
|
|
fUncompressedInfo.fType = format; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( compType == kJPEGCompression ) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
fUncompressedInfo.fType = format; |
|
|
|
fUncompressedInfo.fType = format; |
|
|
|
} |
|
|
|
} |
|
|
@ -270,6 +268,10 @@ UInt32 plMipmap::Read( hsStream *s ) |
|
|
|
IReadJPEGImage( s ); |
|
|
|
IReadJPEGImage( s ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case kPNGCompression: |
|
|
|
|
|
|
|
IReadPNGImage( s ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
hsAssert( false, "Unknown compression type in plMipmap::Read()" ); |
|
|
|
hsAssert( false, "Unknown compression type in plMipmap::Read()" ); |
|
|
|
return totalRead; |
|
|
|
return totalRead; |
|
|
@ -309,6 +311,10 @@ UInt32 plMipmap::Write( hsStream *s ) |
|
|
|
IWriteJPEGImage( s ); |
|
|
|
IWriteJPEGImage( s ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case kPNGCompression: |
|
|
|
|
|
|
|
IWritePNGImage( s ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
hsAssert( false, "Unknown compression type in plMipmap::Read()" ); |
|
|
|
hsAssert( false, "Unknown compression type in plMipmap::Read()" ); |
|
|
|
return totalWritten; |
|
|
|
return totalWritten; |
|
|
@ -576,6 +582,23 @@ void plMipmap::IWriteJPEGImage( hsStream *stream ) |
|
|
|
delete alpha; |
|
|
|
delete alpha; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void plMipmap::IReadPNGImage(hsStream* stream) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
plMipmap* temp = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp = plPNG::Instance().ReadFromStream(stream); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (temp) { |
|
|
|
|
|
|
|
CopyFrom(temp); |
|
|
|
|
|
|
|
delete temp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void plMipmap::IWritePNGImage(hsStream* stream) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
plPNG::Instance().WriteToStream(stream, this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// GetLevelSize /////////////////////////////////////////////////////////////
|
|
|
|
//// GetLevelSize /////////////////////////////////////////////////////////////
|
|
|
|
// Get the size of a single mipmap level (0 is the largest)
|
|
|
|
// Get the size of a single mipmap level (0 is the largest)
|
|
|
|
|
|
|
|
|
|
|
@ -613,6 +636,7 @@ void plMipmap::IBuildLevelSizes() |
|
|
|
|
|
|
|
|
|
|
|
case kUncompressed: |
|
|
|
case kUncompressed: |
|
|
|
case kJPEGCompression: |
|
|
|
case kJPEGCompression: |
|
|
|
|
|
|
|
case kPNGCompression: |
|
|
|
fLevelSizes[ level ] = height * rowBytes; |
|
|
|
fLevelSizes[ level ] = height * rowBytes; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -1586,6 +1610,7 @@ void plMipmap::CopyFrom( const plMipmap *source ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case kUncompressed: |
|
|
|
case kUncompressed: |
|
|
|
case kJPEGCompression: |
|
|
|
case kJPEGCompression: |
|
|
|
|
|
|
|
case kPNGCompression: |
|
|
|
fUncompressedInfo.fType = source->fUncompressedInfo.fType; |
|
|
|
fUncompressedInfo.fType = source->fUncompressedInfo.fType; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|