From 422fadc829581055c4776614f7cffce670e51ab6 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 16 Aug 2007 14:40:03 +0000 Subject: [PATCH] Moved the dummy table local to the PicturePlayer::Play() function since, as Marcus pointed out, having it outside wasn't thread safe. Moved PicturePlayer into the BPrivate namespace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21982 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Shape.h | 3 +- headers/private/interface/PicturePlayer.h | 21 +++---- src/kits/interface/Picture.cpp | 2 +- src/kits/interface/PicturePlayer.cpp | 72 ++++++----------------- src/servers/app/ServerPicture.cpp | 2 +- 5 files changed, 30 insertions(+), 70 deletions(-) diff --git a/headers/os/interface/Shape.h b/headers/os/interface/Shape.h index 65aa277147..0d275ceba9 100644 --- a/headers/os/interface/Shape.h +++ b/headers/os/interface/Shape.h @@ -11,6 +11,7 @@ namespace BPrivate { class ServerLink; + class PicturePlayer; }; @@ -75,9 +76,9 @@ virtual void _ReservedShape3(); virtual void _ReservedShape4(); friend class BShapeIterator; - friend class PicturePlayer; friend class BView; friend class BFont; + friend class BPrivate::PicturePlayer; friend class BPrivate::ServerLink; void GetData(int32 *opCount, int32 *ptCount, uint32 **opList, BPoint **ptList); diff --git a/headers/private/interface/PicturePlayer.h b/headers/private/interface/PicturePlayer.h index 5cfa47ed41..42929b151d 100644 --- a/headers/private/interface/PicturePlayer.h +++ b/headers/private/interface/PicturePlayer.h @@ -4,14 +4,14 @@ * * Authors: * Marc Flerackers (mflerackers@androme.be) - * Stefano Ceccherini (burton666@libero.it) + * Stefano Ceccherini (stefano.ceccherini@gmail.com) * Marcus Overhagen (marcus@overhagen.de) */ /** PicturePlayer is used to play picture data. */ -#ifndef _TPICTURE_H -#define _TPICTURE_H +#ifndef _PICTUREPLAYER_H +#define _PICTUREPLAYER_H #include @@ -20,21 +20,14 @@ #include +namespace BPrivate { + class PicturePlayer { public: PicturePlayer(); PicturePlayer(const void *data, size_t size, BList *pictures); virtual ~PicturePlayer(); - void BeginOp(int32); - void EndOp(); - - void EnterStateChange(); - void ExitStateChange(); - - void EnterFontChange(); - void ExitFontChange(); - status_t Play(void **callBackTable, int32 tableEntries, void *userData); @@ -44,4 +37,6 @@ private: BList *fPictures; }; -#endif // _TPICTURE_H +}; // namespace BPrivate + +#endif // _PICTUREPLAYER_H diff --git a/src/kits/interface/Picture.cpp b/src/kits/interface/Picture.cpp index 171caebd5f..9eed461cdd 100644 --- a/src/kits/interface/Picture.cpp +++ b/src/kits/interface/Picture.cpp @@ -252,7 +252,7 @@ BPicture::Play(void **callBackTable, int32 tableEntries, void *user) if (!_AssertLocalCopy()) return B_ERROR; - PicturePlayer player(extent->Data(), extent->Size(), extent->Pictures()); + BPrivate::PicturePlayer player(extent->Data(), extent->Size(), extent->Pictures()); return player.Play(callBackTable, tableEntries, user); } diff --git a/src/kits/interface/PicturePlayer.cpp b/src/kits/interface/PicturePlayer.cpp index 3e32283f63..6bf55b2a02 100644 --- a/src/kits/interface/PicturePlayer.cpp +++ b/src/kits/interface/PicturePlayer.cpp @@ -18,6 +18,8 @@ #include +using BPrivate::PicturePlayer; + typedef void (*fnc)(void*); typedef void (*fnc_BPoint)(void*, BPoint); typedef void (*fnc_BPointBPoint)(void*, BPoint, BPoint); @@ -49,59 +51,6 @@ nop() } -static void * -kDummyTable[kOpsTableSize] = { - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop, - (void *)nop -}; - - #if DEBUG static const char * PictureOpToString(int op) @@ -193,11 +142,26 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData) // If the caller supplied a function table smaller than needed, // we use our dummy table, and copy the supported ops from the supplied one. void **functionTable = callBackTable; + void *dummyTable[kOpsTableSize] = { + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop, + (void *)nop, (void *)nop, (void *)nop, (void *)nop + }; + if ((uint32)tableEntries < kOpsTableSize) { #if DEBUG fprintf(file, "A smaller than needed function table was supplied.\n"); #endif - functionTable = kDummyTable; + functionTable = dummyTable; memcpy(functionTable, callBackTable, (kOpsTableSize - tableEntries) * sizeof(void *)); } diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index a9587fca29..00b1b64143 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -908,7 +908,7 @@ ServerPicture::Play(ViewLayer *view) if (mallocIO == NULL) return; - PicturePlayer player(mallocIO->Buffer(), mallocIO->BufferLength(), fPictures); + BPrivate::PicturePlayer player(mallocIO->Buffer(), mallocIO->BufferLength(), fPictures); player.Play(const_cast(kTableEntries), sizeof(kTableEntries) / sizeof(void *), view); }