-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for getting layer specific data. #3
Comments
Looking back at this old library, there are some decisions that I think I'd like to try and do to facilitate something like this without having to make redundant copies of raster data. Stuff like having it use memory-mapped-IO for read-only access since the code skips around pretty randomly around the file and the encryption allows for "pretty-random" access as well. And with a setup like that, there can be an API like |
So... a way to do this would be to have... class Layer
Then RasterLayer : public Layer
Mask : public Layer -- Are masks also 4 channel encoded, or are they single channel/gray?
LineWorkLayer : public Layer
FolderLayer : public Layer
Then...
Where would you want said ReadLayer? In Document? Or VirtualFileSystem? EDIT: At the least, the only time I had to read from a stream, the data had to be accessed by reading through the stream which by itself caused the offset. I have the feeling we want to read through the stream, parse the data into the LayerHeader struct(like is being done for Document::Thumbnail()), and then access that. Or would you rather I used VirtualFileSystem::seek(offset) for this? |
Sounds like a good pattern that is similar to how the structures themselves are laid out in memory. We can use the serialized layer headers or just encapsulate it into a more higher level structure describing the layer too, abstracting away all the grit of the layer system to have a more convenient API. Either is fine ultimately. I like the idea that a "raster layer" or "document" is just a view of a particular virtual file system and its entries. And by using memory mapped IO, I can do away with the concept of having stateful seek pointer or having a redundant amount of IO related syscalls. the VFS comes first before its interpretation as a layer. It would involve another dependency, but I've used mio before for rapidly traversing large and complex file formats, and beyond that we would just need a small ring of caches for the table blocks and the data blocks, similar to the one in-place now, to expedite redundant decryption. Do you know of any libraries that read from virtual file systems or archives with patterns that can be referenced from? |
So, I discussed this with Boudewijn, going over all the options. Right now, I think my concern is to get stuff working in Krita, so I am going to implement the layer class to parse through the layers. I will just parse through the entry and fill it into the layer headers and see how much I can get working. (That is, right now they'll be separate objects rather than alternate views) After that we can worry about performance and using memory mapping. I am far more worried about getting the import correct at this point :D |
I've added a bit of an API related to iterating all of the layers and sublayers in a document. Check out the new I've also added the new |
Right now, libsai can decrypt the file system, and look at each entry. To get the information about the layers, and then to get the pixeldata(if applicable) requires using VirtualFileEntry::Read(). There is a struct for the LayerHeader in sai.cpp, but if I want to access that from an outside class, I have to duplicate these structs in that outside class.
Ideally, we'd implement the fiddly bits into libsai, and then use a bit of api to figure out if a VirtualFileEntry is a layer we can read, and then have a layer object that gives us simpler access to layer properties and contents(pixeldata, vectordata).
Do you have any idea how you'd like to see this architecture wise?
The text was updated successfully, but these errors were encountered: