History log of /haiku/src/servers/app/Canvas.cpp
Revision Date Author Comments
# eedb92aa 11-Jul-2022 Máximo Castañeda <antiswen@yahoo.es>

app_server: fix reporting of Origin in scaled views

The local state scale is applied from the origin. That is, the origin
value does not change with the local scale.

This fixes the value returned by BView::Origin() when recovered from the
app server instead of from the client cache.

Change-Id: Id628d8f334fab06e6a6d084c079cdca1cfa914c6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5443
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 779ab335 09-Dec-2020 X512 <danger_mail@list.ru>

use .IsSet() instead if .Get() != NULL

Change-Id: Ia2b7a719fd398e78cc3b11d4f7b02cb81179f65f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3488
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 5f51a74f 02-Dec-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

Build fix.

Some code in a just merged patch needs another one that's still being
discussed on Gerrit. Extract just the parts we need to get things
building again.


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

app_server memory management fixes: use BReference

Use BReference for more automated reference counting in app_server,
fixing some use-after-free and other problems.

Extracted from https://review.haiku-os.org/c/haiku/+/2695

Change-Id: I141bb248229405896b29feff3338447f7257b0b4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3175
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


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

app_server: don't ignore invisible layers

* When a layer has opacity 0, we can't just ignore it, we still
have to play back its picture, even if the drawing will never
appear on screen. This is because there might be nested layers
and if they don't get blended, their references are not released.
Also, it can be argued that state changes in the layer should be
applied even if the layer is invisible (if we ignore it there,
it would be inconsistent with other layers).

This edge case of invisible layers could be optimized further, but
it is rare enough anyway, so this should do.


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

app_server: plug DrawState instance leak, other minor fixes

* OffscreenCanvas was not deleting its DrawState. Found thanks to
the allocation tracking feature in libroot_debug (thanks mmlr!)

* Also a missing nothrow and a missing ref release in an error case


# 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.


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

app_server/Interface Kit: add new clipping API

* Add new clipping API for rectangles (ClipToRect, ClipToInverseRect)
and shapes (ClipToShape, ClipToInverseShape)

* Works with affine transforms and automatically switches from fast
region-based clipping to alpha-mask based clipping as necessary.

* Always self-intersecting, i.e. no state push required to further
narrow down the clipping region. All of the 4 new methods can be
mixed in any order.


# 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.


# 3d12d3a8 03-Aug-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: special handling for opaque/invisible layers

* Opaque layers (opacity = 255) don't need to use an intermediate
bitmap (and everything that comes with it) for drawing at all,
they can just directly draw onto the underlying canvas or layer.
(WebKit likes to use plenty of opaque layers)

* Invisible layers (opacity = 0) can simply be ignored.


# 551438b9 25-Jul-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: add new BView layers API

* Add new methods
BView::BeginLayer(uint8 opacity)
BView::EndLayer()

* All drawing between begin and end of a layer is redirected onto an
intermediate bitmap. When ending the layer, this bitmap is
composited onto the view with the opacity given when the layer was
started.

* Layers can be nested arbitrarily and will be blended onto each
other in order. There can also be any arbitrary interleaving of
layer begin/end and drawing operations.

* Internally, drawing commands are redirected into a BPicture between
BeginLayer and EndLayer (but client code need not know or care
about this). Client code can also start/end other BPictures while
inside a layer.

* Uses the PictureBoundingBoxPlayer to determine the size of the
layer bitmap before allocating and drawing into it, so it does not
allocate more memory than necessary and -- more importantly -- it
will not alpha-composite more pixels than necessary.

* Drawing mode is always set to B_OP_ALPHA, blend mode to
(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE) while inside layers. This is
necessary for (a) correct compositing output and (b) for
redirection of drawing into the intermediate bitmap, which uses the
renderer_region offset (in B_OP_COPY, the Painter does not use the
AGG renderer methods, it directly accesses the pixel data. This
would access out-of-bounds without the offset, so B_OP_COPY cannot
be allowed.)
To ensure these modes aren't changed, BView::SetDrawingMode()
and BView::SetBlendingMode() are ignored while inside a layer.

* The main motivation behind this new API is WebKit, which internally
expects such a layers functionality to be present. A performant and
reusable implementation of this functionality can only be done
server-side in app_server.


# b5c7f936 08-Jul-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: allow replacing the DrawState in a Canvas

* Needed for layers support. The previously set DrawState and its
stack predecessors are not freed, so take care to not leak memory
when using this.


# ae046876 08-Jul-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: add Canvas::PenToLocalTransform


# 6f2a446e 06-Apr-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: extract coordinate conversion class

* Move coordinate conversion into a new class SimpleTransform. It
supports scaling and translation which is sufficient for conversion
between screen, local and pen (drawing) coordinates.

* Because all the overloaded methods for converting
BPoint/BRect/BRegion/etc are now within the single SimpleTransform
class, the interfaces of Canvas, View, DrawState, etc. are slimmed
down. These classes have too many responsibilities, so some will be
factored out into separate classes, this being the first.


# ab1bd2fd 04-Jan-2015 Julian Harnath <julian.harnath@rwth-aachen.de>

app_server: rename DrawingContext to Canvas

* Better reflects the purpose of the class: an interface for things
in which we can draw (e.g. a View)

* Accordingly rename OffscreenContext to OffscreenCanvas