History log of /haiku/src/servers/app/View.h
Revision Date Author Comments
# b5ba4bad 12-Feb-2023 X512 <danger_mail@list.ru>

app_server: clear background immediately on expose

Reduce stamping artifacts when application slowly responds to redraw requests.

This fixes and reintroduces logic previously removed in hrev53711.
Previous logic was incorrect as it didn't take the possibility of multiple
invalidations of different kinds (expose, update request) into account.
Now separate update and expose regions are maintained and only expose region
is cleared immediately.

Change-Id: I0fd98cb1b45ccec285154e8c0d8e3a1400d156d7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6067
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


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


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


# 47102c07 24-Feb-2020 X512 <danger_mail@list.ru>

Interface Kit: introduce B_TRANSPARENT_BACKGROUND flag

BeOS didn't support transparent views. As documented in the Be Book,
SetViewColor(B_TRANSPARENT_COLOR) only effect is to not fill the
invalidated areas with the view color before calling Draw() (it avoids
flickering, especially when combined with B_FULL_UPDATE_ON_RESIZE).

A previous change made B_TRANSPARENT_COLOR actually make the view
transparent (that is, additionally to the above, the underlying view is
drawn before the transparent children), but it creates compatibility
issues.

In order to keep the API compatible with BeOS, the new behavior is now
enabled explicitly using the B_TRANSPARENT_VIEW flag. This also opens
for future developments like allowing a view color with an alpha
channel (not supported yet).

Adjust programs that require transparent views.

Fixes #15744, #15745.
Helps with #15645.

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


# 6ab29b93 09-Jan-2020 X512 <danger_mail@list.ru>

app_server: fix drawing of transparent views

This change makes to draw parent view before current view if current view
ViewColor is transparent. Views with transparent parts such as BDragger are now
drawing properly without workarounds.

Change-Id: I0450d1f012555137c8e7dd2d08c0c27df39465ff
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2091
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 7f9368ca 09-Dec-2015 looncraz <looncraz@looncraz.net>

Set*UIColor, etc.

The inseparable changes necessary to support live color updating across the
system in a sane, safe, and performant manner.

BView gains:

HasSystemColors()
HasDefaultColors()
AdoptSystemColors()
AdoptParentColors()
AdoptViewColor(BView*)
SetViewUIColor(color_which, float tint)
SetHighUIColor(...
SetLowUIColor(...
ViewUIColor(float* tint)
HighUIColor(...
LowUIColor(...
DelayedInvalidate()

BWindow gains a simple helper method:
IsOffscreenWindow()

BMessage gains:

AddColor()
FindColor()
GetColor()
HasColor() * allegedly this API is deprecated, but I implemented it anyway
ReplaceColor()
SetColor()

Previous private ColorTools methods are made public and moved into GraphicsDefs:

mix_color, blend_color, disable_color

These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup
of BeOS example code under the OpenTracker license.

In addition, four new colors are created:
B_LINK_TEXT_COLOR
B_LINK_HOVER_COLOR
B_LINK_ACTIVE_COLOR
B_LINK_VISITED_COLOR

These changes are documented in their proper user documentation files.

In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and
used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit.

On the app_server side, the following has changed:

Add DelayedMessage - a system by which messages can be sent at a scheduled time,
and can also be merged according to set rules. A single thread is used to service the
message queue and multiple recipients can be set for each message.
Desktop gains the ability to add message ports to a DelayedMessage so that
said messages can target either all applications or all windows, as needed.

Desktop maintains a BMessage which is used to queue up all pending color changes
and the delayed messaging system is used to enact these changes after a short
period of time has passed. This prevents abuse and allows the system to merge
repeated set_ui_color events into one event for client applications, improving
performance drastically.

In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message
to each BWindow. This is done to improve performance over having the app_server
independently informing each window.

Decorator changes are live now, which required some reworking.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>


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


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


# 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


# 442e7caa 04-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

app_server: Reset current view also when deleting a parent view.

The check that was in place only ensured that the current view was reset
if the current view itself got deleted. Since deleting views works by
token it is possible that a view other than the current view gets
deleted. When a parent of the current view was deleted, which also
deletes all its children, the current view pointer was not reset and
the stale pointer would still be accessed.


# 215119a1 28-Jan-2014 Stephan Aßmus <superstippi@gmx.de>

app_server: Move AlphaMask management into DrawState.

* Give DrawState a real copy constructor, handle deriving in PushState().
(Although clipping region and alpha mask are not cloned, which is on the
other hand just what's needed for now.)
* Combining alpha masks from previous states is not yet handled.
* Remove SetAlphaMask() from DrawingEngine and Painter. It is now done in
SetDrawState().


# a01eaea7 28-Jan-2014 Stephan Aßmus <superstippi@gmx.de>

app_server: Some cleanup of the new clipping code.

* Fixed some coding style issues and use regular pointers like everywhere
else in app_server code.
* Moved _RenderPicture() from View to AlphaMask.


# f08d5477 28-Jan-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Add Alpha Masking support in ClipToPicture

Use AGG to implement ClipToPicture in a faster and better way.
There are things missing in this initial implementation:
* No support for PushState/PopState saving and restoring the picture.
* No support for nested clipping through PushState
* The clipping doesn't happen where you expect it when using SetScale()
* There are artifacts when scrolling and resizing clipped views
* The implementation uses more memory than it needs, as the clipping
bitmap is stored as RGBA32, yet only the alpha channel is used
* The clipping bitmap is rendered more times than it needs to. We need
some caching here.


# 77bf4d8d 21-Jan-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Style fixes.


# e1a30115 21-Jan-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Introduce DrawingContext View superclass

In order to properly implement ClipToPicture in BView, we need to render
a Picture to a Bitmap. This is currently done client-side, but the
overhead for this (creating a BBitmap that accepts views, including a
window thread, adding a view to it, and rendering the picture to the
view, then sending the result to app_server) isn't acceptable. Moreover,
the bitmap drawn this way is clipped to the view size, and the clipping
won't work when the view is scaled or translated. So, we need to move
the Bitmap creation server-side.

However, app_server currently have no means of doing this. Factor out the
relevant parts of View: a DrawingState stack with PushState/PopState, a
DrawingEngine, and a ConvertToScreen transformation. Another implementation
of the DrawingContext will allow us to also draw a picture directly using
a Painter and low-level pixel buffer, in a format suitable for use as an
AGG alpha mask.


# 701dae79 15-Aug-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Squashed a TODO: Added a View::InitCheck() and use it after construction. Removed the check
for View->CurrentState() == NULL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32412 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 991547ef 14-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

Patch by Artur Wyszynski:
* Implemented BGradient, BGradientLinear, BGradientRadial,
BGradientDiamond, BGradientConic and BGradientRadialFocus
new Interface Kit classes.
* Implemented all the (AGG-based) backend necessary in
the app_server to render gradients (Painter, DrawingEngine)
* app_server/View can convert a BGradient layout to screen
coordinates.
* Added BGradient methods of the Fill* methods in BView.
* Implemented a test app and added it to the image as a
demo.
* Adopted Icon-O-Matic and libs/icon in order to avoid
clashing with the new BGradient class. Re-use some
parts where possible.

Awesome work, Artur! Thanks a lot. Now a more modern
looking GUI has just become much easier to implement! :-)

TODO:
* Remove the need to have gradient type twice in the
app_server protocol.
* Refactor some parts of the patch to remove duplicated
code (Painter, DrawingEngine).
* Adopt the BPicture protocol to know about BGradients.
* Review some parts of the BArchivable implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28109 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 581e6786 09-Jun-2008 Stephan Aßmus <superstippi@gmx.de>

* Change the protocol for sending the affected view tokens during an update
session to also include each view's individual update rect (in screen coords).
Should actually not be mush slower than the old version, and hopefully makes
it possible to have smarter BView::Draw() implementations which should make
more than up for any potential speed loss.
* Removed unused version of View::AddTokensForViewsInRegion().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25879 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0c3c996 07-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

* Decouple local and user clipping into normal local clipping and a user
clipping region pointer.
* Provide _ScreenClipping() that only includes local and screen clipping but
not user clipping.
* Provide ScreenAndUserClipping() that returns screen clipping if no user
clipping is present, or returns a combined region that is then cached.
* Adapt all places where the former methods are used and decide which one to
use depending on the relevance of user clipping.

User clipping is now ignored for background clearing and when determining
whether or not to call Draw() on a view. This should make Haiku behaviourally
compatible with BeOS (confirmed by the ClippingAndRedraw test app) and should
also fix the Firefox redraw issues. Stephan please review!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25854 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 437b1927 08-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed severly outdated DebugInfoManager.
* More "layer" cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24305 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 953d895e 07-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Got rid of the "Layer" part of WindowLayer, ViewLayer, WorkspacesLayer
(now WorkspacesView), OffscreenWindowLayer.
* Renamed ServerScreen.cpp/h to Screen.cpp/h (the class was already called
Screen).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24303 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 442e7caa49ef934eb4c8562e29442fa49775bd46 04-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

app_server: Reset current view also when deleting a parent view.

The check that was in place only ensured that the current view was reset
if the current view itself got deleted. Since deleting views works by
token it is possible that a view other than the current view gets
deleted. When a parent of the current view was deleted, which also
deletes all its children, the current view pointer was not reset and
the stale pointer would still be accessed.


# 215119a1e73029a7165a1c01dfa3ceb4a90d44bf 28-Jan-2014 Stephan Aßmus <superstippi@gmx.de>

app_server: Move AlphaMask management into DrawState.

* Give DrawState a real copy constructor, handle deriving in PushState().
(Although clipping region and alpha mask are not cloned, which is on the
other hand just what's needed for now.)
* Combining alpha masks from previous states is not yet handled.
* Remove SetAlphaMask() from DrawingEngine and Painter. It is now done in
SetDrawState().


# a01eaea74bd23df74fd56411b94e56888bb7f98d 28-Jan-2014 Stephan Aßmus <superstippi@gmx.de>

app_server: Some cleanup of the new clipping code.

* Fixed some coding style issues and use regular pointers like everywhere
else in app_server code.
* Moved _RenderPicture() from View to AlphaMask.


# f08d5477d8b854d8ae33801ad4aaf3c78008df11 28-Jan-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Add Alpha Masking support in ClipToPicture

Use AGG to implement ClipToPicture in a faster and better way.
There are things missing in this initial implementation:
* No support for PushState/PopState saving and restoring the picture.
* No support for nested clipping through PushState
* The clipping doesn't happen where you expect it when using SetScale()
* There are artifacts when scrolling and resizing clipped views
* The implementation uses more memory than it needs, as the clipping
bitmap is stored as RGBA32, yet only the alpha channel is used
* The clipping bitmap is rendered more times than it needs to. We need
some caching here.


# 77bf4d8d5156816e701b47476cf4c07bc7a4ebc2 21-Jan-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Style fixes.


# e1a301151feebf3c335202071b5d3c38c40b2f9a 21-Jan-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Introduce DrawingContext View superclass

In order to properly implement ClipToPicture in BView, we need to render
a Picture to a Bitmap. This is currently done client-side, but the
overhead for this (creating a BBitmap that accepts views, including a
window thread, adding a view to it, and rendering the picture to the
view, then sending the result to app_server) isn't acceptable. Moreover,
the bitmap drawn this way is clipped to the view size, and the clipping
won't work when the view is scaled or translated. So, we need to move
the Bitmap creation server-side.

However, app_server currently have no means of doing this. Factor out the
relevant parts of View: a DrawingState stack with PushState/PopState, a
DrawingEngine, and a ConvertToScreen transformation. Another implementation
of the DrawingContext will allow us to also draw a picture directly using
a Painter and low-level pixel buffer, in a format suitable for use as an
AGG alpha mask.


# 701dae79c9013ed0f4474c6ef845813678f993d5 15-Aug-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Squashed a TODO: Added a View::InitCheck() and use it after construction. Removed the check
for View->CurrentState() == NULL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32412 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 991547ef6c1fca650f0fba855206296ef54bc441 14-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

Patch by Artur Wyszynski:
* Implemented BGradient, BGradientLinear, BGradientRadial,
BGradientDiamond, BGradientConic and BGradientRadialFocus
new Interface Kit classes.
* Implemented all the (AGG-based) backend necessary in
the app_server to render gradients (Painter, DrawingEngine)
* app_server/View can convert a BGradient layout to screen
coordinates.
* Added BGradient methods of the Fill* methods in BView.
* Implemented a test app and added it to the image as a
demo.
* Adopted Icon-O-Matic and libs/icon in order to avoid
clashing with the new BGradient class. Re-use some
parts where possible.

Awesome work, Artur! Thanks a lot. Now a more modern
looking GUI has just become much easier to implement! :-)

TODO:
* Remove the need to have gradient type twice in the
app_server protocol.
* Refactor some parts of the patch to remove duplicated
code (Painter, DrawingEngine).
* Adopt the BPicture protocol to know about BGradients.
* Review some parts of the BArchivable implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28109 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 581e67867c88e4dae51de5c30839eabd303cc0a9 09-Jun-2008 Stephan Aßmus <superstippi@gmx.de>

* Change the protocol for sending the affected view tokens during an update
session to also include each view's individual update rect (in screen coords).
Should actually not be mush slower than the old version, and hopefully makes
it possible to have smarter BView::Draw() implementations which should make
more than up for any potential speed loss.
* Removed unused version of View::AddTokensForViewsInRegion().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25879 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0c3c996cd92350f083210e5cc0d161abbbc3aa1 07-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

* Decouple local and user clipping into normal local clipping and a user
clipping region pointer.
* Provide _ScreenClipping() that only includes local and screen clipping but
not user clipping.
* Provide ScreenAndUserClipping() that returns screen clipping if no user
clipping is present, or returns a combined region that is then cached.
* Adapt all places where the former methods are used and decide which one to
use depending on the relevance of user clipping.

User clipping is now ignored for background clearing and when determining
whether or not to call Draw() on a view. This should make Haiku behaviourally
compatible with BeOS (confirmed by the ClippingAndRedraw test app) and should
also fix the Firefox redraw issues. Stephan please review!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25854 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 437b19277feacd48292ca9ec814a38da17e4eb89 08-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed severly outdated DebugInfoManager.
* More "layer" cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24305 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 953d895e020ece5d50cfc2e76d9f370ceb5c45e7 07-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Got rid of the "Layer" part of WindowLayer, ViewLayer, WorkspacesLayer
(now WorkspacesView), OffscreenWindowLayer.
* Renamed ServerScreen.cpp/h to Screen.cpp/h (the class was already called
Screen).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24303 a95241bf-73f2-0310-859d-f6bbb57e9c96