HaikuDepot/SharedBitmap: switched to use BPositionIO...

...instead of BMallocIO specifically.
This commit is contained in:
Stephan Aßmus 2014-04-05 23:23:59 +02:00
parent e795d95872
commit f5ce3e39da
2 changed files with 18 additions and 8 deletions

View File

@ -64,16 +64,26 @@ SharedBitmap::SharedBitmap(const char* mimeType)
}
SharedBitmap::SharedBitmap(const BMallocIO& data)
SharedBitmap::SharedBitmap(BPositionIO& data)
:
BReferenceable(),
fResourceID(-1),
fBuffer(new(std::nothrow) uint8[data.BufferLength()]),
fSize(data.BufferLength()),
fBuffer(NULL),
fSize(0),
fMimeType()
{
if (fBuffer != NULL)
memcpy(fBuffer, data.Buffer(), fSize);
status_t status = data.GetSize(&fSize);
if (status == B_OK && fSize > 0 && fSize <= 64 * 1024) {
fBuffer = new(std::nothrow) uint8[fSize];
data.Seek(0, SEEK_SET);
ssize_t read = data.Read(fBuffer, fSize);
if (read != fSize) {
delete[] fBuffer;
fBuffer = NULL;
fSize = 0;
}
}
fBitmap[0] = NULL;
fBitmap[1] = NULL;

View File

@ -16,7 +16,7 @@
class BBitmap;
class BMallocIO;
class BPositionIO;
class SharedBitmap : public BReferenceable {
@ -31,7 +31,7 @@ public:
SharedBitmap(BBitmap* bitmap);
SharedBitmap(int32 resourceID);
SharedBitmap(const char* mimeType);
SharedBitmap(const BMallocIO& data);
SharedBitmap(BPositionIO& data);
~SharedBitmap();
const BBitmap* Bitmap(Size which);
@ -49,7 +49,7 @@ private:
private:
int32 fResourceID;
uint8* fBuffer;
size_t fSize;
off_t fSize;
BString fMimeType;
BBitmap* fBitmap[3];
};