Sign in to follow this  
xod

EffectOptions

Recommended Posts

I think in paint.net 4.1.3 some changes have been made because now in VS I have this warning:

'PropertyBasedEffect.PropertyBasedEffect(string, Image, string, EffectFlags)' is obsolete: 'This constructor is deprecated. Use an overload that takes an EffectOptions instance.'

Share this post


Link to post
Share on other sites
1 hour ago, xod said:

I think in paint.net 4.1.3 some changes have been made because now in VS I have this warning:

'PropertyBasedEffect.PropertyBasedEffect(string, Image, string, EffectFlags)' is obsolete: 'This constructor is deprecated. Use an overload that takes an EffectOptions instance.'

 

Yes, Rick wants to move away from using EffectFlags and toward using EffectOptions.  For now, you can still use EffectFlags as this is just a warning... this will change in Paint.NET v4.2 (whenever that ships).  NOTE: Effects compiled with EffectFlags will always work, you just won't be able to compile new effects with them after 4.2 ships.

 

Right now, there are only a hand full of Effect Flags (EffectFlags.Configurable | EffectFlags.ForceAliasedSelectionQuality | EffectFlags.SingleThreaded). Going forward, Rick wants to expand the options available and the best way to do that is with EffectOptions.  EffectOptions can have more than just flags... you can pass in numeric values to parameters, etc.

 

Here's one change available already: with EffectFlags, your selection is broken up into ROI's that span the entire width of the selection and are typically 1 or 2 rows high... using EffectOptions, you'll have access to breaking up ROI's into tiles to more efficiently use the effect engine.

 

The next release of CodeLab will start generating solutions with EffectOptions.

 

  • Upvote 3

Share this post


Link to post
Share on other sites

Also, to expand on what @BoltBait mentioned about tiles vs. horizontal strips: if you use EffectOptions, then you get the new tile-based "rendering schedule" unless you specifically request the legacy horizontal strips. If you still use EffectFlags then your effect is considered a "legacy effect" and you get horizontal strips.

 

EffectOptions isn't difficult, it's just new :) It's meant to be a superset of EffectFlags, and in fact it contains the EffectFlags.

 

This:

 

new EffectOptions() { Flags = EffectFlags.Configurable }

 

is probably all you need to know how to do at this point.

 

The EffectOptions will play a much more important role in a few releases once I open up the Direct2D/GPU stuff for plugins. It's almost ready, but 4.1.2 - 4.1.4 had to go out the door to solve some more immediate concerns (4.1.4 isn't out yet but will be soon).

  • Upvote 2

Share this post


Link to post
Share on other sites

Spiting these posts into a new forum topic.

 

Here's some more info regarding ROI when using EffectOptions.

As BoltBait and Rick have both said, EffectOptions uses tile-based rendering by default.

 

On a 800x600 canvas it looks like this:

RoiTile.png

 

 

With a selection, it can get a bit more complex:

(Note: my red outlines are 1px thick, so some areas appear solid red... because the ROIs are also 1px thick.)

RoiTileSel.png

 

 

^^^ These images were created using this code:

Spoiler

void Render(Surface dst, Surface src, Rectangle rect)
{
    using (Graphics g = new RenderArgs(dst).Graphics)
    {
        g.DrawRectangle(Pens.Red, rect);
    }
}

 

 

 

 

 

 

If your plugin's algorithm assumes the ROIs span the full width, you can specify the legacy behavior like this:

: base(StaticName, StaticIcon, SubmenuName, new EffectOptions() { Flags = EffectFlags.Configurable, RenderingSchedule = EffectRenderingSchedule.SmallHorizontalStrips })

 

As a reminder, here is BoltBait's image of the legacy (full width strips) ROIs.

ROI.png

 

Edited by toe_head2001
typos
  • Upvote 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this