History log of /haiku/src/servers/app/drawing/AlphaMask.h
Revision Date Author Comments
# b009ef38 12-Sep-2021 Máximo Castañeda <antiswen@yahoo.es>

AlphaMask: fix bounds of inverse masks

For inverse masks the real bounds rect is the canvas, as the points that
pass through are the ones not drawn.

Change-Id: I420a5eca419b215b55e4c2362e2c7646465a4cd3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4455
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# d99d8dbd 27-Aug-2020 X512 <danger_mail@list.ru>

app_server memory management: use ObjectDeleter to mark ownership

Make object ownership explicit by use of ObjectDeleter where possible.

Change-Id: I499a00aa3390d1510ae284419e73faffa5166430
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2695
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# 176d0e10 20-Jun-2020 Augustin Cavalier <waddlesplash@gmail.com>

app_server: Make use of BReferenceable in AlphaMask.

Extracted from https://review.haiku-os.org/c/haiku/+/2695
with a few minor tweaks.

May help with #16246, but I could only reproduce it intermittently.


# 67ace0bf 20-Jun-2020 Augustin Cavalier <waddlesplash@gmail.com>

app_server: Use RecursiveLocker in AlphaMask instead of BLocker.

This avoids creaing a semaphore where it is not needed, especially
as most of these locks are never used from another thread (in the
reports in #16246, there are thousands of semaphores from this
with only a small handful having a "last acquirer" != 0.)


# 3c9d8d64 15-Nov-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: fix race condition in alpha mask cloning

* Add a lock which is acquired when reattaching/regenerating masks,
and also acquired for a cached mask before making a clone of it,
to prevent the clone from having an inconsistent state in
concurrent edge cases.

* Maybe fixes #12469


# b54b3ae5 13-Nov-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: add a cache for AlphaMasks

* If the same shape alpha mask is set again and again, we now keep
the rendered masks in a cache. On certain websites, WebKit sets
the same shape for clipping hundreds of times, which uses a lot
of time to render the masks.

* When a shape mask was generated, we put it into AlphaMaskCache.
The constructor for ShapeAlphaMask is made private and a factory
method is used for instantiation instead, which transparently
looks up in the cache whether a suitable mask was already generated
before (so the entire caching is encapsulated inside the AlphaMask
class).

* When taking a mask out of the cache, we still create a new
AlphaMask instance. However, the new instance will share the
mask bitmap with the previously generated instance (aside from
the rendering of their bitmap, AlphaMask instances are pretty
lightweight). Shape masks are only seen as identical when
their shape is the same, the inverse flag, and they have the
same parent mask.

* Cache is limited to a fixed size of currently 8 MiB, using a
simple random replacement scheme. An LRU scheme can be added in
the future if necessary. Counting of bytes for the cache size
includes parent masks of masks in the cache, even if the parent
itself is not cached. A reference counter for "indirect" cache
references keeps track of which masks are not part of the cache,
but still need to be added to the cache byte size.

* For now, only for ShapeAlphaMasks, other mask types can be added
as necessary.


# e718dc91 12-Nov-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: Clip alpha masks to canvas size

* Making the alpha masks independent of view size is a good thing,
however it turns out that I was too optimistic about the
consequences: webkit sometimes sets masks for the whole page, not
just the currently visible area. E.g. on Github diff views, it
was seen to set a clipping path which is about 1,000 x 10,000
pixels in size. Generating these huge masks eats up lots of memory
and time.

* We now clip the alpha masks to the current view size. This
introduces a dependency between mask and view again, however a
weaker one than it used to be before the mask rework. When the
view is enlarged, and the alpha mask was previously clipped during
rendering, we regenerate it at the new size. When the view is
shrunk however, we don't do anything and just keep the
now larger than necessary mask around (so we don't have to
regenerate again when the view is subsequently enlarged again --
except if it then becomes even larger than it used to be).
Changing the view origin is unaffected and still doesn't cause a
regenerate.


# 23af4ff6 09-Nov-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: finish BShape-based alpha mask generation


# 9b417f64 22-Aug-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: rework AlphaMask, use bounds for mask pictures

* Refactor AlphaMask class to separate the mask from its source. This
allows use to not just a BPicture as source for a pixel alpha mask,
but also e.g. a BShape in the future (not yet implemented).

* For BPicture-based masks, use the PictureBoundingBoxPlayer to
determine the size of the resulting mask bitmap. The masks are now
drawn into bitmaps of this size (instead of the whole view size).

When alpha masks are stacked, their bounding rectangles intersect
(i.e. masks further up in the stack can never be larger than masks
lower in the stack). The bitmap of a mask always contains the state
of itself blended with all masks in the stack below it.

This also avoids frequent rerendering of the masks. They are now
independent of view size. When the view origin (in screen
coordinates) changes we only have to reattach the mask buffer,
without having to redraw it.

* The class UniformAlphaMask is used for simple masks with the same
alpha value in all pixels, it uses no mask bitmap at all.
Currently, it can only be used on its own and not be stacked
together with other mask types.


# f4f05935 15-Aug-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: give Painter direct access to alpha masks

* To use alpha masks in optimized drawing code outside of the AGG
renderer pipeline, we need to allow access to the alpha mask's
underlying buffer:

- AlphaMask gets another method which returns its
clipped_alpha_mask
- clipped_alpha_mask gets a get_hspan() method which returns a span
of alpha values without combining it with anything
- Painter/PainterAggInterface store a pointer to the
clipped_alpha_mask (in addition to the AlphaMask's scanline
container)


# cd621b95 22-Jul-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: add method to shift alpha masks

* Allow shifting the offset of alpha masks without changing the size.
Ideally, we only need to reattach the buffer in the shifted
position, saving the work of reallocating and redrawing the mask
picture. Needed for layers support.


# 6ac468ef 22-Jul-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: add support for uniform opacity alpha masks

* Another constructor for AlphaMask allows creating a mask with no
picture, it will simply be a single uniform alpha value over the
whole mask.

* No need to even allocate a buffer in this case, we can just use
the feature of clipped_alpha_mask to define an opacity for outside
the mask, and set the buffer size to zero.


# d02b8b81 08-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

app_server: Cleanup of some file locations


# d02b8b81e884bd0090ef9bd2d7a62af673eca354 08-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

app_server: Cleanup of some file locations