ishani Posted April 30, 2019 Share Posted April 30, 2019 (edited) The plugin I'm building runs its own built-in preview window, so I don't tell PDN that anything is changing (ie. not calling FinishTokenUpdate or calling EffectTokenChanged while the user uses my config UI window) Once a user hits "OK" to render things out, I then want to get my OnRender() called - just the once - so I can push out the final result. My effect has a RenderingSchedule of EffectRenderingSchedule.None and I need to do all the work in a single call. I've got a solution where I embed an ID into the token and the Effect instance - if it matches in a OnRender() call (or if we're repeating the render) then we do the final result - but regardless, we change the ID in every call to OnRender() so it will only trigger once it's been through the UI. // some pseudocode... // in effect code protected override void OnRender( Rectangle[] rois, int startIndex, int length ) { if ( (Token.RenderFinal && localRenderFinal) || repeatEffect ) { // .. do the stuff } localRenderFinal = false } // in config form: private void HwRender_PanelClicked(object sender, MouseEventArgs e) { (theEffectToken as MyEffectToken).RenderFinal = true (Effect as MyEffect).localRenderFinal = true FinishTokenUpdate(); Close(); } Hope that makes sense. The approach feels a little hacky and I wanted to check if there was something more standard? I have had a search and found the post where Rick describes some of the plugin internal call flow (and I've done my own tracing / ILSpy) but I couldn't see anything that was quite in this direction ... Edited April 30, 2019 by ishani Quote Link to comment Share on other sites More sharing options...
null54 Posted April 30, 2019 Share Posted April 30, 2019 1 hour ago, ishani said: The approach feels a little hacky and I wanted to check if there was something more standard? The normal approach for a plugin that uses its own preview window is to have the configuration dialog render the final result to a Surface that is stored in the effect token. If the plugin is called as a repeat effect you would perform rendering in OnSetRenderInfo instead of the configuration dialog. That way the plugin can do the rendering however it needs to and Paint.NET will use its multi-threading when copying to the destination in Render. You can look at the OnSetRenderInfo and Render implementations in G'MIC for an example of how this is done. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.