Hi all,
With metan, we discussed Context, blits, drawing and clipping in core.
My proposal would be to remove clipping information from Context and
to think about some structure for "Drawing context". This structure
could also include other style information and would act as a wrapper
around context and used in convenience drawing functions.
The goal is to simplify the base api and modularize the library. I
believe that we should allow separate use of any part of the library
as much as possible - library supporting all kinds of weird devices
can see many uses both with variable subset of the modules.
Arguments to move clipping from Context to drawing are
* One use of clipping is convenience when drawing primitives. This
should be handled with drawing functions. There, clipping can save
some complicated reasoning.
* Blits should not respect clipping. Blitting a superset of
clip-region is very frequent and even if needed, calculating
intersection of two rectangles is very easy.
* One use-case of clipping is "user" routines drawing inside windows
etc. This can be done using subcontexts (context pointing to part of
memory of other context). This has also the advantage of coordinate
system being always (0,0) and solves the problem when (clipped) "user"
drawing routine would like to use clipping itself. Of course that
every context is still "naturally" clipped by (0,0,w,h).
>From my own experience, I used clipping very rarely, but I see its
value as a convenience mechanism. Having two variants of drawing
functions - one "bare" (unclipped, without implicit style information,
etc.) and an optional set of "convenience" functions (clipping, using
implicit style info on BGcolor, clipping, aliasing, font, ...) would
be the best of both.
It still remains a question how to implement such wrapper (structure
pointing to a context? context-independent structure? something
extensible or fixed? ...). I haven't given it much thought. Any ideas?
If there is an important use-case that I forgot to mention or if there
is any technical problem, bring it on.
Best,
Tomas