src/share/native/sun/java2d/cmm/lcms/cmsplugin.c

Print this page




 695 
 696     // On 0, use global settings
 697     if (id == NULL)
 698         return &globalContext;
 699 
 700     // Search
 701     for (ctx = _cmsContextPoolHead;
 702          ctx != NULL;
 703          ctx = ctx ->Next) {
 704 
 705             // Found it?
 706             if (id == ctx)
 707                 return ctx; // New-style context,
 708     }
 709 
 710     return &globalContext;
 711 }
 712 
 713 
 714 // Internal: get the memory area associanted with each context client
 715 // Returns the block assigned to the specific zone.
 716 void* _cmsContextGetClientChunk(cmsContext ContextID, _cmsMemoryClient mc)
 717 {
 718     struct _cmsContext_struct* ctx;
 719     void *ptr;
 720 
 721     if (mc < 0 || mc >= MemoryClientMax) {
 722         cmsSignalError(ContextID, cmsERROR_RANGE, "Bad context client");
 723         return NULL;






 724     }
 725 
 726     ctx = _cmsGetContext(ContextID);
 727     ptr = ctx ->chunks[mc];
 728 
 729     if (ptr != NULL)
 730         return ptr;
 731 
 732     // A null ptr means no special settings for that context, and this
 733     // reverts to Context0 globals
 734     return globalContext.chunks[mc];
 735 }
 736 
 737 
 738 // This function returns the given context its default pristine state,
 739 // as no plug-ins were declared. There is no way to unregister a single
 740 // plug-in, as a single call to cmsPluginTHR() function may register
 741 // many different plug-ins simultaneously, then there is no way to
 742 // identify which plug-in to unregister.
 743 void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID)


 892     _cmsAllocMPETypePluginChunk(ctx, src);
 893     _cmsAllocTagPluginChunk(ctx, src);
 894     _cmsAllocIntentsPluginChunk(ctx, src);
 895     _cmsAllocOptimizationPluginChunk(ctx, src);
 896     _cmsAllocTransformPluginChunk(ctx, src);
 897     _cmsAllocMutexPluginChunk(ctx, src);
 898 
 899     // Make sure no one failed
 900     for (i=Logger; i < MemoryClientMax; i++) {
 901 
 902         if (src ->chunks[i] == NULL) {
 903             cmsDeleteContext((cmsContext) ctx);
 904             return NULL;
 905         }
 906     }
 907 
 908     return (cmsContext) ctx;
 909 }
 910 
 911 
 912 
 913 static
 914 struct _cmsContext_struct* FindPrev(struct _cmsContext_struct* id)
 915 {
 916     struct _cmsContext_struct* prev;
 917 
 918     // Search for previous
 919     for (prev = _cmsContextPoolHead;
 920              prev != NULL;
 921              prev = prev ->Next)
 922     {
 923         if (prev ->Next == id)
 924             return prev;
 925     }
 926 
 927     return NULL;  // List is empty or only one element!
 928 }

 929 
 930 // Frees any resources associated with the given context,
 931 // and destroys the context placeholder.
 932 // The ContextID can no longer be used in any THR operation.
 933 void CMSEXPORT cmsDeleteContext(cmsContext ContextID)
 934 {
 935     if (ContextID != NULL) {
 936 
 937         struct _cmsContext_struct* ctx = (struct _cmsContext_struct*) ContextID;
 938         struct _cmsContext_struct  fakeContext;
 939         struct _cmsContext_struct* prev;
 940 
 941         memcpy(&fakeContext.DefaultMemoryManager, &ctx->DefaultMemoryManager, sizeof(ctx->DefaultMemoryManager));
 942 
 943         fakeContext.chunks[UserPtr]     = ctx ->chunks[UserPtr];
 944         fakeContext.chunks[MemPlugin]   = &fakeContext.DefaultMemoryManager;
 945 
 946         // Get rid of plugins
 947         cmsUnregisterPluginsTHR(ContextID);
 948 




 695 
 696     // On 0, use global settings
 697     if (id == NULL)
 698         return &globalContext;
 699 
 700     // Search
 701     for (ctx = _cmsContextPoolHead;
 702          ctx != NULL;
 703          ctx = ctx ->Next) {
 704 
 705             // Found it?
 706             if (id == ctx)
 707                 return ctx; // New-style context,
 708     }
 709 
 710     return &globalContext;
 711 }
 712 
 713 
 714 // Internal: get the memory area associanted with each context client
 715 // Returns the block assigned to the specific zone. Never return NULL.
 716 void* _cmsContextGetClientChunk(cmsContext ContextID, _cmsMemoryClient mc)
 717 {
 718     struct _cmsContext_struct* ctx;
 719     void *ptr;
 720 
 721     if ((int) mc < 0 || mc >= MemoryClientMax) {
 722 
 723            cmsSignalError(ContextID, cmsERROR_INTERNAL, "Bad context client -- possible corruption");
 724 
 725            // This is catastrophic. Should never reach here
 726            _cmsAssert(0);
 727 
 728            // Reverts to global context
 729            return globalContext.chunks[UserPtr];
 730     }
 731 
 732     ctx = _cmsGetContext(ContextID);
 733     ptr = ctx ->chunks[mc];
 734 
 735     if (ptr != NULL)
 736         return ptr;
 737 
 738     // A null ptr means no special settings for that context, and this
 739     // reverts to Context0 globals
 740     return globalContext.chunks[mc];
 741 }
 742 
 743 
 744 // This function returns the given context its default pristine state,
 745 // as no plug-ins were declared. There is no way to unregister a single
 746 // plug-in, as a single call to cmsPluginTHR() function may register
 747 // many different plug-ins simultaneously, then there is no way to
 748 // identify which plug-in to unregister.
 749 void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID)


 898     _cmsAllocMPETypePluginChunk(ctx, src);
 899     _cmsAllocTagPluginChunk(ctx, src);
 900     _cmsAllocIntentsPluginChunk(ctx, src);
 901     _cmsAllocOptimizationPluginChunk(ctx, src);
 902     _cmsAllocTransformPluginChunk(ctx, src);
 903     _cmsAllocMutexPluginChunk(ctx, src);
 904 
 905     // Make sure no one failed
 906     for (i=Logger; i < MemoryClientMax; i++) {
 907 
 908         if (src ->chunks[i] == NULL) {
 909             cmsDeleteContext((cmsContext) ctx);
 910             return NULL;
 911         }
 912     }
 913 
 914     return (cmsContext) ctx;
 915 }
 916 
 917 
 918 /*
 919 static
 920 struct _cmsContext_struct* FindPrev(struct _cmsContext_struct* id)
 921 {
 922     struct _cmsContext_struct* prev;
 923 
 924     // Search for previous
 925     for (prev = _cmsContextPoolHead;
 926              prev != NULL;
 927              prev = prev ->Next)
 928     {
 929         if (prev ->Next == id)
 930             return prev;
 931     }
 932 
 933     return NULL;  // List is empty or only one element!
 934 }
 935 */
 936 
 937 // Frees any resources associated with the given context,
 938 // and destroys the context placeholder.
 939 // The ContextID can no longer be used in any THR operation.
 940 void CMSEXPORT cmsDeleteContext(cmsContext ContextID)
 941 {
 942     if (ContextID != NULL) {
 943 
 944         struct _cmsContext_struct* ctx = (struct _cmsContext_struct*) ContextID;
 945         struct _cmsContext_struct  fakeContext;
 946         struct _cmsContext_struct* prev;
 947 
 948         memcpy(&fakeContext.DefaultMemoryManager, &ctx->DefaultMemoryManager, sizeof(ctx->DefaultMemoryManager));
 949 
 950         fakeContext.chunks[UserPtr]     = ctx ->chunks[UserPtr];
 951         fakeContext.chunks[MemPlugin]   = &fakeContext.DefaultMemoryManager;
 952 
 953         // Get rid of plugins
 954         cmsUnregisterPluginsTHR(ContextID);
 955