Skip to content

Use glBlend to replace needing FBO for tool outline

Alvin Wong requested to merge alvinwong/krita:alvin/glblend-brush-outline into master

The previous behaivour requires rendering the canvas with an FBO, then uses its texture as an input to a fragment shader to blend the tool outline. The arithmentic:

outColor = srcColor * vec4(vec3(1.0 - dstColor), 1.0)

... is equivalent to:

outColor = srcColor * 1.0 - srcColor * dstColor

... except for the alpha channel, which is effectively 1.0.

This can be replicated by GL_BLEND using glBlendFuncSeparate and glBlendEquationSeparate. This avoids needing to sample from the FBO texture. It also works on OpenGL 2.1, so we can remove the old glLogicOp(GL_XOR) codepath to get the same behaviour across all supported systems.


This replaces the shader added in !349 (merged). In theory this reduces the graphics memory footprint and may be a bit more performant. GL_BLEND is less flexible than a fragment shader (other than being able to sample the destination), but I don't think we need to make the tool outline any fancier.

I believe it should work fine on OpenGL 2.1 according to the docs, but I have not tested it on such hardware.

I have not completely removed the FBO rendering code because we may still use it in the future to avoid redrawing the full canvas image when updating just the tool outline and assistants.

CC @eoinoneill @emmetoneill

Edited by Alvin Wong

Merge request reports

Loading