I didn't actually get anything done on Gash today, but I'll take this opportunity to write down my plans for the implementation of its deferred processing (also known as laziness) because it's getting a bit hard to handle when the plan is only in my head.
When the xGA resources are opened with FromFiles, the main file is carved up into chunks which are stored in the RawCompChunks list because they haven't been decompressed yet.
When the chunk data is requested via a call to DecompressChunk, a check is made for the presence of the decompressed version of that chunk. If it is present, that same MemoryStream is returned. If not, the version in RawCompChunks is decompressed, and the resulting MemoryStream is added to RawChunks. The extra compressed version in RawCompChunks is removed.
When an image resource is requested, a check is made for the presence of the fully parsed version of it in the appropriate field. If it's there, it is returned. If not, the decompressed chunk is acquired and then parsed; the result is added to the appropriate cache field and returned.
When a new image object is assigned into a NextGenGraphics property, it is added to the appropriate cache field.
When it's time to save the xGA resources with ToFiles, the equality of the decompression dictionary and standard recompression (null-effect) dictionary is checked. If they're the same, entries remaining in RawCompChunks can be directly copied into the output. If not, they must be decompressed. Every image object in the caches is then serialized into the appropriate binary form and placed into RawChunks. Every entry of RawChunks is then copied to the output.
No comments:
Post a Comment