jchunn Posted February 2, 2008 Share Posted February 2, 2008 I have been playing with the effects api for a couple of days now... just trying to get something to work (and I have gotten something to work). I would deeply apprreciate it if somebody wouldn't mind taking a minute to review my comments below and provide some insight. Some of the folks here have obviously created some astounding plugins, and I think one of those folks could reply to this with their eyes closed. I have read through the forum, and I have toyed around with some of the plugin source that is available, but I am still not completely sure I have this right. Please correct any incorrect assumptions here: The "rois" variable (rectangles of interest, I presume) that is passed into the "OnRender" method appears to be at the heart of the multithreaded model. When the method is called, it looks like one or more rectangles are passed in via this "rois" array, and it looks like the expectation of the application is that the plugin will process the areas contained in the "rois" that are passed in, and only those areas, during that pass. It also appears that the "OnRender" method will be called multiple times for a single rendering, passing in different "rois" until the entire selected area (or is it the entire surface of the layer?) has been covered. If I am correct so far, then it appears that this must be looked at from the perspective of the "location" of each rectangle. In other words, the plugin could be asked to render an arbitrary location within the overall selection (although I assume logically that they are passed in from top to bottom?). The plugin, then, must use the location of the rectangle (and the pixels within that rectangle) relative to the overall selection or the overall layer, depending on what your plugin does. Again assuming I am right so far, then the x,y location of a pixel must be used in any math that determines how the effect acts on that pixel. While that is obviously true even in a single threaded implementation, the point is that you cant really use other variables within a loop (like i, for example) in the math, at least not easily, since i would start over at zero in each pass (unless, of course, you use relative position to set the initial value of i). I am just trying to verify how this works. My testing this far seems to verify what I have said, but I don't want to get too far along only to find that I have misunderstood something. Any commentary would be greatly appreciated. Regards. Quote Total hack. Link to comment Share on other sites More sharing options...
pyrochild Posted February 2, 2008 Share Posted February 2, 2008 Right, you must assume that your effect will be called on and required to render from completely arbitrary locations in the image. You cannot assume that the rects will be passed from top to bottom, because the workload will be distributed among 2 or more threads, depending on the number of processor cores present. You can assume, however, that only one instance of your Effect will be working on the image at once, so if you absolutely need something to persist, you can put a variable in that class. ^Ed Harvey will shoot me for saying that. He is dead-set against global variables Quote ambigram signature by Kemaru [i write plugins and stuff] If you like a post, upvote it! Link to comment Share on other sites More sharing options...
Simon Brown Posted February 16, 2008 Share Posted February 16, 2008 He is dead-set against global variables Just in plugins or in every program? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 16, 2008 Share Posted February 16, 2008 Global variables are a form of shared state which causes a radical increase in the number of possible states that a program can be in. And not only that, it causes an explosive increase in the number of control flow paths that can be taken to reach any of those states. In other words, the complexity of a program rises significantly with more global state, and maintainability decreases significantly. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html 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.