Effectively compose / render multiple layers for a Photoshop-like image editor

I am making a Photoshop application having 5 or about 1600x1200 layers. Each layer can have different blending modes, such as normal blending, XOR blending, additive blending, etc. Where conventional blending is the most common. Blending all layers together takes about 0.3 seconds on my target platform (hardware acceleration is an option here).

My problem: How can I effectively update the screen to show all layers flattened / mixed together when the user performs editing operations on the layer?

For example, a simple operation may be to convert one layer to shades of gray. A more complicated operation is to draw a brush image in real time on one of the layers in several places. In particular, my interface will be too unresponsive if I try to remake everything that the user uses the brush.

The only optimizations I can think of are as follows:

  • cache the anti-aliased image and when changes occur, update only the rectangle of the anti-aliased image that has changed. This will be fast for small brush images, for example.
  • when editing a layer, cache the smoothed image of all layers under the active layer. When updating a full tapered image, we only need to blend the active layer and the layers above in this cached image.

2 , , , .

+3
1

, - . OpenGL 2.0+ ( ES 2.0+) - , - GLSL C-, , GPU , . , , , , , (2). , , , Direct3d HLSL, NVidia Cg, , , GLSL HLSL.

: (1) - , . , , . , - .

(2) ( ). , , , , , 8bpp/channel, 16bpp/channel, , . , , 8bpp/channel. .

, , , , , . , - . , , . XOR. , , , , , . , . , . , , .

, , , .

0

Source: https://habr.com/ru/post/1793882/


All Articles