static void draw_picture(View* view, BPoint where, int32 token) { ServerPicture* picture = view->Window()->ServerWindow()->App()->GetPicture(token); if (picture != NULL) { view->SetDrawingOrigin(where); view->PushState(); picture->Play(view); view->PopState(); picture->ReleaseReference(); } }
ServerPicture::ServerPicture(const ServerPicture& picture) : fFile(NULL), fData(NULL), fPictures(NULL), fPushed(NULL), fOwner(NULL) { fToken = gTokenSpace.NewToken(kPictureToken, this); BMallocIO* mallocIO = new(std::nothrow) BMallocIO(); if (mallocIO == NULL) return; fData = mallocIO; const off_t size = picture.DataLength(); if (mallocIO->SetSize(size) < B_OK) return; picture.fData->ReadAt(0, const_cast<void*>(mallocIO->Buffer()), size); PictureDataWriter::SetTo(fData); }
static void draw_picture(DrawingContext* context, BPoint where, int32 token) { ServerPicture* picture = context->GetPicture(token); if (picture != NULL) { context->PushState(); context->SetDrawingOrigin(where); context->PushState(); picture->Play(context); context->PopState(); context->PopState(); picture->ReleaseReference(); } }
static void draw_picture(void* _context, const BPoint& where, int32 token) { DrawingContext* context = reinterpret_cast<DrawingContext *>(_context); ServerPicture* picture = context->GetPicture(token); if (picture != NULL) { context->PushState(); context->SetDrawingOrigin(where); context->PushState(); picture->Play(context); context->PopState(); context->PopState(); picture->ReleaseReference(); } }
static void draw_picture(void* _canvas, const BPoint& where, int32 token) { Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas); ServerPicture* picture = canvas->GetPicture(token); if (picture != NULL) { canvas->PushState(); canvas->SetDrawingOrigin(where); canvas->PushState(); picture->Play(canvas); canvas->PopState(); canvas->PopState(); picture->ReleaseReference(); } }
static void clip_to_picture(void* _context, int32 pictureToken, const BPoint& where, bool clipToInverse) { DrawingContext* context = reinterpret_cast<DrawingContext *>(_context); ServerPicture* picture = context->GetPicture(pictureToken); if (picture == NULL) return; AlphaMask* mask = new(std::nothrow) AlphaMask( picture, clipToInverse, where, *context->CurrentState()); context->SetAlphaMask(mask); context->UpdateCurrentDrawingRegion(); if (mask != NULL) mask->ReleaseReference(); picture->ReleaseReference(); }
status_t ServerPicture::ExportData(BPrivate::PortLink& link) { link.StartMessage(B_OK); off_t oldPosition = fData->Position(); fData->Seek(0, SEEK_SET); int32 subPicturesCount = 0; if (fPictures != NULL) subPicturesCount = fPictures->CountItems(); link.Attach<int32>(subPicturesCount); if (subPicturesCount > 0) { for (int32 i = 0; i < subPicturesCount; i++) { ServerPicture* subPicture = fPictures->ItemAt(i); link.Attach<int32>(subPicture->Token()); } } off_t size = 0; fData->GetSize(&size); link.Attach<int32>((int32)size); status_t status = B_NO_MEMORY; char* buffer = new(std::nothrow) char[size]; if (buffer) { status = B_OK; ssize_t read = fData->Read(buffer, size); if (read < B_OK || link.Attach(buffer, read) < B_OK) status = B_ERROR; delete [] buffer; } if (status != B_OK) { link.CancelMessage(); link.StartMessage(B_ERROR); } fData->Seek(oldPosition, SEEK_SET); return status; }
ServerPicture::~ServerPicture() { ASSERT(fOwner == NULL); delete fData; delete fFile; gTokenSpace.RemoveToken(fToken); if (fPictures != NULL) { for (int32 i = fPictures->CountItems(); i-- > 0;) { ServerPicture* picture = fPictures->ItemAt(i); picture->SetOwner(NULL); picture->ReleaseReference(); } delete fPictures; } if (fPushed != NULL) { fPushed->SetOwner(NULL); fPushed->ReleaseReference(); } }