drawstyleHandlesRefCounts.clear(); // remove all references
- map<void *,ImageIndex>::iterator mitty=monobitmaps.begin();
+ map<void *,VectorHandleImage>::iterator mitty=monobitmaps.begin();
while (mitty!=monobitmaps.end()) {
vgDestroyImage((VGImage)(*mitty).second);
mitty++;
}
monobitmaps.clear();
- / *map<string,ImageIndex>::iterator jitty=jpegs.begin();
+ / *map<string,VectorHandleImage>::iterator jitty=jpegs.begin();
while (jitty!=jpegs.end()) {
vgDestroyImage((VGImage)(*jitty).second);
jitty++;
}
jpegs.clear();* /
- map<TVMediaInfo,ImageIndex>::iterator titty=tvmedias.begin();
+ map<TVMediaInfo,VectorHandleImage>::iterator titty=tvmedias.begin();
while (titty!=tvmedias.end()) {
vgDestroyImage((VGImage)(*titty).second);
titty++;
return 0;
}
-void OsdOpenVG::destroyImageRef(ImageIndex index)
+void OsdOpenVG::destroyImageRef(VectorHandleImage handle)
{
struct OpenVGCommand comm;
comm.task = OVGdestroyImageRef;
- comm.param1 = index;
+ comm.param1 = handle;
putOpenVGCommand(comm, false);
}
return putOpenVGCommand(comm, true);
}
-ImageIndex OsdOpenVG::createMonoBitmap(void* base, int width, int height)
+VectorHandleImage OsdOpenVG::createMonoBitmap(void* base, int width, int height)
{
struct OpenVGCommand comm;
comm.task = OVGcreateMonoBitmap;
return putOpenVGCommand(comm, true);
}
-ImageIndex OsdOpenVG::createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data)
+VectorHandleImage OsdOpenVG::createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data)
{
struct OpenVGCommand comm;
comm.task = OVGcreateImagePalette;
void doRender();
/*osd vector implementation*/
- void destroyImageRef(ImageIndex index);
- // ImageIndex createJpeg(const char* fileName, int *width,int *height);
- ImageIndex createMonoBitmap(void* base, int width, int height);
- ImageIndex createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data);
+ void destroyImageRef(VectorHandleImage handle);
+ // VectorHandleImage createJpeg(const char* fileName, int *width,int *height);
+ VectorHandleImage createMonoBitmap(void* base, int width, int height);
+ VectorHandleImage createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data);
void createPicture(struct PictureInfo& pict_inf);
void destroyDrawStyleHandle(VectorHandle index);
VectorHandle createDrawStyleHandle(const DrawStyle& c);
if (handle != 0) // command might not have a handle
decrementDrawStyleHandleRefCount(handle);
- ImageIndex ii = command.getImageIndex();
- if (ii) removeImageRef(ii);
+ VectorHandleImage imageHandle = command.getImageHandle();
+ if (imageHandle) removeImageRef(imageHandle);
LoadIndex li = command.getLoadIndex();
if (li) removeLoadIndexRef(li);
if (handle != 0) // command might not have a handle
incrementDrawStyleHandleRefCount(handle);
- ImageIndex ii = command.getImageIndex();
- if (ii) incImageRef(ii);
+ VectorHandleImage imageHandle = command.getImageHandle();
+ if (imageHandle) incImageRef(imageHandle);
LoadIndex li = command.getLoadIndex();
if (li) incLoadIndexRef(li);
}
}
-void OsdVector::incImageRef(ImageIndex index)
+void OsdVector::incImageRef(VectorHandleImage handle)
{
- if (images_ref.find(index) == images_ref.end())
+ if (images_ref.find(handle) == images_ref.end())
{
- images_ref[index] = 1;
+ images_ref[handle] = 1;
}
else
{
- images_ref[index]++;
+ images_ref[handle]++;
}
}
-void OsdVector::removeImageRef(const ImageIndex ref)
+void OsdVector::removeImageRef(const VectorHandleImage handle)
{
- images_ref[ref]--;
+ images_ref[handle]--;
}
int OsdVector::getLoadIndexRef(LoadIndex index)
if (loadindex_ref[ref] == 0)
{
//now check, if it is already loaded
- std::map<LoadIndex, ImageIndex>::iterator itty = tvmedias_loaded.find(ref);
+ std::map<LoadIndex, VectorHandleImage>::iterator itty = tvmedias_loaded.find(ref);
if ( itty != tvmedias_loaded.end())
{
{
// Do some garbage collection
- std::map<void*, ImageIndex>::iterator mitty = monobitmaps.begin();
+ std::map<void*, VectorHandleImage>::iterator mitty = monobitmaps.begin();
while (mitty != monobitmaps.end())
{
- std::map<ImageIndex, int>::iterator curitty = images_ref.find((*mitty).second);
+ std::map<VectorHandleImage, int>::iterator curitty = images_ref.find((*mitty).second);
int count = (*curitty).second;
if (count == 0)
{
- ImageIndex ref = (*curitty).first;
+ VectorHandleImage handle = (*curitty).first;
monobitmaps.erase(mitty++);
images_ref.erase(curitty++);
- destroyImageRef(ref);
+ destroyImageRef(handle);
}
else ++mitty;
}
- /*map<string,ImageIndex>::iterator jitty=jpegs.begin();
+ /*map<string,VectorHandleImage>::iterator jitty=jpegs.begin();
while (jitty!=jpegs.end()) {
- map<ImageIndex,int>::iterator curitty=images_ref.find((*jitty).second);
+ map<VectorHandleImage,int>::iterator curitty=images_ref.find((*jitty).second);
int count=(*curitty).second;
if (count==0) {
- ImageIndex ref=(*curitty).first;
+ VectorHandleImage handle=(*curitty).first;
jpegs.erase(jitty++);
images_ref.erase(curitty++);
- destroyImageRef(ref);
+ destroyImageRef(handle);
} else ++jitty;
}*/
- std::map<TVMediaInfo, ImageIndex>::iterator titty = tvmedias.begin();
+ std::map<TVMediaInfo, VectorHandleImage>::iterator titty = tvmedias.begin();
while (titty != tvmedias.end())
{
- std::map<ImageIndex, int>::iterator curitty = images_ref.find((*titty).second);
+ std::map<VectorHandleImage, int>::iterator curitty = images_ref.find((*titty).second);
int count = (*curitty).second;
if (count == 0)
{
- ImageIndex ref = (*curitty).first;
+ VectorHandleImage handle = (*curitty).first;
tvmedias.erase(titty++);
images_ref.erase(curitty);
- destroyImageRef(ref);
+ destroyImageRef(handle);
}
else ++titty;
}
else ++litty;
}
- std::list<ImageIndex>::iterator pitty = palettepics.begin();
+ std::list<VectorHandleImage>::iterator pitty = palettepics.begin();
while (pitty != palettepics.end())
{
- std::map<ImageIndex, int>::iterator curitty = images_ref.find((*pitty));
+ std::map<VectorHandleImage, int>::iterator curitty = images_ref.find((*pitty));
int count = (*curitty).second;
if (count == 0)
{
- ImageIndex ref = (*curitty).first;
+ VectorHandleImage handle = (*curitty).first;
palettepics.erase(pitty++);
images_ref.erase(curitty++);
- destroyImageRef(ref);
+ destroyImageRef(handle);
}
else ++pitty;
}
- std::map<ImageIndex, int>::iterator citty = images_ref.begin();
+ std::map<VectorHandleImage, int>::iterator citty = images_ref.begin();
while (citty != images_ref.end())
{
if (count == 0)
{
- ImageIndex ref = (*citty).first;
+ VectorHandleImage handle = (*citty).first;
images_ref.erase(citty++);
- destroyImageRef(ref);
+ destroyImageRef(handle);
}
else ++citty;
}
}
}
-int OsdVector::getImageRef(ImageIndex index)
+int OsdVector::getImageRef(VectorHandleImage handle)
{
surfaces_mutex.lock();
- if (images_ref.find(index) == images_ref.end())
+ if (images_ref.find(handle) == images_ref.end())
{
return -1;
}
else
{
- return images_ref[index];
+ return images_ref[handle];
}
surfaces_mutex.unlock();
}
#endif
-LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, ImageIndex& image)
+LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, VectorHandleImage& handle)
{
- ImageIndex image_handle = 0;
+ VectorHandleImage localHandle = 0;
LoadIndex loadindex = 0;
surfaces_mutex.lock();
{
loadindex = loadTVMedia(tvmedia);
}
- else // if found, return a real imageIndex. incImageRef(image_handle). EXCEPT: If it's not found in images_ref (???) in which case do same as above.
+ else // if found, return a real imageIndex. incImageRef(localHandle). EXCEPT: If it's not found in images_ref (???) in which case do same as above.
{
- image_handle = tvmedias[tvmedia];
+ localHandle = tvmedias[tvmedia];
- if (images_ref.find(image_handle) == images_ref.end())
+ if (images_ref.find(localHandle) == images_ref.end())
{
//invalid handle recreate
loadindex = loadTVMedia(tvmedia);
- image_handle = 0;
+ localHandle = 0;
}
else
{
- incImageRef(image_handle);
+ incImageRef(localHandle);
}
}
/*tvmedias[tvmedia]=createTVMedia(tvmedia,width,height);
- incImageRef(image_handle);*/
- image = image_handle;
+ incImageRef(localHandle);*/
+ handle = localHandle;
surfaces_mutex.unlock();
return loadindex;
}
return index;
}
-void OsdVector::informPicture(LoadIndex index, ImageIndex imageIndex)
+void OsdVector::informPicture(LoadIndex index, VectorHandleImage handle)
{
//Beware for thread safety
- ImageIndex image_index = 0;
+ VectorHandleImage localHandle = 0;
- logger->debug(TAG, "TVMedia Picture for load-id {:#x} arrived index {:#x}", index, imageIndex);
+ logger->debug(TAG, "TVMedia Picture for load-id {:#x} arrived index {:#x}", index, handle);
surfaces_mutex.lock();
TVMediaInfo tvmedia = tvmedias_load_inv[index];
- if (imageIndex)
+ if (handle)
{
std::map<LoadIndex, int>::iterator itty = loadindex_ref.find(index);
- image_index = tvmedias[tvmedia] = imageIndex;
- tvmedias_loaded[index] = image_index;
+ localHandle = tvmedias[tvmedia] = handle;
+ tvmedias_loaded[index] = localHandle;
if (itty == loadindex_ref.end() || (*itty).second == 0)
{
// we do not want the picture anymore . Really...
// fill images_ref in to not irritate the garbage collector
- if (images_ref.find(image_index) == images_ref.end())
+ if (images_ref.find(localHandle) == images_ref.end())
{
- images_ref[image_index] = 0;
+ images_ref[localHandle] = 0;
}
}
else
{
- incImageRef(image_index); // hold one index until all loadings refs are gone;
+ incImageRef(localHandle); // hold one index until all loadings refs are gone;
}
}
case Message::NEW_PICTURE:
{
//logger->debug(TAG, "TVMedia NEW_PICTURE");
- informPicture(m->tag, reinterpret_cast<ImageIndex>(m->data));
+ informPicture(m->tag, reinterpret_cast<VectorHandleImage>(m->data));
break;
}
case Message::NEW_PICTURE_STATIC:
{
//logger->debug(TAG, "TVMedia NEW_PICTURE {:#x} {:#x}", m->tag, m->parameter);
- informPicture(static_cast<unsigned long long>(m->tag) << 32LL, reinterpret_cast<ImageIndex>(m->data));
+ informPicture(static_cast<unsigned long long>(m->tag) << 32LL, reinterpret_cast<VectorHandleImage>(m->data));
break;
}
}
}
/*
-ImageIndex OsdVector::getJpegRef(const char* fileName, int *width,int *height)
+VectorHandleImage OsdVector::getJpegRef(const char* fileName, int *width,int *height)
{
- ImageIndex image_handle=0;
+ VectorHandleImage image_handle=0;
if (jpegs.find(fileName)==jpegs.end())
{
image_handle=jpegs[fileName]=createJpeg(fileName,width,height);
}
*/
-ImageIndex OsdVector::getMonoBitmapRef(void* base, int width, int height)
+VectorHandleImage OsdVector::getMonoBitmapRef(void* base, int width, int height)
{
- ImageIndex image_handle;
+ VectorHandleImage image_handle;
surfaces_mutex.lock();
if (monobitmaps.find(base) == monobitmaps.end())
return image_handle;
}
-ImageIndex OsdVector::getImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data)
+VectorHandleImage OsdVector::getImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data)
{
- ImageIndex image_handle;
+ VectorHandleImage image_handle;
image_handle = createImagePalette(width, height, image_data, palette_data);
surfaces_mutex.lock();
palettepics.push_back(image_handle);
TopLeftLimited
};
-typedef VectorHandle ImageIndex;
+typedef VectorHandle VectorHandleImage;
typedef unsigned long long LoadIndex;
class SVGCommand
return nc;
};
- inline static SVGCommand PaintImage(float ix, float iy, float iw, float ih, ImageIndex image_in, VectorHandle ref, Corner corner = TopLeft)
+ inline static SVGCommand PaintImage(float ix, float iy, float iw, float ih, VectorHandleImage handle, VectorHandle ref, Corner corner = TopLeft)
{
SVGCommand nc;
nc.instr = DrawImage;
nc.y = iy;
nc.w = iw;
nc.h = ih;
- nc.target.image = image_in;
+ nc.target.image = handle;
nc.handle = ref; // can be 0 (no handle) or can be an Drawstyle nandle
nc.corner = corner;
return nc;
return handle;
};
- ImageIndex getImageIndex()
+ VectorHandleImage getImageHandle()
{
if (instr != DrawImage) return 0;
else return target.image;
{
PathIndex path_index;
wchar_t textchar;
- ImageIndex image;
+ VectorHandleImage image;
unsigned int ttchar;
LoadIndex loadindex;
} target;
virtual float getCharWidth(wchar_t c) = 0;
float* getCharWidthArray() {return byte_char_width;};
- //virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);
- virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia, ImageIndex& image);
- virtual ImageIndex getMonoBitmapRef(void* base, int width, int height);
- virtual ImageIndex getImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data);
+ //virtual VectorHandleImage getJpegRef(const char* fileName, int *width,int *height);
+ virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia, VectorHandleImage& handle);
+ virtual VectorHandleImage getMonoBitmapRef(void* base, int width, int height);
+ virtual VectorHandleImage getImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data);
virtual bool getStaticImageData(unsigned int static_id, UCHAR** userdata, ULONG* length) = 0;
- void removeImageRef(const ImageIndex ref);
+ void removeImageRef(const VectorHandleImage ref);
void removeLoadIndexRef(const LoadIndex ref);
VectorHandle getDrawStyleHandle(const DrawStyle& c);
virtual void decrementDrawStyleHandleRefCount(VectorHandle ref);
virtual void getRealScreenSize(int& width, int& height) = 0;
// should be only called from control thread
- void informPicture(LoadIndex index, ImageIndex i_index);
+ void informPicture(LoadIndex index, VectorHandleImage handle);
void processMessage(Message* m);
PictureReader reader;
- std::map<ImageIndex, int> images_ref;
- std::map<void*, ImageIndex> monobitmaps;
- //map<string,ImageIndex> jpegs;
- std::map<TVMediaInfo, ImageIndex> tvmedias;
- std::list<ImageIndex> palettepics;
+ std::map<VectorHandleImage, int> images_ref;
+ std::map<void*, VectorHandleImage> monobitmaps;
+ //map<string,VectorHandleImage> jpegs;
+ std::map<TVMediaInfo, VectorHandleImage> tvmedias;
+ std::list<VectorHandleImage> palettepics;
std::map<LoadIndex, int> loadindex_ref;
std::map<TVMediaInfo, LoadIndex> tvmedias_load;
std::map<LoadIndex, TVMediaInfo> tvmedias_load_inv;
- std::map<LoadIndex, ImageIndex> tvmedias_loaded;
+ std::map<LoadIndex, VectorHandleImage> tvmedias_loaded;
std::map<DrawStyle, VectorHandle> drawstyleHandles;
std::map<DrawStyle, VectorHandle>::iterator drawstyleHandles_lastit;
float byte_char_width[256]{};
- void incImageRef(ImageIndex index);
- int getImageRef(ImageIndex index);
- virtual void destroyImageRef(ImageIndex index) = 0;
+ void incImageRef(VectorHandleImage handle);
+ int getImageRef(VectorHandleImage handle);
+ virtual void destroyImageRef(VectorHandleImage handle) = 0;
void incLoadIndexRef(LoadIndex index);
int getLoadIndexRef(LoadIndex index);
- //virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;
- virtual ImageIndex createMonoBitmap(void* base, int width, int height) = 0;
- virtual ImageIndex createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data) = 0;
+ //virtual VectorHandleImage createJpeg(const char* fileName, int *width,int *height)=0;
+ virtual VectorHandleImage createMonoBitmap(void* base, int width, int height) = 0;
+ virtual VectorHandleImage createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data) = 0;
virtual void createPicture(struct PictureInfo& pict_inf) = 0;
virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia);
-void OsdWinVector::destroyImageRef(ImageIndex index)
+void OsdWinVector::destroyImageRef(VectorHandleImage handle)
{
- ID2D1Bitmap* bitmap = (ID2D1Bitmap*)index;
+ ID2D1Bitmap* bitmap = (ID2D1Bitmap*)handle;
if (bitmap) bitmap->Release();
}
}
-ImageIndex OsdWinVector::createMonoBitmap(void *base, int width, int height)
+VectorHandleImage OsdWinVector::createMonoBitmap(void *base, int width, int height)
{
// First we have to convert it to 8 bit alpha, we could use WIC but actually writing this code is not hard to port from base class
}
-ImageIndex OsdWinVector::createImagePalette(int width, int height, const unsigned char *image_data, const unsigned int*palette_data)
+VectorHandleImage OsdWinVector::createImagePalette(int width, int height, const unsigned char *image_data, const unsigned int*palette_data)
{
// First we have to convert it to 32 bit RGBA, we could use WIC but actually writing this code is not hard to port from base class
void getTextureCoordinates(FLOAT*, FLOAT*);
/*osd vector implementation*/
- void destroyImageRef(ImageIndex index);
- ImageIndex createMonoBitmap(void *base, int width, int height);
- ImageIndex createImagePalette(int width, int height, const unsigned char *image_data, const unsigned int*palette_data);
+ void destroyImageRef(VectorHandleImage index);
+ VectorHandleImage createMonoBitmap(void *base, int width, int height);
+ VectorHandleImage createImagePalette(int width, int height, const unsigned char *image_data, const unsigned int*palette_data);
void createPicture(struct PictureInfo& pict_inf);
void destroyDrawStyleHandle(VectorHandle index);
VectorHandle createDrawStyleHandle(const DrawStyle &c);
{
osd->decrementDrawStyleHandleRefCount(command.getHandle()); // We remove the Style reference, so that osd can free stuff // FIXME BUG BUG BUG
- ImageIndex ii = command.getImageIndex();
- if (ii) osd->removeImageRef(ii);
+ VectorHandleImage handle = command.getImageHandle();
+ if (handle) osd->removeImageRef(handle);
LoadIndex li = command.getLoadIndex();
if (li) osd->removeLoadIndexRef(li);
void SurfaceVector::drawJpeg(const char *fileName,int x, int y,int *width, int *height)
{
command_mutex.lock();
- ImageIndex image=osd->getJpegRef(fileName,width,height);
- commands.push_back(SVGCommand::PaintImage(x,y,*width,*height,image,0));
+ VectorHandleImage handle=osd->getJpegRef(fileName,width,height);
+ commands.push_back(SVGCommand::PaintImage(x,y,*width,*height,handle,0));
command_mutex.unlock();
}
*/
void SurfaceVector::drawTVMedia(TVMediaInfo& tvmedia, float x, float y, float width, float height, Corner corner)
{
command_mutex.lock();
- ImageIndex image = 0;
- LoadIndex load_index = osd->getTVMediaRef(tvmedia, image);
+ VectorHandleImage handle = 0;
+ LoadIndex load_index = osd->getTVMediaRef(tvmedia, handle);
if (width != 0 && height != 0)
{
removeCommands(x, y, width, height);
}
- if (image)
+ if (handle)
{
- logger->trace(TAG, "drawTVMedia: i=true, Add instr PaintImage load_index={} image={}", load_index, image);
- commands.push_back(SVGCommand::PaintImage(x, y, width, height, image, 0, corner));
+ logger->trace(TAG, "drawTVMedia: i=true, Add instr PaintImage load_index={} handle={}", load_index, handle);
+ commands.push_back(SVGCommand::PaintImage(x, y, width, height, handle, 0, corner));
}
else
{
- logger->trace(TAG, "drawTVMedia: i=false, Add instr PaintImageLoading {} {}", load_index, image);
+ logger->trace(TAG, "drawTVMedia: i=false, Add instr PaintImageLoading {} {}", load_index, handle);
commands.push_back(SVGCommand::PaintImageLoading(load_index, x, y, width, height, corner));
}
data[i+j*bm.getHeight()]=bm.getColour(i,j);
}
}*/
- ImageIndex image = osd->getImagePalette(bm.getWidth(), bm.getHeight(), &(bm.rawData()[0]),
+ VectorHandleImage handle = osd->getImagePalette(bm.getWidth(), bm.getHeight(), &(bm.rawData()[0]),
(const unsigned int*)&bm.palette.getColourVector()[0]); // data is freed by the OSD
//free(data);
float tx = x + region.windowx;
ty *= scaley;
tw *= scalex;
th *= scaley;
- SVGCommand temp = SVGCommand::PaintImage(tx, ty, tw, th, image, 0);
+ SVGCommand temp = SVGCommand::PaintImage(tx, ty, tw, th, handle, 0);
removeCommands(tx, ty, tw, th);
commands.push_back(temp);
command_mutex.unlock();
void SurfaceVector::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, unsigned int width, const DrawStyle& nextColour)
{
command_mutex.lock();
- ImageIndex image = osd->getMonoBitmapRef(base, width, height);
+ VectorHandleImage handle = osd->getMonoBitmapRef(base, width, height);
VectorHandle ref = osd->getDrawStyleHandle(nextColour);
removeCommands(dx, dy, width, height);
- commands.push_back(SVGCommand::PaintImage(dx, dy, height, width, image, ref)); // FIXME BUG height and width wrong way around?
+ commands.push_back(SVGCommand::PaintImage(dx, dy, height, width, handle, ref)); // FIXME BUG height and width wrong way around?
command_mutex.unlock();
}
//Log::getInstance()->log("OSD", Log::DEBUG, "Remove command %d %g %g %g %g %d %d",(*itty).instr,
//(*itty).x,(*itty).y,(*itty).w,(*itty).h,(*itty).handle,(*itty).target.image);
osd->decrementDrawStyleHandleRefCount((*itty).getHandle()); // We remove the Style reference, so that osd can free stuff // FIXME BUG BUG BUG
- ImageIndex ii = (*itty).getImageIndex();
+ VectorHandleImage handle = (*itty).getImageHandle();
- if (ii) osd->removeImageRef(ii);
+ if (handle) osd->removeImageRef(handle);
LoadIndex li = (*itty).getLoadIndex();