# Filter's changeRect() and merging problems

Dmitry Kazakov dimula73 at gmail.com
Sat Aug 22 11:54:41 CEST 2009

```Hi all!

I'm revising our merging strategy  at the moment. We have big problems
with  it. I  want it  to take  into account  need rects  of adjustment
layers.

At  the   moment  i  have   problems  with  KisFilter::changedRect(rc)
rect. Could someone  describe me what it is? Is  there any usecase for
that?

Actually,  i understand  that this  is  a rect  that adjustment  layer
changed after applying on @rc  rect. But(!) how should update strategy
treat this rect?  There are two possibilities:

1) Update  strategy should update  this _expanded_ rect on  all higher
layers

2) Update strategy should NOT  pay any attention to this expanded rect
and all higher layers should update requested rect only.

Let's see  it in  example. Assume that  our adjustment  layer's change
rect is two  pixels wider than requested rect and  we have changed 2x2
rect on the lowest paint layer.

/**
* GL - group layer
* PL - paint layer
*/

GL         Updated rect(1st case)         Updated rect(2nd case)
|--PL           4x4                               2x2
|
|--PL           4x4                               2x2
|
|--AL           4x4                               4x4
|
+--PL           2x2                               2x2

I think  that the first  case is more  obvious, but it depends  on the
meaning of  changedRect() and  it's usecases. Those  are the  things i
can't understand.

In my  refactor of merging i'm  going to collect all  the needed rects
for  all the layers  in a  top-down way.  But if  we pay  attention to
change rects and  they don't depend on need rects  this task will have
no trivial  solution. Of  course it  will have one,  but it'll  be too
complex - it'll  use "Least common multiple" stuff.  Let's take a look
at the case when this applies:

GL
|--PL
|
|--AL#2 cr:+3 nr:+5
|
|--AL#1 cr:+2 nr:+4
|
+--PL

Imagine  AL#1 needs  2 additional  pixels for  need rect  and  4px for
change rect
but      AL#2 3px for needRect and 5px for changeRect

I don't know how to merge layers in such a case.

There can  be a solution for this  if we define changeRect()  to be an
inverse function for needRect(). So to say, needRect is +2, changeRect
is   -2.   Generally,   it   means   that  we   return   to   an   old
overlapMarginNeeded() function.

What do you think?

PS:
A short summary of questions:
1) What is changedRect actually? And what are the usecases?
2) How to merge that case with two adj. layers?
3) If there  is  no  way how  to  merge it,  should  we  revert to  a
deprecated function?

--
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20090822/aec80bbe/attachment.htm
```