00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 00021 #ifndef SOCOLORPACKER_H 00022 #define SOCOLORPACKER_H 00023 00024 #include <Inventor/sys/port.h> 00025 #include <Inventor/SbBase.h> 00026 #include <Inventor/threads/SbThreadMutex.h> 00027 #include <Inventor/SbColor.h> 00028 00029 class SoCpuBufferObject; 00030 00032 // 00033 // Class: SoColorPacker 00034 // This class is meant to be used by all property nodes that set either 00035 // a diffuse color or transparency in the lazy element. It maintains 00036 // a cache of the current diffuse color and transparency in a packed 00037 // color array. 00039 00040 class SoColorPacker { 00041 00042 public: 00043 00044 //Constructor, makes a colorPacker with NULL packedColor pointer: 00045 SoColorPacker(); 00046 00047 // destructor, deletes packed color array 00048 ~SoColorPacker(); 00049 00054 uint32_t *getPackedColors() const { 00055 return packedColors; 00056 } 00057 SbBool diffuseMatch(uint64_t nodeId) { 00058 return (nodeId == diffuseNodeId); 00059 } 00060 SbBool transpMatch(uint64_t nodeId) { 00061 return (nodeId == transpNodeId); 00062 } 00063 void setNodeIds(uint64_t diffNodeId, uint64_t tNodeId) { 00064 diffuseNodeId = diffNodeId; 00065 transpNodeId = tNodeId; 00066 } 00067 int32_t getSize() { 00068 return packedArraySize; 00069 } 00070 void reallocate(int32_t size); 00071 00072 static void exitClass(); 00073 00074 private: 00076 static SoCpuBufferObject* convertBigEndianToSystem(SoCpuBufferObject* source); 00077 00079 static void packedColorBigEndianToSbColor(SbColor& result, const uint32_t packedColor); 00080 00081 private: 00082 00083 // nodeids are used for testing cache validity 00084 uint64_t transpNodeId; 00085 uint64_t diffuseNodeId; 00086 // array of packed colors, or NULL if empty 00087 uint32_t *packedColors; 00088 // size of packed color array (not necessarily number of valid colors) 00089 int32_t packedArraySize; 00090 00091 static SbThreadMutex *m_mutex; 00092 00093 }; 00094 00095 #endif 00096