Commit Graph

2815 Commits

Author SHA1 Message Date
Augustin Cavalier 0cdb323800 app_server & Application Kit: Fix bitmap cursor handling.
Using a memcpy here is supremely dangerous, because we are writing to
an app_server buffer that we chose the length for, but using a size
that came from the client. And, indeed, because the buffer can contain
padding if the BBitmap was allocated with a non-standard BytesPerRow,
we will overflow the buffer and corrupt memory, causing app_server to crash.

So, instead, reorganize parameters a bit, and pass BytesPerRow along
with the other data needed to instantiate the bitmap, and then use
ImportBits.

Fixes an app_server crash I triggered with the experimental libX11
compatibility layer.
2021-12-11 21:44:59 -05:00
Augustin Cavalier ba3ee26af0 WindowInfo: Use char[0] for FLA instead of char[1].
This is a private structure, so despite being an ABI break,
it should not cause any problems.
2021-11-23 13:50:45 -05:00
Augustin Cavalier 44e3766be5 app_server: Add casts to appease GCC 11 -Wclass-memaccess. 2021-11-17 14:00:10 -05:00
Augustin Cavalier a04b2f4c5e Launch app_server in user context.
This way, we get the user's environment variables, and so should
input_server, which is started by app_server.

This should, after 6 years, fix #12534. We may need to revisit this
when/if we add multiuser support, but that is a problem for another day.

Change-Id: I04698306bc68a585acd232e9f9d29c50bc170a1f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4506
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-10-26 19:20:53 +00:00
Augustin Cavalier 778706215d app_server: Drop gfxcpy and implement some TODOs about checking for graphics memory.
We still do not know if the accelerant buffers are graphics memory or not,
but in my testing (on the VESA driver), the only time I could get _CopyRect
to be called was where the buffer was in fact not graphics memory.
So that should provide a performance improvement there.

On the other end of things, this should resolve unaligned video memory
access problems on RISCV, and potentially other platforms, as gfxcpy32
did not attempt to align pointers; it should also improve performance
as memcpy will usually be faster than our custom gfxcpy here.

Most of this code has not been touched since 2006 or so.

Change-Id: I40b0345c5d47f2b45acafb14f03fd3a24d2042a8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4315
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2021-10-23 00:40:53 +00:00
Augustin Cavalier b419a79f8f app_server: Remove IsDoubleBuffered() default implementation from HWInterface.
It just causes confusion and is wrong in the case where double buffering
status changed during the object lifetime.

Change-Id: Ia1a9ae3f5a1b1b7d521b79c7d1c7be92cef60a06
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4633
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-10-22 21:05:35 +00:00
Augustin Cavalier 411ccfeb96 app_server: Treat the framebuffer driver as a special case like VESA.
This should resolve the problems where the framebuffer driver was
getting picked instead of the "real" graphics driver, when available,
which led to the framebuffer driver getting merged back into the VESA
driver.

Change-Id: I4ad00d2ac3b5dda34aa63f8691d4cbb85e4f6bb5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4616
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-10-20 17:12:21 +00:00
Máximo Castañeda b009ef381b 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>
2021-10-14 18:49:18 +00:00
Jérôme Duval 947d3b862b app_server: handle RGB48 and RGBA64 in switches
Change-Id: I14019b3285e036eba4b73effd79d7e1b4181daeb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4558
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-10-08 15:06:07 +00:00
Augustin Cavalier 37ea891aad Enable -fvisibility=hidden on static libraries by default.
Only on non-GCC2 for now, as GCC2 does not have -fvisibility.

An opt-out is left as a possibility, and is unfortunately necessary
for libshared and libicon, as these two are used even in WebKit instead
of linking to the .a. However, libcolumnlistview, libagg, and a whole
bunch of others are now no longer exported, so this is already a major
improvement on what symbols we were leaking.

This may provide performance differences for consumers of these APIs,
as GCC and the linker are now free to merge and directly use functions
that previously could have been semantically interposed. AGG usage in
app_server, especially, may benefit.

We can also now remove the addition from libnetservices, so do that.
2021-09-08 17:32:47 -04:00
Adrien Destugues 1c88f77dcc app_server: turn DPMS on only after setting a valid mode
It's not allowed to enable the screen before having set a mode. At least
in the case of the intel_extreme driver, this creates some problem. Move
the call just a bit later in the init process, where the mode is already
set.

Change-Id: Iaa665f0edc15316890032f1a5928f33634dc8749
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4362
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: François Revol <revol@free.fr>
Reviewed-by: <BeagleJoe13@gmail.com>
2021-08-24 15:05:45 +00:00
Kacper Kasper ef83008e79 app_server: add B_UNDERSCORE_FACE support
There was some confusion (and a TODO indicating it) in ServerFont.cpp,
because the notion of "font face" from the Be API is partially
implemented using different font manager styles (bold, italic, etc),
and partially by keeping flags in a separate variable for drawing
extra things or modifying the drawing (underscore, strikeout, ...).

The implementation did not actually preserve the extra flags, and so the
underscore face attribute was lost.

Implement the actual underlining of the text in AGGTextRenderer. This
implementation is a naive one so far. In particular there are the
following limitations:
1. Line is drawn over the text - no nice gaps for descents. Ideally, the
   line should not touch the letter descents, and leave some space
   around them. I don't know how to retrieve the contour - it appears to
   me this might require bigger refactoring of this code. I have left in
   my experiments commented out in the code.
2. If the text run ends with whitespace, the whitespace is not underlined
   as it should. In particular if another text run is drawn next to it
   and it's expected that the underline is continuous between the two.

Change-Id: I8d78b8e1eceddff0a7d98e5a49659e7b03fd89a0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3041
Reviewed-by: Kacper Kasper <kacperkasper@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2021-07-25 08:39:57 +00:00
François Revol 627fb72d50 app_server: only turn screens on once at start
Previous code from hrev55212 was triggered on every workspaces change.

Fixes #17078.

Change-Id: I13108cddbd57662650e06c05bd43931c12b3dfae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4208
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-07-24 19:35:49 +00:00
X512 2641b03c91 app_server: fix integer overflow in ServerBitmap
Integer overflow caused bitmap buffer creation of wrong size and out of
bounds access when large bitmap was created. Now allocation failure is
reported for large bitmaps.

This prevents app_server from crashing while playing YouTube in WebPositive.

Fixes #16489.

Change-Id: I297aa6e3b79b32a486d297f1239a1fd4397a8a36
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4209
Reviewed-by: Sergei Reznikov <diver@gelios.net>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2021-07-14 20:25:00 +00:00
Máximo Castañeda 22dda7795d GlyphLayout: emit .nodef glyph for missing glyphs
Use glyph 0 when no glyph is found for a character in the current font
nor any of the fallbacks.

HasGlyphs has to bypass LayoutGlyphs because we want it to mark this
case as false, while still checking the fallbacks.

Change-Id: Ief8d9d53c91992c659922fb56b79be7172f4ab0d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4144
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-07-11 12:14:01 +00:00
X512 cc265c1482 app_server: turn on screen on start
Screen may be turned off if video card is not supported by firmware and boot
loader.

Change-Id: Ie60fc00da281ec3781084dd97466a68b885fde7b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4114
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-07-03 09:17:36 +00:00
Adrien Destugues 6aec6b1c9a app_server: add Noto Emoji to font fallback list.
Helps with #16221 (somehow it doesn't seem to matter if the font is
installed or not?)
2021-06-26 16:55:41 +02:00
Máximo Castañeda a60e5cb46e Get font metrics from a bitmap if there are no outlines
FreeType only provides some font parameters for scalable fonts. In
particular, we use the FT_Face values of units_per_EM, ascender,
descender and height, which are 0 for bitmap-only fonts.

Part of #16938.

Change-Id: Iea2d87ad95f3bc1c2e27fb041da0a27c6e68be91
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4042
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-06-04 07:39:02 +00:00
Tri-Edge AI 773d5303d1 app_server: Implement B_OUTLINE_RESIZE
- Allows applications to be resized without the window contents resizing with the window frame.
- Due to the nature of out-of-tree decorators using private APIs, this will require all pre-existing decorators to be rebuilt
- Newer decorators won't work on older versions of Haiku...
- Also has some formatting with license headers.
- Fixes #2724

Change-Id: Id0b45e7bbc0b636e6dffbd396eb584bf348b5296
Reviewed-on: https://review.haiku-os.org/c/haiku/+/344
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Jacob Secunda <secundaja@gmail.com>
2021-03-19 10:17:01 +00:00
Murai Takashi 741032ea6d servers/app: Fix double delete
Pointed out by Clang Static Analyzer.

Change-Id: Ifba9ffd03a49fd66cc3e3c7cacaee641b7e939ab
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3774
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-03-16 17:01:47 +00:00
Máximo Castañeda 6c04dd4898 Fix subpixel scanline size for fonts with bitmaps
Fixes #16788

Change-Id: If4c5a6e37ab5950c2426286d5afab59652a2a61b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3743
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-02-28 11:16:22 +00:00
X512 779ab335dd 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>
2021-02-02 15:17:54 +00:00
X512 ebe6011c58 app_server: do not flush back buffer outside of clipping
Introduce DrawTransaction that automatically hide/show floating overlays
and flush back buffer.

Fixes #15574.

Change-Id: I30088b74fc66cfcd5b2b433b34141e7d496f68a1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3496
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2020-12-15 12:00:12 +00:00
Adrien Destugues 5d1042057b Add Noto Sans Symbols2 to font fallbacks
Also use the correct symbol for the return key (we were using another
similar arrow because this one was not available in DejaVu Sans).

Fixes #14034.

Note that build/jam/repositories/HaikuPorts ships an old version of the
Noto package that does not include the Symbols2 font. It should be
updated. Adding this to the pile of lagging behind packages, alongside
icu, mawk/gawk, and tnftp. Can anyone take care of it?
2020-12-09 20:00:26 +01:00
X512 d99d8dbdd2 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>
2020-12-03 18:45:14 +00:00
Adrien Destugues 5f51a74f1a 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.
2020-12-02 20:05:20 +01:00
X512 60d3078585 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>
2020-12-02 17:59:06 +00:00
Máximo Castañeda a1c9aa9d90 Get a fallback font for each missing character
Make the glyph layout engine look for a suitable font fallback for each
missing character, instead of using the first one found for all of them.

Solves #16404, #16213, maybe other garbled text issues.

Does not solve similar issues of getting slightly different positions and
widths for a whole string than for the sum of its parts due to subpixel
rendering (cf #15007 comment 2).

Change-Id: I40664e32c8ecd5f09e10aa7a60fcdaec230471b6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3273
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-01 11:45:27 +00:00
X512 be3fde6d02 app_server: perform NULL check before use
Fixes #16610.

Change-Id: Ic377a2faef7279f607298b3b80bc44bc1c6aae36
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3401
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2020-11-20 18:24:48 +00:00
Murai Takashi f7fbc22a58 servers/app: Fix -Wformat-security
Change-Id: Ia2ad0aac295c7a1ce3aafe571ae71f3aa8a4f433
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3346
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-10-23 07:11:59 +00:00
Jérôme Duval 06ed32b8c4 BCursor: add a constructor with bitmap and point
* enhancement #15169
* get_mouse_bitmap(): also reads the colorspace from app_server.
* docs and tests

Change-Id: Iba63f8a2789530ae596c30b92f14828f31761d98
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3292
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-10-08 08:23:31 +00:00
Adrien Destugues 0d87f2555a app_server: missing null pointer check.
Should fix #16551.
2020-09-29 20:01:46 +02:00
Adrien Destugues 7ace34a6ba app_server: don't reset brightness when switching workspaces
Fixes #16538.
2020-09-28 20:51:10 +02:00
Adrien Destugues 8b2b301059 app_server: save/restore screen brightness settings
The brightness is saved in the screen configurations of the first
workspace. For now, all screens get the same brightness (I can't get
screen IDs to work today). Since we only support setting the brightness
for laptop displays for now, this shouldn't matter. It can be fixed when
app_server gets actual multiple display support.

Fixes #14254

Change-Id: Ib33aa65a73407a65bd469d0efa8542210fec02d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/362
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-20 13:30:29 +00:00
Adrien Destugues a99221e61a build fix. 2020-09-19 11:07:06 +02:00
X512 6fd2274306 app_server pointer/ownership cleanup: trivial changes
Split apart the work done in https://review.haiku-os.org/c/haiku/+/2695
in smaller, easier to review parts.

This commit contains self-contained/local changes that are unlikely to
cause problems.

Change-Id: Idae27ca440791423e3d090bcfe33f4cc83bbea3d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3174
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-19 07:13:19 +00:00
John Scipione 90f9b5590f App Server: Save decorator path on load, fixes #16412
Change-Id: Ia536764d4abb79772e4d3f16e2364d87792d60fd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3150
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-08-19 03:22:09 +00:00
Adrien Destugues b78a83eb29 app_server: Style fix 2020-07-29 20:13:58 +02:00
Adrien Destugues fd3f9c4126 Allow setting a "full and half fixed" font as the system fixed font.
Fixes #14424.
2020-07-29 20:13:58 +02:00
Emir SARI 60a6f1d5d7 Set Noto Sans Mono as monospace default font
Should help improve [1].

[1]: https://github.com/haikuports/haikuports/issues/3116

Change-Id: I29dd94e3380c3a5935d47d97e2a2ac1c5fb7e774
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3070
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-07-28 16:42:18 +00:00
X512 4399ec510d BPicture: add fill rule support
Change-Id: I068e1c2e8659f7b90c6d7c7331a8bb25ae343fe9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2922
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-07-12 19:44:43 +00:00
X512 90ab1a44ad BPicture: add gradient support
Fixes #9680.

Change-Id: I0013326559cc40ff26cf7b44794c0b32aea832ba
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2829
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2020-07-12 19:44:43 +00:00
Adrien Destugues 4ad808b67d app_server: Fix clipping computation in DrawArc
The clipped rect was extended with the stroke width, and then the result
was overwritten.

Fixes #3130.
2020-07-12 13:11:11 +02:00
Kacper Kasper 2899294cf1 app_server: Fix assert in DrawStringDry
Change-Id: I58b86860367df86b77bbdffadeff9843c9c8ab11
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2958
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-07-03 08:15:17 +00:00
Kacper Kasper 009df98c86 app_server: Fix gcc2 build 2020-06-29 19:44:57 +02:00
Kacper Kasper 97bd6fe8d4 app_server: Implement more composition modes
* Use agg::comp_op classes to blend pixels.
* Subpixel path not implemented.
* Needed by WebKit.
* Implements #10274.

Change-Id: I07b0002196fd0a05fc100bd9f6d703c33cadc85b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2932
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-06-29 14:07:42 +00:00
Augustin Cavalier 176d0e1041 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.
2020-06-20 20:02:35 -04:00
Augustin Cavalier 67ace0bfab 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.)
2020-06-20 19:46:22 -04:00
X512 111247c842 app_server: match behavior when drawing to BPicture
Change-Id: I7676e73bda0eb02a1905888706aab6bb1db401d5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2892
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-06-20 18:33:30 +00:00
Kacper Kasper c63d300251 app_server: fix tiled drawing when phase is outside bitmap bounds
sourceRect has phase baked in. If phasecomponents are larger than bitamp bounds
sourceRect no longer intersects and nothing gets drawn.

Change-Id: Ib3f676b8e78e2d941c89e699f9a0ab39cc93e173
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2916
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-06-13 20:35:29 +00:00