-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Add loading of in-memory resources. #578
Conversation
Thanks - this is looking pretty good, although a few things to sort, some testing needed, and some possibilities for reducing duplication a little I think. A few things so far:
|
BTW - we should add some tests for this in IGraphicsTest, which will make life easier in the long run. |
I think I know what I did wrong regarding the web stuff, the Mac fix should be pretty easy as well, and I know what you're talking about regarding the Windows code deduplication. As for the testing, are you talking about stuff in |
Currently the tests folder contains projects, no unit tests, but I’ve been thinking about adding some tests with catch2 |
Yes - currently we make custom controls for testing (by the way @oli - right now the test controls are in IGraphics/Controls/Test, but wouldn't it make more sense to has them in Tests/Controls or somewhere like that? |
I'm noticing a lot of Windows API calls that could be easier to manage with a custom deleter. Something like this:
This might make managing some of the Windows API code easier and less likely to leak. This is applicable specifically to the font code, but also to other parts of the Windows API and probably other platform APIs as well. |
Okay, I'm just going to get emscripten setup so I can actually compile stuff to make sure it works. XD |
… to comment out GL.newRenderingFrameStarted() in the main loop.
Okay! I think this is finally ready for a real review. It's working on NanoVG, Skia, and Canvas, as well as Windows and probably Mac, though memory font loading on Mac needs to be confirmed. @olilarkin @AlexHarker Can I get some feedback please? Also note: I have a |
How do you envisage dealing with multi-res bitmaps? Currently IGraphics::LoadBitmap() will find @2x.png , @3x.png , finding those files on disk, so you only need a single Load bitmap line. I was experimenting with your code, having used bin2c.py to convert the knob and knob@2x.png from the IPlugControls example, and I had to make a slight modification in order to get the multi-res bitmap to load properly on different screens. I think it would be great if we could make bin2c.py and your new IGraphics::LoadBitmap() deal with multi-res pngs automatically, so you can #include a single file and call LoadBitmap once.
|
Also, I wonder if putting everything in a header file is best, or if the tool should make header + .c/pp file ? In my example above, every time I want to rebuild the plugin the compiler will have to process the included header files again i think, slowing build times if they included a lot of data |
I'm don't really think that in-memory loading should decide what scale to load at. It should take a block of memory and load that image, regardless of scale. We could easily make a helper method that takes an array of Secondly, my original system had some more support for that, but I removed it to be more compatible with I'd say that if you want a function that loads based on the current scale, that should be a separate function. I can add it to the PR today. I can also add the option to generate a header file with the cpp file. What we probably shouldn't do is over-complicate the resource generator tool. One resource file -> one .cpp file. If they want to make an array of resource files, that's on them. |
I'm with @olilarkin - currently when you use one filename it looks for multiple scales of the same filename so it is seamless to the developer - so to my mind the resource generator should make the array and when you load it IGraphics knows which scale is best - otherwise it's more work to use this method than the normal ones. |
Okay, I can put my multiple-file code back in, but how will it be specified? I'm thinking a CLI flag would be best, maybe That way if the user is including a font, SVG, or some other binary blob, it remains simple. If they want the file-array, it should be opt-in. |
that sounds fine |
Should the script automatically pick up multiple resolutions of the file, or should the user have to specify them manually? |
It would be great to do it automatically of course!
…On Mon, Jul 13, 2020 at 10:44 PM Binder News ***@***.***> wrote:
Should the script automatically pick up multiple resolutions of the file,
or should the user have to specify them manually?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#578 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFACLTSMTFR6XNIHN3AYTDR3N54ZANCNFSM4OVBFHWQ>
.
|
Okay, I have what I think is a pretty nice balance. First, both the source file and header file are now required arguments. Technically the script still supports not generating a header, but I'm not going to make it an option from the CLI as I think it's more confusing. Almost everyone will want header files, and if they don't they can just delete it or something. Now, files with the scaling suffix are added with the In addition to the scaled files, you can now specify multiple files individually on the command line. Each file is specified as a pair of arguments |
Oh, and compression is still a feature and is applied to all files if specified. So the simple use-case is still easy, and adding scaled resources and the array feature are just an extra flag each. |
IPlugControls example seems to fail loading svgs. If statements around fseek in IGraphics::LoadResource() seem wrong
fixes it |
I thought I tested that, oops. I always get confused because some things return 0 or an error code, and other things return 0 or 1 as a boolean. It's quite annoying. I'll make the change and confirm the fix. |
Is there a way to IGraphics::LoadBitmap() in one line now for a multi-res bitmap? I didn't work it out if so. @AlexHarker i think this is close to mergeable now, but missing AGG, LICE & CAIRO impl. |
There is not yet a one-liner for loading multi-res bitmaps, because I have some questions on how to do so.
As for AGG, LICE, and CAIRO, are you sure you want them? If people are really using them, I'll get them working, but I don't want to spend the time getting them to work if we're going to drop support for a backend soon. |
need to think about those questions. if you comment # WEB_LDFLAGS += $(NANOVG_LDFLAGS) then you don't get the WebGL error when using canvas |
Any update on this? I'd like to continue working and get this merged, but I need some decisions. |
Can get back to this later in more detail, but the first question is do you understand what happens with multiple resolution bitmaps if they are on disk? One of the issues here is that from disk you can load the one you need right now and then later we find the one we need when it changes - that would be the best kind of solution, but obviously there is no such thing as a "path" for memory loading - might need some back and forth on that one. |
That's why the |
Just noticed that this would fix issue #210 . |
Sadly I think #210 is about having a modifiable bitmap in memory that can be edited and then drawn - I don't think you'd want to have to load that resource in each time. I actually got quite far with that issue 7 months ago (https://github.com/iPlug2/iPlug2/tree/IRawBitmap), but there were some downsides and it isn't currently merged. |
Let's clarify things so I can get this done and it can be merged:
Is that everything? Because I'd really like to get this merged and be able to use it from master. |
I would be happy to merge without 1), as long as those backends compile with no-ops
|
merged in b8c4663, may make some extra issues for single-line loading etc |
I do NOT consider this PR merge-ready yet. It needs testing on Mac and iOS, and support for
LoadBitmap
needs to be added to the Canvas backend, and maybe the Cairo, AGG and Lice backends. That being said, I'm putting it up for review.Major changes:
LoadBitmap()
,LoadSVG()
, andLoadFont()
to enable loading resources directly from memory.xxd.py
in theScripts
directory for generating C++ source/header files from binary files. Ideally this would become part of the build process for users who want to use this feature.