From d74b77331a83d34262eddce736da163db91cf4e0 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 9 Jan 2019 19:45:58 +0000 Subject: Gem d136736e8da1d549bd8f44bb50c26fc98f76f776 osx/x86_64 built 'master:d136736e8da1d549bd8f44bb50c26fc98f76f776' for osx/x86_64 --- Gem/develop/include/Gem/Base/GemBase.h | 1 - Gem/develop/include/Gem/Base/GemPixObj.h | 6 +- Gem/develop/include/Gem/Base/GemShape.h | 1 + Gem/develop/include/Gem/Base/TextBase.h | 1 + Gem/develop/include/Gem/Gem/Image.h | 127 +++++++++++++++-------------- Gem/develop/include/Gem/Gem/State.h | 5 +- Gem/develop/include/Gem/Utils/any.h | 20 +++-- Gem/develop/include/Gem/Utils/is_pointer.h | 34 ++++++++ 8 files changed, 121 insertions(+), 74 deletions(-) create mode 100644 Gem/develop/include/Gem/Utils/is_pointer.h (limited to 'Gem/develop') diff --git a/Gem/develop/include/Gem/Base/GemBase.h b/Gem/develop/include/Gem/Base/GemBase.h index 8ff4678..cc752d5 100644 --- a/Gem/develop/include/Gem/Base/GemBase.h +++ b/Gem/develop/include/Gem/Base/GemBase.h @@ -15,7 +15,6 @@ #ifndef _INCLUDE__GEM_BASE_GEMBASE_H_ #define _INCLUDE__GEM_BASE_GEMBASE_H_ -#include "Gem/GemGL.h" #include "Gem/ContextData.h" #include "Base/CPPExtern.h" diff --git a/Gem/develop/include/Gem/Base/GemPixObj.h b/Gem/develop/include/Gem/Base/GemPixObj.h index b6a4076..e9a4f9b 100644 --- a/Gem/develop/include/Gem/Base/GemPixObj.h +++ b/Gem/develop/include/Gem/Base/GemPixObj.h @@ -18,9 +18,9 @@ LOG #include "Base/GemBase.h" #include "Gem/Image.h" #include "Gem/Rectangle.h" -#include "stdlib.h" -#include "string.h" -#include "math.h" +#include +#include +#include /*----------------------------------------------------------------- ------------------------------------------------------------------- diff --git a/Gem/develop/include/Gem/Base/GemShape.h b/Gem/develop/include/Gem/Base/GemShape.h index 47395c2..d990a63 100644 --- a/Gem/develop/include/Gem/Base/GemShape.h +++ b/Gem/develop/include/Gem/Base/GemShape.h @@ -16,6 +16,7 @@ #define _INCLUDE__GEM_BASE_GEMSHAPE_H_ #include "Base/GemBase.h" +#include "Gem/GemGL.h" #include /*----------------------------------------------------------------- ------------------------------------------------------------------- diff --git a/Gem/develop/include/Gem/Base/TextBase.h b/Gem/develop/include/Gem/Base/TextBase.h index 7c6b832..4c10cb7 100644 --- a/Gem/develop/include/Gem/Base/TextBase.h +++ b/Gem/develop/include/Gem/Base/TextBase.h @@ -26,6 +26,7 @@ #include "RTE/Outlet.h" #include "Base/GemBase.h" +#include "Gem/GemGL.h" #include #include diff --git a/Gem/develop/include/Gem/Gem/Image.h b/Gem/develop/include/Gem/Gem/Image.h index bf61aef..c0b6eda 100644 --- a/Gem/develop/include/Gem/Gem/Image.h +++ b/Gem/develop/include/Gem/Gem/Image.h @@ -8,7 +8,7 @@ LOG Copyright (c) 1997-1999 Mark Danks. mark@danks.org Copyright (c) Günther Geiger. geiger@epy.co.at - Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at + Copyright (c) 2001-2019 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. @@ -17,10 +17,9 @@ LOG #ifndef _INCLUDE__GEM_GEM_IMAGE_H_ #define _INCLUDE__GEM_GEM_IMAGE_H_ -#include "Gem/GemGL.h" - #include #include +#include "Gem/ExportDef.h" /////////////////////////////////////////////////////////////////////////////// // Color component defines @@ -28,29 +27,33 @@ LOG // These should be used to reference the various color channels /////////////////////////////////////////////////////////////////////////////// -/* RGBA */ - -#if GL_RGBA_GEM == GL_RGBA -const int chRed = 0; -const int chGreen = 1; -const int chBlue = 2; -const int chAlpha = 3; -#else -const int chAlpha = 0; -const int chRed = 1; -const int chGreen = 2; -const int chBlue = 3; +/* RGBA: on Apple this is really BGRA_EXT */ +#ifndef __APPLE__ +# define GEM_RGBA 0x1908 +const int chRed = 0; +const int chGreen = 1; +const int chBlue = 2; +const int chAlpha = 3; +#else /* APPLE */ +# define GEM_RGBA 0x80E1 +const int chAlpha = 0; +const int chRed = 1; +const int chGreen = 2; +const int chBlue = 3; #endif +#define GEM_RGB 0x1907 /* Gray */ -const int chGray = 0; +#define GEM_GRAY 0x1909 +const int chGray = 0; /* YUV422 */ -const int chU = 0; -const int chY0 = 1; -const int chV = 2; -const int chY1 = 3; +#define GEM_YUV 0x85B9 +const int chU = 0; +const int chY0 = 1; +const int chV = 2; +const int chY1 = 3; /*----------------------------------------------------------------- ------------------------------------------------------------------- @@ -86,23 +89,23 @@ struct GEM_EXTERN imageStruct { ////////// // dimensions of the image - GLint xsize; - GLint ysize; + int xsize; + int ysize; ////////// // (average) width of 1 pixel (LUMINANCE = 1, RGBA = 4, YUV = 2) - GLint csize; + int csize; ////////// // data type - always GL_UNSIGNED_BYTE (except for OS X) - GLenum type; + unsigned int type; ////////// // the format - either GL_RGBA, GL_LUMINANCE // or GL_YCBCR_422_GEM (which is on mac-computers GL_YCBCR_422_APPLE) - GLenum format; + unsigned int format; - ////////// + ///////// // is this owned by us (? what about underscores ?) int notowned; @@ -136,10 +139,10 @@ struct GEM_EXTERN imageStruct { ///////// // gets the color of a pixel - virtual void getRGB(int X, int Y, unsigned char*r, unsigned char*g, + virtual bool getRGB(int X, int Y, unsigned char*r, unsigned char*g, unsigned char*b, unsigned char*a=NULL) const; - virtual void getGrey(int X, int Y, unsigned char*g) const; - virtual void getYUV(int X, int Y, unsigned char*y, unsigned char*u, + virtual bool getGrey(int X, int Y, unsigned char*g) const; + virtual bool getYUV(int X, int Y, unsigned char*y, unsigned char*u, unsigned char*v) const; /* following will set the whole image-data to either black or white @@ -192,64 +195,64 @@ struct GEM_EXTERN imageStruct { * this is maybe not really clean (the meta-data is stored in the destination, * while the source has no meta-data of its own) */ - virtual void convertTo (imageStruct*to, GLenum dest_format=0) const; - virtual void convertFrom(const imageStruct*from, GLenum dest_format=0); - - virtual void fromRGB (const unsigned char* orgdata); - virtual void fromRGBA (const unsigned char* orgdata); - virtual void fromBGR (const unsigned char* orgdata); - virtual void fromBGRA (const unsigned char* orgdata); - virtual void fromRGB16 (const unsigned char* orgdata); - virtual void fromABGR (const unsigned char* orgdata); - virtual void fromARGB (const unsigned char* orgdata); - virtual void fromGray (const unsigned char* orgdata); - virtual void fromGray (short* orgdata); - virtual void fromUYVY (const unsigned char* orgdata); - virtual void fromYUY2 (const unsigned char* orgdata); // YUYV - virtual void fromYVYU (const unsigned char* orgdata); + virtual bool convertTo (imageStruct*to, unsigned int dest_format=0) const; + virtual bool convertFrom(const imageStruct*from, unsigned int dest_format=0); + + virtual bool fromRGB (const unsigned char* orgdata); + virtual bool fromRGBA (const unsigned char* orgdata); + virtual bool fromBGR (const unsigned char* orgdata); + virtual bool fromBGRA (const unsigned char* orgdata); + virtual bool fromRGB16 (const unsigned char* orgdata); + virtual bool fromABGR (const unsigned char* orgdata); + virtual bool fromARGB (const unsigned char* orgdata); + virtual bool fromGray (const unsigned char* orgdata); + virtual bool fromGray (const short* orgdata); + virtual bool fromUYVY (const unsigned char* orgdata); + virtual bool fromYUY2 (const unsigned char* orgdata); // YUYV + virtual bool fromYVYU (const unsigned char* orgdata); /* planar YUV420: this is rather generic and not really YV12 only */ - virtual void fromYV12 (const unsigned char* Y, const unsigned char*U, + virtual bool fromYV12 (const unsigned char* Y, const unsigned char*U, const unsigned char*V); /* assume that the planes are near each other: YVU */ - virtual void fromYV12 (const unsigned char* orgdata); + virtual bool fromYV12 (const unsigned char* orgdata); /* assume that the planes are near each other: YVU */ - virtual void fromYU12 (const unsigned char* orgdata); + virtual bool fromYU12 (const unsigned char* orgdata); /* overloading the above two in order to accept pdp YV12 packets */ - virtual void fromYV12 (const short* Y, const short*U, const short*V); - virtual void fromYV12 (const short* orgdata); + virtual bool fromYV12 (const short* Y, const short*U, const short*V); + virtual bool fromYV12 (const short* orgdata); /* aliases */ - virtual void fromYUV422 (const unsigned char* orgdata) + virtual bool fromYUV422 (const unsigned char* orgdata) { - fromUYVY(orgdata); + return fromUYVY(orgdata); } - virtual void fromYUV420P(const unsigned char* orgdata) + virtual bool fromYUV420P(const unsigned char* orgdata) { - fromYV12(orgdata); + return fromYV12(orgdata); } - virtual void fromYUV420P(const unsigned char*Y,const unsigned char*U, + virtual bool fromYUV420P(const unsigned char*Y,const unsigned char*U, const unsigned char*V) { - fromYV12(Y,U,V); + return fromYV12(Y,U,V); } // "data" points to the image. // the memory could(!) be reserved by this class or someone else // "notowned" should be set to "1", if "data" points to foreign memory // "data" is not freed directly, when the destructor is called - unsigned char *data; // the pointer to the data + unsigned char *data; // the pointer to the data private: // "pdata" is the private data, and is the memory reserved by this class // this data is freed when the destructor is called - unsigned char *pdata; + unsigned char *pdata; // "datasize" is the size of data reserved at "pdata" - size_t datasize; + size_t datasize; public: ////////// // true if the image is flipped horizontally (origin is upper-left) // false if the image is openGL-conformant (origin is lower-left) - GLboolean upsidedown; + bool upsidedown; /* make the image orientation openGL-conformant */ virtual void fixUpDown(void); @@ -270,17 +273,17 @@ struct GEM_EXTERN pixBlock { ////////// // the block's image - imageStruct image; + imageStruct image; ////////// // is this a newimage since last time? // ie, has it been refreshed - bool newimage; + bool newimage; ////////// // keeps track of when new films are loaded // useful for rectangle_textures on OSX - bool newfilm; + bool newfilm; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/Gem/develop/include/Gem/Gem/State.h b/Gem/develop/include/Gem/Gem/State.h index 173acf9..4273e46 100644 --- a/Gem/develop/include/Gem/Gem/State.h +++ b/Gem/develop/include/Gem/Gem/State.h @@ -208,7 +208,10 @@ public: // key not found return false; } - value=gem::any_cast(val); + if(_PIX == key) + value=gem::any_cast(val, true); + else + value=gem::any_cast(val); return true; } catch (gem::bad_any_cast&x) { ::verbose(3, "%s:%d [%s] %d :: %s", __FILE__, __LINE__, __FUNCTION__, key, diff --git a/Gem/develop/include/Gem/Utils/any.h b/Gem/develop/include/Gem/Utils/any.h index 0861e19..435f3a3 100644 --- a/Gem/develop/include/Gem/Utils/any.h +++ b/Gem/develop/include/Gem/Utils/any.h @@ -27,7 +27,9 @@ #include #include -//#define GEM_ANY_TYPEID_HACK +#include "is_pointer.h" + +//#define GEM_ANY_TYPEID_HACK 1 namespace gem { @@ -293,6 +295,11 @@ struct GEM_EXTERN any { { return (get_type() == typeid(T)); } + template + bool compatible(T&x) const + { + return compatible(); + } // implicit casting is disabled by default @@ -329,11 +336,10 @@ struct GEM_EXTERN any { }; // boost::any-like casting - template -T* any_cast(any* this_) +T* any_cast(any* this_, bool force) { - if (this_->get_type() != typeid(T)) { + if (!force && !this_->compatible()) { throw bad_any_cast(this_->get_type(), typeid(T)); } if (sizeof(T) <= sizeof(void*)) { @@ -346,13 +352,13 @@ T* any_cast(any* this_) template T const* any_cast(any const* this_) { - return any_cast(const_cast(this_)); + return any_cast(const_cast(this_), false); } template -T const& any_cast(any const& this_) +T const& any_cast(any const& this_, bool force_pointers=false) { - return *any_cast(const_cast(&this_)); + return *any_cast(const_cast(&this_), force_pointers && is_pointer()); } #ifdef GEM_INTERNAL // Note: The "unsafe" versions of any_cast are not part of the diff --git a/Gem/develop/include/Gem/Utils/is_pointer.h b/Gem/develop/include/Gem/Utils/is_pointer.h new file mode 100644 index 0000000..6c5cb16 --- /dev/null +++ b/Gem/develop/include/Gem/Utils/is_pointer.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2010 fredoverflow https://stackoverflow.com/a/3177723/1169096 + * Copyright © 2019 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at + */ + +#ifndef GEM_IS_POINTER_H_ +#define GEM_IS_POINTER_H_ + +namespace gem +{ + template + struct is_pointer_type + { + enum { value = false }; + }; + + template + struct is_pointer_type + { + enum { value = true }; + }; + + template + bool is_pointer(void) + { + return is_pointer_type::value; + } + template + bool is_pointer(const T&) + { + return is_pointer_type::value; + } +}; +#endif // GEM_IS_POITNER_H_ -- cgit v1.2.1