< prev index next >

src/java.desktop/share/native/liblcms/lcms2_internal.h

Print this page

 271 // The trick here is that InitializeCriticalSection() is not allowed to fail. It tries
 272 // to allocate a critical section debug object, but if no memory is available, it sets
 273 // the pointer to a specific value. (One would expect that value to be NULL, but it is
 274 // actually (void *)-1 for some reason.) Thus we can use this special value for that
 275 // pointer, and the critical section code will work.
 276 
 277 // The other important part of the critical section type to initialize is the number
 278 // of waiters. This controls whether or not the mutex is locked. Fortunately, this
 279 // part of the critical section is unlikely to change. Apparently, many programs
 280 // already test critical sections to see if they are locked using this value, so
 281 // Microsoft felt that it was necessary to keep it set at -1 for an unlocked critical
 282 // section, even when they changed the underlying algorithm to be more scalable.
 283 // The final parts of the critical section object are unimportant, and can be set
 284 // to zero for their defaults. This yields to an initialization macro:
 285 
 286 typedef CRITICAL_SECTION _cmsMutex;
 287 
 288 #ifdef _MSC_VER
 289 #    if (_MSC_VER >= 1800)
 290 #          pragma warning(disable : 26135)

 291 #    endif
 292 #endif
 293 
 294 #ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
 295 // If we are building with a version of MSVC smaller
 296 // than 1400 (i.e. before VS2005) then we don't have
 297 // the InterlockedCompareExchangePointer API, so use
 298 // the old version.
 299 #    ifdef _MSC_VER
 300 #       if _MSC_VER < 1400
 301 #          define CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
 302 #       endif
 303 #    endif
 304 #endif
 305 
 306 #ifdef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
 307 #      define CMS_MUTEX_INITIALIZER {(PRTL_CRITICAL_SECTION_DEBUG) -1,-1,0,0,0,0}
 308 #else
 309 #      define CMS_MUTEX_INITIALIZER {(PRTL_CRITICAL_SECTION_DEBUG)NULL,-1,0,0,0,0}
 310 #endif

 528 typedef struct {
 529 
 530     _cmsMallocFnPtrType     MallocPtr;
 531     _cmsMalloZerocFnPtrType MallocZeroPtr;
 532     _cmsFreeFnPtrType       FreePtr;
 533     _cmsReallocFnPtrType    ReallocPtr;
 534     _cmsCallocFnPtrType     CallocPtr;
 535     _cmsDupFnPtrType        DupPtr;
 536 
 537 } _cmsMemPluginChunkType;
 538 
 539 // Copy memory management function pointers from plug-in to chunk, taking care of missing routines
 540 void  _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr);
 541 
 542 // Internal structure for context
 543 struct _cmsContext_struct {
 544 
 545     struct _cmsContext_struct* Next;  // Points to next context in the new style
 546     _cmsSubAllocator* MemPool;        // The memory pool that stores context data
 547 
 548     void* chunks[MemoryClientMax];    // array of pointers to client chunks. Memory itself is hold in the suballocator.
 549                                       // If NULL, then it reverts to global Context0
 550 
 551     _cmsMemPluginChunkType DefaultMemoryManager;  // The allocators used for creating the context itself. Cannot be overridden
 552 };
 553 
 554 // Returns a pointer to a valid context structure, including the global one if id is zero.
 555 // Verifies the magic number.
 556 struct _cmsContext_struct* _cmsGetContext(cmsContext ContextID);
 557 
 558 // Returns the block assigned to the specific zone.
 559 void*     _cmsContextGetClientChunk(cmsContext id, _cmsMemoryClient mc);
 560 
 561 
 562 // Chunks of context memory by plug-in client -------------------------------------------------------
 563 
 564 // Those structures encapsulates all variables needed by the several context clients (mostly plug-ins)
 565 
 566 // Container for error logger -- not a plug-in
 567 typedef struct {
 568 

 822 
 823 
 824 // ----------------------------------------------------------------------------------
 825 
 826 // This is the internal struct holding profile details.
 827 
 828 // Maximum supported tags in a profile
 829 #define MAX_TABLE_TAG       100
 830 
 831 typedef struct _cms_iccprofile_struct {
 832 
 833     // I/O handler
 834     cmsIOHANDLER*            IOhandler;
 835 
 836     // The thread ID
 837     cmsContext               ContextID;
 838 
 839     // Creation time
 840     struct tm                Created;
 841 



 842     // Only most important items found in ICC profiles
 843     cmsUInt32Number          Version;
 844     cmsProfileClassSignature DeviceClass;
 845     cmsColorSpaceSignature   ColorSpace;
 846     cmsColorSpaceSignature   PCS;
 847     cmsUInt32Number          RenderingIntent;
 848 

 849     cmsUInt32Number          flags;
 850     cmsUInt32Number          manufacturer, model;
 851     cmsUInt64Number          attributes;
 852     cmsUInt32Number          creator;
 853 
 854     cmsProfileID             ProfileID;
 855 
 856     // Dictionary
 857     cmsUInt32Number          TagCount;
 858     cmsTagSignature          TagNames[MAX_TABLE_TAG];
 859     cmsTagSignature          TagLinked[MAX_TABLE_TAG];           // The tag to which is linked (0=none)
 860     cmsUInt32Number          TagSizes[MAX_TABLE_TAG];            // Size on disk
 861     cmsUInt32Number          TagOffsets[MAX_TABLE_TAG];
 862     cmsBool                  TagSaveAsRaw[MAX_TABLE_TAG];        // True to write uncooked
 863     void *                   TagPtrs[MAX_TABLE_TAG];
 864     cmsTagTypeHandler*       TagTypeHandlers[MAX_TABLE_TAG];     // Same structure may be serialized on different types
 865                                                                  // depending on profile version, so we keep track of the
 866                                                                  // type handler for each tag in the list.
 867     // Special
 868     cmsBool                  IsWrite;

 271 // The trick here is that InitializeCriticalSection() is not allowed to fail. It tries
 272 // to allocate a critical section debug object, but if no memory is available, it sets
 273 // the pointer to a specific value. (One would expect that value to be NULL, but it is
 274 // actually (void *)-1 for some reason.) Thus we can use this special value for that
 275 // pointer, and the critical section code will work.
 276 
 277 // The other important part of the critical section type to initialize is the number
 278 // of waiters. This controls whether or not the mutex is locked. Fortunately, this
 279 // part of the critical section is unlikely to change. Apparently, many programs
 280 // already test critical sections to see if they are locked using this value, so
 281 // Microsoft felt that it was necessary to keep it set at -1 for an unlocked critical
 282 // section, even when they changed the underlying algorithm to be more scalable.
 283 // The final parts of the critical section object are unimportant, and can be set
 284 // to zero for their defaults. This yields to an initialization macro:
 285 
 286 typedef CRITICAL_SECTION _cmsMutex;
 287 
 288 #ifdef _MSC_VER
 289 #    if (_MSC_VER >= 1800)
 290 #          pragma warning(disable : 26135)
 291 #          pragma warning(disable : 4127)
 292 #    endif
 293 #endif
 294 
 295 #ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
 296 // If we are building with a version of MSVC smaller
 297 // than 1400 (i.e. before VS2005) then we don't have
 298 // the InterlockedCompareExchangePointer API, so use
 299 // the old version.
 300 #    ifdef _MSC_VER
 301 #       if _MSC_VER < 1400
 302 #          define CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
 303 #       endif
 304 #    endif
 305 #endif
 306 
 307 #ifdef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
 308 #      define CMS_MUTEX_INITIALIZER {(PRTL_CRITICAL_SECTION_DEBUG) -1,-1,0,0,0,0}
 309 #else
 310 #      define CMS_MUTEX_INITIALIZER {(PRTL_CRITICAL_SECTION_DEBUG)NULL,-1,0,0,0,0}
 311 #endif

 529 typedef struct {
 530 
 531     _cmsMallocFnPtrType     MallocPtr;
 532     _cmsMalloZerocFnPtrType MallocZeroPtr;
 533     _cmsFreeFnPtrType       FreePtr;
 534     _cmsReallocFnPtrType    ReallocPtr;
 535     _cmsCallocFnPtrType     CallocPtr;
 536     _cmsDupFnPtrType        DupPtr;
 537 
 538 } _cmsMemPluginChunkType;
 539 
 540 // Copy memory management function pointers from plug-in to chunk, taking care of missing routines
 541 void  _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr);
 542 
 543 // Internal structure for context
 544 struct _cmsContext_struct {
 545 
 546     struct _cmsContext_struct* Next;  // Points to next context in the new style
 547     _cmsSubAllocator* MemPool;        // The memory pool that stores context data
 548 
 549     void* chunks[MemoryClientMax];    // array of pointers to client chunks. Memory itself is held in the suballocator.
 550                                       // If NULL, then it reverts to global Context0
 551 
 552     _cmsMemPluginChunkType DefaultMemoryManager;  // The allocators used for creating the context itself. Cannot be overridden
 553 };
 554 
 555 // Returns a pointer to a valid context structure, including the global one if id is zero.
 556 // Verifies the magic number.
 557 struct _cmsContext_struct* _cmsGetContext(cmsContext ContextID);
 558 
 559 // Returns the block assigned to the specific zone.
 560 void*     _cmsContextGetClientChunk(cmsContext id, _cmsMemoryClient mc);
 561 
 562 
 563 // Chunks of context memory by plug-in client -------------------------------------------------------
 564 
 565 // Those structures encapsulates all variables needed by the several context clients (mostly plug-ins)
 566 
 567 // Container for error logger -- not a plug-in
 568 typedef struct {
 569 

 823 
 824 
 825 // ----------------------------------------------------------------------------------
 826 
 827 // This is the internal struct holding profile details.
 828 
 829 // Maximum supported tags in a profile
 830 #define MAX_TABLE_TAG       100
 831 
 832 typedef struct _cms_iccprofile_struct {
 833 
 834     // I/O handler
 835     cmsIOHANDLER*            IOhandler;
 836 
 837     // The thread ID
 838     cmsContext               ContextID;
 839 
 840     // Creation time
 841     struct tm                Created;
 842 
 843     // Color management module identification
 844     cmsUInt32Number          CMM;
 845 
 846     // Only most important items found in ICC profiles
 847     cmsUInt32Number          Version;
 848     cmsProfileClassSignature DeviceClass;
 849     cmsColorSpaceSignature   ColorSpace;
 850     cmsColorSpaceSignature   PCS;
 851     cmsUInt32Number          RenderingIntent;
 852 
 853     cmsPlatformSignature     platform;
 854     cmsUInt32Number          flags;
 855     cmsUInt32Number          manufacturer, model;
 856     cmsUInt64Number          attributes;
 857     cmsUInt32Number          creator;
 858 
 859     cmsProfileID             ProfileID;
 860 
 861     // Dictionary
 862     cmsUInt32Number          TagCount;
 863     cmsTagSignature          TagNames[MAX_TABLE_TAG];
 864     cmsTagSignature          TagLinked[MAX_TABLE_TAG];           // The tag to which is linked (0=none)
 865     cmsUInt32Number          TagSizes[MAX_TABLE_TAG];            // Size on disk
 866     cmsUInt32Number          TagOffsets[MAX_TABLE_TAG];
 867     cmsBool                  TagSaveAsRaw[MAX_TABLE_TAG];        // True to write uncooked
 868     void *                   TagPtrs[MAX_TABLE_TAG];
 869     cmsTagTypeHandler*       TagTypeHandlers[MAX_TABLE_TAG];     // Same structure may be serialized on different types
 870                                                                  // depending on profile version, so we keep track of the
 871                                                                  // type handler for each tag in the list.
 872     // Special
 873     cmsBool                  IsWrite;
< prev index next >