History log of /haiku/src/servers/app/DrawState.h
Revision Date Author Comments
# 85b82f85 19-Jul-2022 Dale Cieslak <dcieslak@yahoo.com>

BFont: allow loading of user fonts from disk or memory

This patch adds an API call to BFont, called LoadFont, that
takes a string path to a font file. The user fonts are managed
via a new class called AppFontManager that inherits from the base
class FontManagerBase but adds the methods to add and remove user
fonts from disk or memory. There is also a new method called UnloadFont
to remove a user font, but on exit of an app all user fonts should be
automatically cleaned up.

Global/system fonts are managed by the GlobalFontManager, which is
a new class that also inherits from the base class FontManagerBase,
replacing the old "FontManager" class.

A maximum of 128 user fonts may be loaded, and memory fonts
may not exceed 20MB.

There's also an overloaded version of LoadFont that accepts
an area_id and loads the font from memory. A size and offset may
optionally be provided to allow for an area that contains more
than just a font.

Change-Id: I6add42bdf0c0cefc0e2e2a4984fd848c3e7269e5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4790
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


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


# 1876ba00 02-Jan-2019 Stephan Aßmus <superstippi@gmx.de>

DrawState: Return mask from ReadFontFromLink()

When changing the font state, a uin16 mask at the beginning of the
commands encodes which font parameters are transmitted in the link
data. Return this mask, so that one can know what parameters have
changed in the DrawState's ServerFont.

Change-Id: I52a9a665aac8eb0e6505193eba32c4b137846c78
Reviewed-on: https://review.haiku-os.org/814
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


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


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


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

app_server: Drawing mode fixups

* TODO: squash commit before merge into master


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

app_server: allow drawing mode changes in opaque layers

* For better performance, we allow doing drawing mode changes
(and thus, B_OP_COPY) again when inside an opaque layer which
has only other opaque layers below it in the layer stack.

As soon as the first non-opaque layer turns up in the stack, the
drawing mode will be locked to alpha composite mode, until this
layer stack is ended entirely.

This allows using B_OP_COPY in many cases as used by WebKit.

* In the long term it would be nice to get rid of the drawing-mode
lock altogether, however that would need some larger refactoring
work in Painter (i.e. remove the offsetting from renderer_region
again and instead implement an "exit-level transform" (support
for offsets is enough) in Painter which is applied after all other
transforms).


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

app_server: allow disabling affine transforms in DrawState

* New method DrawState::SetTransformEnabled allows to temporarily
disable all BAffineTransforms in the state stack (up to 'this').
Later, the same method can be used to reenable the transforms.

Needed for layers support: when drawing the finished layer bitmap
onto the view, the affine transforms must not be applied again --
they have already been applied while drawing the bitmap's contents.


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

app_server: add Squash method in DrawState

* New method DrawState::Squash() uses the combined scale, origin and
transform as the state's own scale, origin, transform.

This can be used when making copies of DrawStates which have
previous states below them in the state stack. The top of stack
DrawState can be copied, squashed and then used just like the
original one with the whole stack below it (except of course
when trying to pop off any earlier state).


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


# eb431663 11-Mar-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

app_server & interface kit: support fill rules.

* BView gets SetFillRule/FillRule methods. The fill rule is part of the
view state.
* The B_NONZERO rule is the default. This is what we implemented before.
* The B_EVEN_ODD rule is the other common possibility for this, and
we need to support it to help WebKit to render properly.


# a6db6bd4 04-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

Added WIP support for affine transformations to BViews.

Everything untested, but compiles, so it must work. The idea is to introduce
BAffineTransform additionally to the existing Origin and Scale properties of
BViews. One may use it in parallel or as an alternative. Painter in app_server
is not yet aware of the additional transformation. It is however already used
to transform drawing coordinates. It probably needs to work differently,
perhaps only in Painter and AGGTextRenderer.


# ad3318b3 01-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

DrawState: Coding style cleanup


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


# f4f30311 24-Jul-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Cleanup app server directory a bit by creating a font and a decorator sub folder.



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


# 2e44cfce 29-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

Make BView::PopState() (executed at least on every call to Draw()) a lot
cheaper by preventing to rebuild the clipping on the app_server side.
I think this was commented out, because user clipping was broken until
some point and I forgot to reenable it after I fixed it. At least I cannot
spot any regressions when running with this patch now would I expect to
see regressions, since DrawStates do not mess with the screen clipping,
unless they get a clipping region assigned when the (user) clipping changes
during the state's life time.


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


# 79ef179c 17-Mar-2008 Stephan Aßmus <superstippi@gmx.de>

A test app revealed some bugs with regards to client provided clipping regions:
* It is necessary to store the local origin and scale of a view state, at
least for the clipping region and especially because the scale affects the
clipping region. Ie origin and scale of one state affect the clipping region,
at the time the clipping is evaluated, ie
SetOrigin(...);
ConstrainClippingRegion(...);
is equivalent to
ConstrainClippingRegion(...);
SetOrigin(...);
The current client provided clipping region at the time of PushState()
always constrains the region of the new state. The previous region
and the current local clipping may have their own individual origin and
scale.
To support all this, I needed to store origin and scale of each state on
the stack, but I do cache the combined origin and scale. Caching only
the combined region is not possible though. So the new implementation
is slower than the previous, but more correct.
* Refactored "copy constructor" from DrawState, which is not really a copy
constructor anyways, made it private. It is only used by PushState().
* Removed some dead code from DrawState.

All this improves Firefox redraw issues a tiny bit, but does not fix them.
Either I am not covering Firefox needs with my test app, or the bug is
somewhere else. At least Haiku behaves like BeOS with regard to client
clipping regions and the state stack now...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24428 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


# f7e1df75 16-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* get rid of RGBColor usage where it is not needed, this simplified many things,
possibly making them a little faster too
* mess with decorator button size calculation to make the whole layout scale
more agreeable with the font size (no more fixed offsets/insets), but it
is work in progress
* DefaultDecorator no longer allocated the border color array, it is part of
the object now
* small memory footprint optimizations in ViewLayer, Decorator and WindowLayer


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


# aaa42c7e 08-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* added a way to get the unscaled pensize (ie that of the current draw state
of a view)


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


# 16ed1e1d 18-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed headers/private/servers/app - everything is in src/servers/app now.
* Removed DisplaySupport.h, wasn't needed anymore.
* Removed private color set functions from InterfaceDefs.cpp - we might want
something similar, but definitely not like that.
* Minor cleanup, added some missing licenses.


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


# eb431663264ef319e72b492801fb867b5d71910b 11-Mar-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

app_server & interface kit: support fill rules.

* BView gets SetFillRule/FillRule methods. The fill rule is part of the
view state.
* The B_NONZERO rule is the default. This is what we implemented before.
* The B_EVEN_ODD rule is the other common possibility for this, and
we need to support it to help WebKit to render properly.


# a6db6bd40fe3492fd3104dba560f0e3ff61d388d 04-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

Added WIP support for affine transformations to BViews.

Everything untested, but compiles, so it must work. The idea is to introduce
BAffineTransform additionally to the existing Origin and Scale properties of
BViews. One may use it in parallel or as an alternative. Painter in app_server
is not yet aware of the additional transformation. It is however already used
to transform drawing coordinates. It probably needs to work differently,
perhaps only in Painter and AGGTextRenderer.


# ad3318b33ddeb82da503236224bbf41c98fd9262 01-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

DrawState: Coding style cleanup


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


# f4f30311aab9b2768d3ef7e590f85598298edfe0 24-Jul-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Cleanup app server directory a bit by creating a font and a decorator sub folder.



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


# 2e44cfce6671cbb0a5a1658fbb197899def3c73b 29-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

Make BView::PopState() (executed at least on every call to Draw()) a lot
cheaper by preventing to rebuild the clipping on the app_server side.
I think this was commented out, because user clipping was broken until
some point and I forgot to reenable it after I fixed it. At least I cannot
spot any regressions when running with this patch now would I expect to
see regressions, since DrawStates do not mess with the screen clipping,
unless they get a clipping region assigned when the (user) clipping changes
during the state's life time.


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


# 79ef179c52ff23c1338a34a95452114d51bffeda 17-Mar-2008 Stephan Aßmus <superstippi@gmx.de>

A test app revealed some bugs with regards to client provided clipping regions:
* It is necessary to store the local origin and scale of a view state, at
least for the clipping region and especially because the scale affects the
clipping region. Ie origin and scale of one state affect the clipping region,
at the time the clipping is evaluated, ie
SetOrigin(...);
ConstrainClippingRegion(...);
is equivalent to
ConstrainClippingRegion(...);
SetOrigin(...);
The current client provided clipping region at the time of PushState()
always constrains the region of the new state. The previous region
and the current local clipping may have their own individual origin and
scale.
To support all this, I needed to store origin and scale of each state on
the stack, but I do cache the combined origin and scale. Caching only
the combined region is not possible though. So the new implementation
is slower than the previous, but more correct.
* Refactored "copy constructor" from DrawState, which is not really a copy
constructor anyways, made it private. It is only used by PushState().
* Removed some dead code from DrawState.

All this improves Firefox redraw issues a tiny bit, but does not fix them.
Either I am not covering Firefox needs with my test app, or the bug is
somewhere else. At least Haiku behaves like BeOS with regard to client
clipping regions and the state stack now...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24428 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


# f7e1df75609966bdfdb4ed39edf26dd145d8221f 16-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* get rid of RGBColor usage where it is not needed, this simplified many things,
possibly making them a little faster too
* mess with decorator button size calculation to make the whole layout scale
more agreeable with the font size (no more fixed offsets/insets), but it
is work in progress
* DefaultDecorator no longer allocated the border color array, it is part of
the object now
* small memory footprint optimizations in ViewLayer, Decorator and WindowLayer


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


# aaa42c7e223b458bbf0e4a2ded7197d9234f76d8 08-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* added a way to get the unscaled pensize (ie that of the current draw state
of a view)


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


# 16ed1e1d15aac69c945890e5d5990bb41d9f4303 18-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed headers/private/servers/app - everything is in src/servers/app now.
* Removed DisplaySupport.h, wasn't needed anymore.
* Removed private color set functions from InterfaceDefs.cpp - we might want
something similar, but definitely not like that.
* Minor cleanup, added some missing licenses.


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