renamed private members of BPicture to fit our coding guidelines

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22216 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-09-10 14:55:42 +00:00
parent 945d8d11cd
commit 3424ff46e9
3 changed files with 99 additions and 97 deletions
+8 -13
View File
@@ -28,21 +28,11 @@
#ifndef _PICTURE_H #ifndef _PICTURE_H
#define _PICTURE_H #define _PICTURE_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h> #include <BeBuild.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <Rect.h> #include <Rect.h>
#include <Archivable.h> #include <Archivable.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BView; class BView;
struct _BPictureExtent_; struct _BPictureExtent_;
@@ -83,7 +73,10 @@ virtual void _ReservedPicture3();
void _ImportData(const void *data, int32 size, BPicture **subs, int32 subCount); void _ImportData(const void *data, int32 size, BPicture **subs, int32 subCount);
void _ImportOldData(const void *data, int32 size); void _ImportOldData(const void *data, int32 size);
void SetToken(int32 token); void SetToken(int32 token);
int32 Token() const;
bool _AssertLocalCopy(); bool _AssertLocalCopy();
bool _AssertOldLocalCopy(); bool _AssertOldLocalCopy();
bool _AssertServerCopy(); bool _AssertServerCopy();
@@ -99,9 +92,11 @@ virtual void _ReservedPicture3();
void Usurp(BPicture *lameDuck); void Usurp(BPicture *lameDuck);
BPicture *StepDown(); BPicture *StepDown();
int32 token;
_BPictureExtent_ *extent; int32 fToken;
BPicture *usurped; _BPictureExtent_ *fExtent;
BPicture *fUsurped;
uint32 _reserved[3]; uint32 _reserved[3];
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
+85 -78
View File
@@ -62,9 +62,9 @@ struct picture_header {
BPicture::BPicture() BPicture::BPicture()
: :
token(-1), fToken(-1),
extent(NULL), fExtent(NULL),
usurped(NULL) fUsurped(NULL)
{ {
_InitData(); _InitData();
} }
@@ -72,31 +72,31 @@ BPicture::BPicture()
BPicture::BPicture(const BPicture &otherPicture) BPicture::BPicture(const BPicture &otherPicture)
: :
token(-1), fToken(-1),
extent(NULL), fExtent(NULL),
usurped(NULL) fUsurped(NULL)
{ {
_InitData(); _InitData();
if (otherPicture.token != -1) { if (otherPicture.fToken != -1) {
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_CLONE_PICTURE); link.StartMessage(AS_CLONE_PICTURE);
link.Attach<int32>(otherPicture.token); link.Attach<int32>(otherPicture.fToken);
status_t status = B_ERROR; status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK if (link.FlushWithReply(status) == B_OK
&& status == B_OK) && status == B_OK)
link.Read<int32>(&token); link.Read<int32>(&fToken);
if (status < B_OK) if (status < B_OK)
return; return;
} }
if (otherPicture.extent->Size() > 0) { if (otherPicture.fExtent->Size() > 0) {
extent->ImportData(otherPicture.extent->Data(), otherPicture.extent->Size()); fExtent->ImportData(otherPicture.fExtent->Data(), otherPicture.fExtent->Size());
for (int32 i = 0; i < otherPicture.extent->CountPictures(); i++) { for (int32 i = 0; i < otherPicture.fExtent->CountPictures(); i++) {
BPicture *picture = new BPicture(*otherPicture.extent->PictureAt(i)); BPicture *picture = new BPicture(*otherPicture.fExtent->PictureAt(i));
extent->AddPicture(picture); fExtent->AddPicture(picture);
} }
} }
} }
@@ -104,9 +104,9 @@ BPicture::BPicture(const BPicture &otherPicture)
BPicture::BPicture(BMessage *archive) BPicture::BPicture(BMessage *archive)
: :
token(-1), fToken(-1),
extent(NULL), fExtent(NULL),
usurped(NULL) fUsurped(NULL)
{ {
_InitData(); _InitData();
@@ -128,28 +128,28 @@ BPicture::BPicture(BMessage *archive)
int32 i = 0; int32 i = 0;
while (archive->FindMessage("piclib", i++, &picMsg) == B_OK) { while (archive->FindMessage("piclib", i++, &picMsg) == B_OK) {
BPicture *pic = new BPicture(&picMsg); BPicture *pic = new BPicture(&picMsg);
extent->AddPicture(pic); fExtent->AddPicture(pic);
} }
if (version == 0) { if (version == 0) {
// TODO: For now. We'll see if it's worth to support old style data // TODO: For now. We'll see if it's worth to support old style data
debugger("old style BPicture data is not supported"); debugger("old style BPicture data is not supported");
} else if (version == 1) { } else if (version == 1) {
extent->ImportData(data, size); fExtent->ImportData(data, size);
// swap_data(extent->fNewData, extent->fNewSize); // swap_data(fExtent->fNewData, fExtent->fNewSize);
if (extent->Size() > 0) if (fExtent->Size() > 0)
_AssertServerCopy(); _AssertServerCopy();
} }
// Do we just free the data now? // Do we just free the data now?
if (extent->Size() > 0) if (fExtent->Size() > 0)
extent->SetSize(0); fExtent->SetSize(0);
// What with the sub pictures? // What with the sub pictures?
for (i = extent->CountPictures() - 1; i >= 0; i--) for (i = fExtent->CountPictures() - 1; i >= 0; i--)
extent->DeletePicture(i); fExtent->DeletePicture(i);
} }
@@ -164,10 +164,10 @@ BPicture::BPicture(const void *data, int32 size)
void void
BPicture::_InitData() BPicture::_InitData()
{ {
token = -1; fToken = -1;
usurped = NULL; fUsurped = NULL;
extent = new (std::nothrow) _BPictureExtent_; fExtent = new (std::nothrow) _BPictureExtent_;
} }
@@ -180,17 +180,17 @@ BPicture::~BPicture()
void void
BPicture::_DisposeData() BPicture::_DisposeData()
{ {
if (token != -1) { if (fToken != -1) {
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_DELETE_PICTURE); link.StartMessage(AS_DELETE_PICTURE);
link.Attach<int32>(token); link.Attach<int32>(fToken);
link.Flush(); link.Flush();
SetToken(-1); SetToken(-1);
} }
delete extent; delete fExtent;
extent = NULL; fExtent = NULL;
} }
@@ -222,14 +222,14 @@ BPicture::Archive(BMessage *archive, bool deep) const
if (err != B_OK) if (err != B_OK)
return err; return err;
err = archive->AddData("_data", B_RAW_TYPE, extent->Data(), extent->Size()); err = archive->AddData("_data", B_RAW_TYPE, fExtent->Data(), fExtent->Size());
if (err != B_OK) if (err != B_OK)
return err; return err;
for (int32 i = 0; i < extent->CountPictures(); i++) { for (int32 i = 0; i < fExtent->CountPictures(); i++) {
BMessage picMsg; BMessage picMsg;
extent->PictureAt(i)->Archive(&picMsg, deep); fExtent->PictureAt(i)->Archive(&picMsg, deep);
err = archive->AddMessage("piclib", &picMsg); err = archive->AddMessage("piclib", &picMsg);
if (err != B_OK) if (err != B_OK)
break; break;
@@ -252,7 +252,7 @@ BPicture::Play(void **callBackTable, int32 tableEntries, void *user)
if (!_AssertLocalCopy()) if (!_AssertLocalCopy())
return B_ERROR; return B_ERROR;
BPrivate::PicturePlayer player(extent->Data(), extent->Size(), extent->Pictures()); BPrivate::PicturePlayer player(fExtent->Data(), fExtent->Size(), fExtent->Pictures());
return player.Play(callBackTable, tableEntries, user); return player.Play(callBackTable, tableEntries, user);
} }
@@ -273,7 +273,7 @@ BPicture::Flatten(BDataIO *stream)
if (bytesWritten != (ssize_t)sizeof(header)) if (bytesWritten != (ssize_t)sizeof(header))
return B_IO_ERROR; return B_IO_ERROR;
int32 count = extent->CountPictures(); int32 count = fExtent->CountPictures();
bytesWritten = stream->Write(&count, sizeof(count)); bytesWritten = stream->Write(&count, sizeof(count));
if (bytesWritten < B_OK) if (bytesWritten < B_OK)
return bytesWritten; return bytesWritten;
@@ -281,19 +281,19 @@ BPicture::Flatten(BDataIO *stream)
return B_IO_ERROR; return B_IO_ERROR;
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
status_t status = extent->PictureAt(i)->Flatten(stream); status_t status = fExtent->PictureAt(i)->Flatten(stream);
if (status < B_OK) if (status < B_OK)
return status; return status;
} }
int32 size = extent->Size(); int32 size = fExtent->Size();
bytesWritten = stream->Write(&size, sizeof(size)); bytesWritten = stream->Write(&size, sizeof(size));
if (bytesWritten < B_OK) if (bytesWritten < B_OK)
return bytesWritten; return bytesWritten;
if (bytesWritten != (ssize_t)sizeof(size)) if (bytesWritten != (ssize_t)sizeof(size))
return B_IO_ERROR; return B_IO_ERROR;
bytesWritten = stream->Write(extent->Data(), size); bytesWritten = stream->Write(fExtent->Data(), size);
if (bytesWritten < B_OK) if (bytesWritten < B_OK)
return bytesWritten; return bytesWritten;
if (bytesWritten != size) if (bytesWritten != size)
@@ -329,21 +329,21 @@ BPicture::Unflatten(BDataIO *stream)
if (status < B_OK) if (status < B_OK)
return status; return status;
extent->AddPicture(picture); fExtent->AddPicture(picture);
} }
status_t status = extent->ImportData(stream); status_t status = fExtent->ImportData(stream);
if (status < B_OK) if (status < B_OK)
return status; return status;
// swap_data(extent->fNewData, extent->fNewSize); // swap_data(fExtent->fNewData, fExtent->fNewSize);
if (!_AssertServerCopy()) if (!_AssertServerCopy())
return B_ERROR; return B_ERROR;
// Data is now kept server side, remove the local copy // Data is now kept server side, remove the local copy
if (extent->Data() != NULL) if (fExtent->Data() != NULL)
extent->SetSize(0); fExtent->SetSize(0);
return status; return status;
} }
@@ -364,7 +364,7 @@ BPicture::_ImportData(const void *data, int32 size, BPicture **subs,
link.Attach<int32>(subCount); link.Attach<int32>(subCount);
for (int32 i = 0; i < subCount; i++) for (int32 i = 0; i < subCount; i++)
link.Attach<int32>(subs[i]->token); link.Attach<int32>(subs[i]->fToken);
link.Attach<int32>(size); link.Attach<int32>(size);
link.Attach(data, size); link.Attach(data, size);
@@ -372,7 +372,7 @@ BPicture::_ImportData(const void *data, int32 size, BPicture **subs,
status_t status = B_ERROR; status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK if (link.FlushWithReply(status) == B_OK
&& status == B_OK) && status == B_OK)
link.Read<int32>(&token);*/ link.Read<int32>(&fToken);*/
} }
@@ -384,19 +384,26 @@ BPicture::_ImportOldData(const void *data, int32 size)
void void
BPicture::SetToken(int32 _token) BPicture::SetToken(int32 token)
{ {
token = _token; fToken = token;
}
int32
BPicture::Token() const
{
return fToken;
} }
bool bool
BPicture::_AssertLocalCopy() BPicture::_AssertLocalCopy()
{ {
if (extent->Data() != NULL) if (fExtent->Data() != NULL)
return true; return true;
if (token == -1) if (fToken == -1)
return false; return false;
return _Download() == B_OK; return _Download() == B_OK;
@@ -415,14 +422,14 @@ BPicture::_AssertOldLocalCopy()
bool bool
BPicture::_AssertServerCopy() BPicture::_AssertServerCopy()
{ {
if (token != -1) if (fToken != -1)
return true; return true;
if (extent->Data() == NULL) if (fExtent->Data() == NULL)
return false; return false;
for (int32 i = 0; i < extent->CountPictures(); i++) for (int32 i = 0; i < fExtent->CountPictures(); i++)
extent->PictureAt(i)->_AssertServerCopy(); fExtent->PictureAt(i)->_AssertServerCopy();
return _Upload() == B_OK; return _Upload() == B_OK;
} }
@@ -431,26 +438,26 @@ BPicture::_AssertServerCopy()
status_t status_t
BPicture::_Upload() BPicture::_Upload()
{ {
ASSERT((token == -1)); ASSERT((fToken == -1));
ASSERT((extent->Data() != NULL)); ASSERT((fExtent->Data() != NULL));
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_CREATE_PICTURE); link.StartMessage(AS_CREATE_PICTURE);
link.Attach<int32>(extent->CountPictures()); link.Attach<int32>(fExtent->CountPictures());
for (int32 i = 0; i < extent->CountPictures(); i++) { for (int32 i = 0; i < fExtent->CountPictures(); i++) {
BPicture *picture = extent->PictureAt(i); BPicture *picture = fExtent->PictureAt(i);
if (picture) if (picture)
link.Attach<int32>(picture->token); link.Attach<int32>(picture->fToken);
} }
link.Attach<int32>(extent->Size()); link.Attach<int32>(fExtent->Size());
link.Attach(extent->Data(), extent->Size()); link.Attach(fExtent->Data(), fExtent->Size());
status_t status = B_ERROR; status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK if (link.FlushWithReply(status) == B_OK
&& status == B_OK) && status == B_OK)
link.Read<int32>(&token); link.Read<int32>(&fToken);
return status; return status;
} }
@@ -459,13 +466,13 @@ BPicture::_Upload()
status_t status_t
BPicture::_Download() BPicture::_Download()
{ {
ASSERT((extent->Data() == NULL)); ASSERT((fExtent->Data() == NULL));
ASSERT((token != -1)); ASSERT((fToken != -1));
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_DOWNLOAD_PICTURE); link.StartMessage(AS_DOWNLOAD_PICTURE);
link.Attach<int32>(token); link.Attach<int32>(fToken);
status_t status = B_ERROR; status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK && status == B_OK) { if (link.FlushWithReply(status) == B_OK && status == B_OK) {
@@ -475,15 +482,15 @@ BPicture::_Download()
// Read sub picture tokens // Read sub picture tokens
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
BPicture *pic = new BPicture; BPicture *pic = new BPicture;
link.Read<int32>(&pic->token); link.Read<int32>(&pic->fToken);
extent->AddPicture(pic); fExtent->AddPicture(pic);
} }
int32 size; int32 size;
link.Read<int32>(&size); link.Read<int32>(&size);
status = extent->SetSize(size); status = fExtent->SetSize(size);
if (status == B_OK) if (status == B_OK)
link.Read(const_cast<void *>(extent->Data()), size); link.Read(const_cast<void *>(fExtent->Data()), size);
} }
return status; return status;
@@ -493,20 +500,20 @@ BPicture::_Download()
const void * const void *
BPicture::Data() const BPicture::Data() const
{ {
if (extent->Data() == NULL) if (fExtent->Data() == NULL)
const_cast<BPicture*>(this)->_AssertLocalCopy(); const_cast<BPicture*>(this)->_AssertLocalCopy();
return extent->Data(); return fExtent->Data();
} }
int32 int32
BPicture::DataSize() const BPicture::DataSize() const
{ {
if (extent->Data() == NULL) if (fExtent->Data() == NULL)
const_cast<BPicture*>(this)->_AssertLocalCopy(); const_cast<BPicture*>(this)->_AssertLocalCopy();
return extent->Size(); return fExtent->Size();
} }
@@ -519,15 +526,15 @@ BPicture::Usurp(BPicture *lameDuck)
_InitData(); _InitData();
// Do the Usurping // Do the Usurping
usurped = lameDuck; fUsurped = lameDuck;
} }
BPicture * BPicture *
BPicture::StepDown() BPicture::StepDown()
{ {
BPicture *lameDuck = usurped; BPicture *lameDuck = fUsurped;
usurped = NULL; fUsurped = NULL;
return lameDuck; return lameDuck;
} }
+6 -6
View File
@@ -3091,7 +3091,7 @@ BView::SetDiskMode(char* filename, long offset)
void void
BView::BeginPicture(BPicture *picture) BView::BeginPicture(BPicture *picture)
{ {
if (do_owner_check() && picture && picture->usurped == NULL) { if (do_owner_check() && picture && picture->fUsurped == NULL) {
picture->Usurp(cpicture); picture->Usurp(cpicture);
cpicture = picture; cpicture = picture;
@@ -3105,8 +3105,8 @@ BView::AppendToPicture(BPicture *picture)
{ {
check_lock(); check_lock();
if (picture && picture->usurped == NULL) { if (picture && picture->fUsurped == NULL) {
int32 token = picture->token; int32 token = picture->Token();
if (token == -1) { if (token == -1) {
BeginPicture(picture); BeginPicture(picture);
@@ -3277,9 +3277,9 @@ BView::DrawPictureAsync(const BPicture *picture, BPoint where)
if (picture == NULL) if (picture == NULL)
return; return;
if (do_owner_check() && picture->token > 0) { if (do_owner_check() && picture->Token() > 0) {
fOwner->fLink->StartMessage(AS_LAYER_DRAW_PICTURE); fOwner->fLink->StartMessage(AS_LAYER_DRAW_PICTURE);
fOwner->fLink->Attach<int32>(picture->token); fOwner->fLink->Attach<int32>(picture->Token());
fOwner->fLink->Attach<BPoint>(where); fOwner->fLink->Attach<BPoint>(where);
_FlushIfNotInTransaction(); _FlushIfNotInTransaction();
@@ -4286,7 +4286,7 @@ BView::DoPictureClip(BPicture *picture, BPoint where,
if (do_owner_check()) { if (do_owner_check()) {
fOwner->fLink->StartMessage(AS_LAYER_CLIP_TO_PICTURE); fOwner->fLink->StartMessage(AS_LAYER_CLIP_TO_PICTURE);
fOwner->fLink->Attach<int32>(picture->token); fOwner->fLink->Attach<int32>(picture->Token());
fOwner->fLink->Attach<BPoint>(where); fOwner->fLink->Attach<BPoint>(where);
fOwner->fLink->Attach<bool>(invert); fOwner->fLink->Attach<bool>(invert);