I hope to understand the insides of the CoreFoundation CGColor object with this study. I could find a sample definition of the CGColor structure from a free quartz project that seems to be consistent with the IOS declaration (based on my research).
typedef struct CGColor { CFRuntimeBase obj; CFTypeID colorID; CGColorSpaceRef colorSpace; CGPatternRef pattern; size_t numberOfComponents; CGFloat *components; } *CGColorRef;
(the colorID field is called nextID free quartz, but I think it is intended as a unique identifier for color using IOS, so it is not a kind of next identifier.)
The global thread safe unique value uses the hold value, which is incremented by 1 for each CGColor object created and assigned to the colorID member. Only the undocumented function CGColorGetIdentifier () returns this value. (I have an assumption about a monotonous increase in the id value, this can improve performance when switching between a device in a calibrated color search or vice versa).
I checked CoreGraphics and its resource libraries. I found that only the ripc_GetColor function (libRIP.A.dylib) calls the CGColorGetIdentifier () function.
Call stack for CGColorGetIdentifier (hoping to help draw a conclusion about colorID)
0 com.apple.CoreGraphics CGColorGetIdentifier + 0 1 libRIP.A.dylib ripc_GetColor + 112 2 libRIP.A.dylib ripc_DrawGlyphs + 1740 3 com.apple.CoreGraphics CGContextDelegateDrawGlyphs + 108 4 com.apple.CoreGraphics drawGlyphs + 284 5 com.apple.CoreGraphics CGContextShowGlyphsWithAdvances + 208
For the current contextual color chart operation, ripc_GetColor () computes some transformations for the current hatch / fill color and caches these transformations using the reference and colorID of that color.
So, for the next graphic context operation, ripc_GetColor () compares the previously cached and current reference and colorID values ββto skip the color conversions that were already cached for the last graphic context operation.
We know that a link (memory address) of a selected object can be used when creating another object. Therefore, just checking the link will not be enough for the same color object to be valid, but we need to compare the contents or some kind of hash value. Thus, for this purpose, we could use unique identifier values.
However, an identifier can be used for a single object and its reference, so it is enough to compare only identifiers. But both refs and identifiers are used. I do not think that engineers have missed such a simple and important thing.
So, I'm trying to figure out the need to compare both identifiers and references, while comparing only identifiers will suffice.
Does this remain from the previous approach, so you can not completely abandon it?