Made the getSize() and getData() methods for CompressedData consistent with each other. Note that CompressedData's data may not all be contiguous in memory, so getData(miplevel) and getSize(miplevel) should always be used instead.

--HG--
branch : image-CompressedData
This commit is contained in:
Alex Szpakowski
2013-04-09 23:39:20 -03:00
parent ab2c4aca7e
commit 4cd14d5c08
2 changed files with 16 additions and 9 deletions
+13 -8
View File
@@ -36,18 +36,23 @@ CompressedData::~CompressedData()
int CompressedData::getSize() const int CompressedData::getSize() const
{ {
size_t totalsize = sizeof(SubImage) * dataImages.size(); // Adding up the total size for all mipmap levels would make more sense, but
// it's probably better for getSize() to match getData() so no bad memory
for (size_t i = 0; i < dataImages.size(); i++) // accesses happen...
totalsize += dataImages[i].size; if (dataImages.size() > 0)
return dataImages[0].size;
return totalsize; else
return 0;
} }
void *CompressedData::getData() const void *CompressedData::getData() const
{ {
// ? // Data for different mipmap levels is not stored contiguously in memory, so
return (void *) &dataImages[0].data[0]; // getData() won't work properly for CompressedData.
if (dataImages.size() > 0)
return (void *) &(dataImages[0].data[0]);
else
return 0;
} }
int CompressedData::getNumMipmaps() const int CompressedData::getNumMipmaps() const
+3 -1
View File
@@ -70,7 +70,9 @@ public:
CompressedData(); CompressedData();
virtual ~CompressedData(); virtual ~CompressedData();
// Implements Data. // Implements Data. Note that data for different mipmap levels is not always
// stored contiguously in memory, so getData() and getSize() don't make
// much sense. Use getData(miplevel) and getSize(mipleveL) instead.
virtual void *getData() const; virtual void *getData() const;
virtual int getSize() const; virtual int getSize() const;