[cairo] is self-copy supposed to work?

Robert O'Callahan robert at ocallahan.org
Wed May 5 16:42:15 PDT 2010


On Thu, May 6, 2010 at 12:20 AM, Siarhei Siamashka <
siarhei.siamashka at gmail.com> wrote:

> On Friday 30 April 2010, Robert O'Callahan wrote:
>
> > Also I think it's generally a bad idea for an API to just do something
> > random in certain special cases.
>
> People familiar with C programming language and 'memcpy' function should
> not
> be surprised too much.


People familiar with C are used to pain, it's true :-)

Undefined behavior is ok as long as it is clearly
> documented. And especially if it also helps to have better performance and
> avoid redundant complexity.
>

Maybe so, but in this case I don't think it does. I think pixman and cairo
could just support self-copies without adding much complexity or hurting
performance.

> I can't think of any reasonable behaviour other than to make self-copies
> > just work. It's not that hard for the general case; just detect the
> > self-copy and use a temporary buffer.
>
> AFAIK there are some plans to support sub-images eventually, and it will
> make
> self-copy detection somewhat more tricky.
>

We'd just need an internal API to get the true underlying surface, right?

Also, what is going to happen if an application deliberately performs some
> operations inside of all the same image, but with non-overlapping pixel
> areas?
> Will it be penalized with the use of a temporary buffer just because this
> simple self-copy detection will be triggered?
>

An application shouldn't be doing that; applications should not rely on
undefined behavior. If you want applications to be able to do that reliably,
then we do need to define behavior for self-copy.

Exposing APIs with random behavior is bad. Applications coming to rely on
particular details of that random behavior is worse.

> Some simple cases (i.e., the cases I
> > care about!) can easily be optimized to avoid the temporary buffer.
>
> Yes, but simple cases can probably use simple solutions.
>
> What are you going to actually do with a complete (and complex) self-copy
> aware implementation when it is done? It might be an overkill just for a
> simple scrolling.
>

It doesn't have to be complex. See Matt's patch.

Is there a practical use case for self-copy aware OVER compositing?
>

I don't know. But if there isn't, then no-one's going to hit a slow path.

Rob
-- 
"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
53:5-6]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100506/998dd1bf/attachment.htm>


More information about the cairo mailing list