Skip to content
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

Change filter clear parameter to clear modes #6295

Merged
merged 9 commits into from
Jan 16, 2020
Merged

Conversation

ivanpopelyshev
Copy link
Collaborator

@ivanpopelyshev ivanpopelyshev commented Dec 23, 2019

Previous issue #6270 #6257 and possible future changes in FilterSystem enabled me to finally clarify the clear variable everywhere.

BlurFilter test for this branch: https://www.pixiplayground.com/#/edit/0-VaT0fFvoiWju_9XeJO2

Modes:
NO/BLEND (false) - don't clear the output texture, it contains vital information that we need to blend upon
YES/CLEAR (true) - texture contains junk, clear it.
AUTO/BLIT (new mode!) - we know that texture partially or fully cleared and previous state should not be a problem.

By default pixi-v5 uses renderer.filter.forceClear=false, which corresponds to minimal number of WebGL commands.

The trick is - on some mobile videos its better to clear just after bind , because it saves the time for copying content. In that case we need renderer.filter.forceClear=true.

Another case is when someone made a mistake, like it existed in BlurFilter, but we dont have time to debug all those custom filters. In that case we just clear whenever its possible.

As a joke, I thought it was possible to add one more "russian" mode, YES_NO_MAYBE (да нет, наверное). If filter area covers all renderTexture, we might not clear it borders and just blit it.

Copy link
Member

@ShukantPal ShukantPal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m pretty cool with this; however, I don’t see how AUTO is doing anything in this PR. I mean, AUTO depends on forceClear - that’s all. Are you going to add something in the future to this?

@ivanpopelyshev
Copy link
Collaborator Author

Yep :) I'll do experiments which devices have this problem.

Right now its just a paranoia option: v4 cleared everything, v5 doesnt and we have a switch between those modes.

@bigtimebuddy
Copy link
Member

How are you supporting backward compatibility? I’m sure there are some pixi-filters using clear Boolean? I’d suggest adding a typeof check to clear and throwing a deprecation warning.

@ivanpopelyshev
Copy link
Collaborator Author

Easy.
0=false, 1=true - behaviour is the same.

2 is not used in pixi-filters

@bigtimebuddy
Copy link
Member

@ivanpopelyshev we should not use truthy conditions with constants like CLEAR_MODES. This is how we got bit with the scale modes, because someone flipped the value. Please don’t mix types. If someone uses a boolean, we should make sure that’s properly deprecated.

@bigtimebuddy bigtimebuddy added this to the v5.3.0 milestone Jan 10, 2020
@ivanpopelyshev
Copy link
Collaborator Author

We will get rid of booleans in pixi-filters and only numbers will remain. I just don't want the plugin to break right after we merge this thing.

We won't have problems like that in future with typescript.

@codecov-io
Copy link

codecov-io commented Jan 13, 2020

Codecov Report

Merging #6295 into dev will decrease coverage by 0.01%.
The diff coverage is 30%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #6295      +/-   ##
==========================================
- Coverage   77.98%   77.96%   -0.02%     
==========================================
  Files         186      186              
  Lines       10111    10116       +5     
==========================================
+ Hits         7885     7887       +2     
- Misses       2226     2229       +3
Impacted Files Coverage Δ
packages/accessibility/src/AccessibilityManager.js 34.43% <30%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ce656f...f15c1a3. Read the comment docs.

@ivanpopelyshev
Copy link
Collaborator Author

ivanpopelyshev commented Jan 14, 2020

OK, I've added support for true and added a test. I completely forgot that true !== 1

this.renderer.renderTexture.bind(filterTexture, filterTexture ? filterTexture.filterFrame : null);
if (clearMode === CLEAR_MODES.CLEAR
|| (clearMode === CLEAR_MODES.BLIT && this.forceClear)
|| clearMode === true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incorrect/incomplete way to implement backward compatibility. The API shouldn't support both booleans and CLEAR_MODES. Please move this condition (clearMode === true) out of the if statement so that we can easily remove it later. For instance, add this before the if:

// TODO: remove in next major version
if (typeof clearMode === 'boolean') {
  clearMode = clearMode ? CLEAR_MODES.CLEAR : CLEAR_MODES.BLEND;
  // get deprecation function from utils
  deprecation('5.2.1', 'Use CLEAR_MODES when using clear applyFilter option');
}

Copy link
Member

@bigtimebuddy bigtimebuddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for appeasing me!

@ivanpopelyshev
Copy link
Collaborator Author

ivanpopelyshev commented Jan 15, 2020

Thank you for appeasing me!

You know that I can't see everything. Btw, tests show deprecation in console - can we do something about it?

Also, I don't know whether we will remove booleans in next version, because i want to stay v4-compliant.

@bigtimebuddy
Copy link
Member

If you see deprecation in console it means we missed a spot for upgrading. Could be a test? Probably worth tracking down.

@ivanpopelyshev
Copy link
Collaborator Author

Both tests are mine: one uses BeginTextureFIll with arguments instead of object, and one here, I'm testing bool param.

@bigtimebuddy bigtimebuddy changed the title Dev filter clear mode Change filter clear parameter with clear modes Jan 16, 2020
@bigtimebuddy bigtimebuddy changed the title Change filter clear parameter with clear modes Change filter clear parameter to clear modes Jan 16, 2020
@bigtimebuddy bigtimebuddy merged commit b437b17 into dev Jan 16, 2020
@bigtimebuddy bigtimebuddy deleted the dev-filter-clear-mode branch January 16, 2020 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants