Commit Graph

2928 Commits

Author SHA1 Message Date
Andreas Kling
dcbddb4f8c GraphicsBitmap: Provide templated versions of get_pixel() and set_pixel().
If we already know the bitmap format used, we can use these functions to
bypass the format checks and go straight to pixel manipulation.
2019-06-15 11:06:02 +02:00
Andreas Kling
150b3cf378 PaintBrush: Fix some silly logic typos in flood fill. 2019-06-15 10:48:20 +02:00
Andreas Kling
a8b2b96f38 PaintBrush: Use a Queue<Point> for the flood fill. 2019-06-15 10:39:45 +02:00
Andreas Kling
bfaa74f076 AK/Tests: Test Queue<String> with large number of elements. 2019-06-15 10:39:19 +02:00
Andreas Kling
c699d9d79d AK: Add a simple Queue<T> class.
The underlying data structure is a singly-linked list of Vector<T>.
We never shift any of the vector contents around, but we batch the memory
allocations into 1000-element segments.
2019-06-15 10:35:35 +02:00
Andreas Kling
9443957c14 PaintBrush: Speed up the bucket tool with smarter use of Vector.
Put together a pretty well-performing queue using a Vector and an offset.
By using the new Vector::shift_left(int) instead of Vector::take_first()
we can avoid shifting the vector contents every time and instead only
do it every so often.

Maybe this could be generalized into a separate class, I'm not sure if it's
the best algorithm though, it's just what I came up with right now. :^)
2019-06-14 21:50:28 +02:00
Andreas Kling
e9c021de92 PaintBrush: Implement a naive but working bucket fill tool.
I've used a SinglyLinkedList<Point> for the flood fill queue, since Vector
was death slow. This could definitely be made faster with a better algorithm
and/or data structure. :^)
2019-06-14 19:11:22 +02:00
Andreas Kling
1ec5172ce1 GraphicsBitmap: Add set_pixel(x, y, Color)
This only works for RGB32 and RGBA32 formats.
2019-06-14 19:10:59 +02:00
Andreas Kling
ae598116f4 Color: Add equality operators. 2019-06-14 19:10:43 +02:00
Andreas Kling
56cbe15033 PaintBrush: Factor out the pen tool into an actual PenTool class.
Also add a Tool base class, and an empty BucketTool subclass which is the
next thing to implement.
2019-06-14 18:51:57 +02:00
Andreas Kling
a12751695e AK/Tests: Add a simple EXPECT_EQ macro and use it for the String test. 2019-06-14 17:52:51 +02:00
Andreas Kling
3557f277f6 AK/Tests: Add some macros for testing. 2019-06-14 17:38:17 +02:00
Sergey Bugaev
d900fe98e2 VM: Remove PhysicalPage::create_eternal().
Now that it is possible to create non-eternal non-freeable
pages, PageDirectory can do just that.
2019-06-14 16:14:49 +02:00
Sergey Bugaev
010314ee66 VM: Make VMObject::create_for_physical_range() create non-freeable pages.
This method is used in BXVGADevice to create pages for the framebuffer;
we should neither make the PhysicalPage instances eternal, nor hand over
actual physical pages to the memory allocator.
2019-06-14 16:14:49 +02:00
Sergey Bugaev
a8e86841ce VM: Support non-freeable, non-eternal PhysicalPages. 2019-06-14 16:14:49 +02:00
Sergey Bugaev
6bb7c80365 VM: Fix leaking PhysicalPage instances.
After PhysicalPage::return_to_freelist(), an actual physical page
is returned back to the memory manager; which will create a new
PhysicalPage instance if it decides to reuse the physical page. This
means this PhysicalPage instance should be freed; otherwise it would
get leaked.
2019-06-14 16:14:49 +02:00
Sergey Bugaev
118cb391dd VM: Pass a PhysicalPage by rvalue reference when returning it to the freelist.
This makes no functional difference, but it makes it clear that
MemoryManager and PhysicalRegion take over the actual physical
page represented by this PhysicalPage instance.
2019-06-14 16:14:49 +02:00
Sergey Bugaev
7710e48d83 VM: Fix freeing physical pages.
Pages created with PhysicalPage::create_eternal() should *not* be
returnable to the freelist; and pages created with the regular
PhysicalPage::create() should be; not the other way around.
2019-06-14 16:14:49 +02:00
Andreas Kling
0589ef2886 AK/Tests: Add a couple more String tests. 2019-06-14 07:40:36 +02:00
Andreas Kling
255c7562ba AK: Massage it into building on my host system without breaking Serenity. 2019-06-14 06:43:56 +02:00
Andreas Kling
b7cca76ca2 AK: Add an extremely primitive unit test for String.
This builds for the host system rather than for Serenity.
We need to improve on it a *lot*, but at least it's a place to start.
2019-06-14 06:42:21 +02:00
Sergey Bugaev
802612f665 Shell: Implement more advanced globbing.
A glob has to be resolved against the directory corresponding to
the part of the path it is found in, not the current directory.
For example, in /usr/i*/AK/, the glob has to be resolved inside
/usr. Moreover, an argument can contain more than one glob, such
as /u*/*/?, in which case they have to be resolved recursively.

In case a glob matches nothing, the argument should be used as is.
2019-06-14 06:24:02 +02:00
Sergey Bugaev
d211307547 Kernel: Fix KResultOr move constructor not copying errors. 2019-06-14 06:24:02 +02:00
Sergey Bugaev
27203369b4 Kernel: Fix not returning errors for the last path item.
Previously the check for an empty part would happen before the
check for access and for the parent being a directory, and so an
error in those would not be detected.
2019-06-14 06:24:02 +02:00
Sergey Bugaev
1a697f70db AK: Add more StringView utilities for making substrings.
These two allow making a new substring view starting from,
or starting after, an existing substring view.

Also make use of one of them in the kernel.
2019-06-14 06:24:02 +02:00
Sergey Bugaev
3e326de8fa AK: Fix nullptr dereference in String::matches().
In case cp and mp were never set, we should not try
to use them.
2019-06-14 06:24:02 +02:00
Sergey Bugaev
e585ed48b0 AK: Fix String::matches() with non-null-terminated StringViews.
StringView character buffer is not guaranteed to be null-terminated;
in particular it will not be null-terminated when making a substring.
This means it is not correct to check whether we've reached the end
of a StringView by comparing the next character to null; instead, we
need to do an explicit length (or pointer) comparison.
2019-06-14 06:24:02 +02:00
Andreas Kling
c1bbd40b9e Kernel: Rename "descriptor" to "description" where appropriate.
Now that FileDescription is called that, variables of that type should not
be called "descriptor". This is kinda wordy but we'll get used to it.
2019-06-13 22:03:04 +02:00
Andreas Kling
1c5677032a Kernel: Replace the last "linear" with "virtual". 2019-06-13 21:42:12 +02:00
Andreas Kling
42f374d0f1 Terminal: Add support for DCH ('P' final)
Patch contributed by "pd"
2019-06-12 20:54:23 +02:00
Andreas Kling
16f624421a Demos: Import Fire demo contributed by "pd". 2019-06-12 20:19:44 +02:00
Sergey Bugaev
629501049f Kernel: Fix resolving symlinks in the middle of a path.
If a symlink is not the last part of a path, the remaining part
of the path has to be further resolved against the symlink target.

With this, a path containing a symlink always resolves to the target
of the first (leftmost) symlink in it, for example any path of form
/proc/self/... resolves to the corresponding /proc/pid directory.
2019-06-12 16:14:29 +02:00
Sergey Bugaev
75df45d709 Kernel: Fix comparing StringViews with strcmp().
StringView character buffer is not guaranteed to be null-terminated;
in particular it will not be null-terminated when making a substring.
This means that the buffer can not be used with C functions that expect
a null-terminated string. Instead, StringView provides a convinient
operator == for comparing it with Strings and C stirngs, so use that.

This fixes /proc/self/... resolution failures in ProcFS, since the name
("self") passed to ProcFSInode::lookup() would not be null-terminated.
2019-06-12 16:14:29 +02:00
Conrad Pankoff
b29a83d554 Kernel: Wrap around to region start if necessary in take_free_page 2019-06-12 15:38:17 +02:00
Conrad Pankoff
aee9317d86 Kernel: Refactor MemoryManager to use a Bitmap rather than a Vector
This significantly reduces the pressure on the kernel heap when
allocating a lot of pages.

Previously at about 250MB allocated, the free page list would outgrow
the kernel's heap. Given that there is no longer a page list, this does
not happen.

The next barrier will be the kernel memory used by the page records for
in-use memory. This kicks in at about 1GB.
2019-06-12 15:38:17 +02:00
Conrad Pankoff
1a77dfed23 Kernel: Add some comparison operators to PhysicalAddress 2019-06-12 15:38:17 +02:00
Conrad Pankoff
8df44b476d Kernel: Use an environment variable to set the memory size in the run script 2019-06-12 15:38:17 +02:00
Conrad Pankoff
f0ce0910ab Userland: Add test program for stressing memory allocation 2019-06-12 15:38:17 +02:00
Conrad Pankoff
f7dce4765c AK: Add find_first_{set,unset} and grow methods to Bitmap 2019-06-12 15:38:17 +02:00
Larkin Nickle
fa204aeb77 build-root-filesystem.sh: Create /dev/null, /dev/random, /dev/zero, and /dev/full with proper permissions. 2019-06-12 09:43:58 +02:00
Andreas Kling
e673bb921e AK: Delete the Badge copy and move constructors. 2019-06-11 23:47:51 -07:00
Andreas Kling
c4d24bb4e9 PaintBrush: Start fleshing out a toolbox widget. 2019-06-12 05:58:31 +02:00
Andreas Kling
d7756fc09f LibGUI: Add an "exclusive" property to GAbstractButtons.
This makes checkable buttons exclusive with other checkable buttons in the
same parent widget. Basically like radio buttons. This should probably be
used to implement GRadioButton once it's a bit more mature.
2019-06-12 05:57:26 +02:00
Andreas Kling
cadc65a82d PaintBrush: Let's use Color::MidGray for the outside-the-bitmap area. 2019-06-11 20:39:32 +02:00
Andreas Kling
70564a78b2 PaintBrush: Tidy up the UI a bit. Add some more colors. 2019-06-11 20:37:58 +02:00
Andreas Kling
1372f10dda Terminal: Add support for REP ('b' final)
Patch contributed by "pd"
2019-06-11 07:32:53 +02:00
Andreas Kling
58a2b9336a Color: Add inverted().
Patch contributed by "pd"
2019-06-11 07:28:59 +02:00
Andreas Kling
6ef45bc0ef PaintBrush: Add some placeholder menus so it looks proper. 2019-06-10 21:05:20 +02:00
Andreas Kling
ba2d0ab19a PaintBrush: Include in makeall.sh 2019-06-10 20:26:54 +02:00
Andreas Kling
1f756378e8 PaintBrush: Make it possible to switch colors using the PaletteWidget. 2019-06-10 20:07:26 +02:00