diff options
author | Christopher Dumas <christopherdumas@gmail.com> | 2019-05-26 19:36:16 -0700 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-27 21:40:53 +0200 |
commit | aa50e5bb13a45eb97fa31a7f9a6facc8145e7666 (patch) | |
tree | cd5a35a14fa56397aa1e54cdcd73fe8c97202853 | |
parent | c23882dde1f8a46f82b599ece5bb4b59606d030b (diff) | |
download | serenity-aa50e5bb13a45eb97fa31a7f9a6facc8145e7666.zip |
tiled backgrounds no longer has strange off-by-one pixel errors
-rw-r--r-- | Base/home/anon/WindowManager.ini | 4 | ||||
-rw-r--r-- | Base/res/wallpapers/highpriority16.png | bin | 0 -> 1078 bytes | |||
-rw-r--r-- | Demos/PaintTest/Makefile | 22 | ||||
-rwxr-xr-x | Demos/PaintTest/PaintTest | bin | 0 -> 276244 bytes | |||
-rw-r--r-- | Demos/PaintTest/main.cpp | 50 | ||||
-rw-r--r-- | Demos/PaintTest/main.d | 165 | ||||
-rw-r--r-- | Demos/PaintTest/main.o | bin | 0 -> 8384 bytes | |||
-rwxr-xr-x | Kernel/sync.sh.orig | 92 | ||||
-rw-r--r-- | SharedGraphics/Painter.cpp | 29 |
9 files changed, 346 insertions, 16 deletions
diff --git a/Base/home/anon/WindowManager.ini b/Base/home/anon/WindowManager.ini index e142b0c28d..a13fcde519 100644 --- a/Base/home/anon/WindowManager.ini +++ b/Base/home/anon/WindowManager.ini @@ -1,6 +1,6 @@ [Screen] -Width=1920 -Height=1080 +Width=2560 +Height=1440 [Cursor] Arrow=/res/cursors/arrow.png diff --git a/Base/res/wallpapers/highpriority16.png b/Base/res/wallpapers/highpriority16.png Binary files differnew file mode 100644 index 0000000000..8146b503a1 --- /dev/null +++ b/Base/res/wallpapers/highpriority16.png diff --git a/Demos/PaintTest/Makefile b/Demos/PaintTest/Makefile new file mode 100644 index 0000000000..33edbaa7e5 --- /dev/null +++ b/Demos/PaintTest/Makefile @@ -0,0 +1,22 @@ +include ../../Makefile.common + +OBJS = \ + main.o + +APP = PaintTest + +DEFINES += -DUSERLAND + +all: $(APP) + +$(APP): $(OBJS) + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc + +.cpp.o: + @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< + +-include $(OBJS:%.o=%.d) + +clean: + @echo "CLEAN"; rm -f $(APP) $(OBJS) *.d + diff --git a/Demos/PaintTest/PaintTest b/Demos/PaintTest/PaintTest Binary files differnew file mode 100755 index 0000000000..771ef316f2 --- /dev/null +++ b/Demos/PaintTest/PaintTest diff --git a/Demos/PaintTest/main.cpp b/Demos/PaintTest/main.cpp new file mode 100644 index 0000000000..2174afe9c4 --- /dev/null +++ b/Demos/PaintTest/main.cpp @@ -0,0 +1,50 @@ +#include <LibGUI/GApplication.h> +#include <LibGUI/GWindow.h> +#include <LibGUI/GWidget.h> +#include <LibGUI/GPainter.h> +#include <SharedGraphics/PNGLoader.h> + +class TestWidget final : public GWidget { +public: + TestWidget(GWidget* parent) : GWidget(parent) { } + virtual ~TestWidget() override { } + + void set_bitmap(RetainPtr<GraphicsBitmap>&& bitmap) + { + m_bitmap = move(bitmap); + update(); + } + +private: + virtual void paint_event(GPaintEvent&) override + { + GPainter painter(*this); + + painter.fill_rect(rect(), Color::LightGray); + + painter.blit_tiled({ 0, 0, 160, 160 }, *m_bitmap, m_bitmap->rect()); + + painter.add_clip_rect({ 50, 50, 115, 95 }); + painter.blit_tiled({ 160, 160, 160, 160 }, *m_bitmap, m_bitmap->rect()); + } + + RetainPtr<GraphicsBitmap> m_bitmap; +}; + +int main(int argc, char** argv) +{ + GApplication app(argc, argv); + + auto* window = new GWindow; + window->set_rect(100, 100, 400, 400); + window->set_title("Paint test"); + + auto* test_widget = new TestWidget(nullptr); + window->set_main_widget(test_widget); + + test_widget->set_bitmap(load_png("/res/icons/gear16.png")); + + window->show(); + + return app.exec(); +} diff --git a/Demos/PaintTest/main.d b/Demos/PaintTest/main.d new file mode 100644 index 0000000000..d119b04163 --- /dev/null +++ b/Demos/PaintTest/main.d @@ -0,0 +1,165 @@ +main.o: main.cpp /home/christopherdumas/serenity/LibGUI/GApplication.h \ + /home/christopherdumas/serenity/AK/Badge.h \ + /home/christopherdumas/serenity/AK/OwnPtr.h \ + /home/christopherdumas/serenity/AK/StdLibExtras.h \ + /home/christopherdumas/serenity/LibC/stdlib.h \ + /home/christopherdumas/serenity/LibC/sys/cdefs.h \ + /home/christopherdumas/serenity/LibC/sys/types.h \ + /home/christopherdumas/serenity/LibC/stdint.h \ + /home/christopherdumas/serenity/LibC/stddef.h \ + /home/christopherdumas/serenity/LibC/string.h \ + /home/christopherdumas/serenity/AK/Types.h \ + /home/christopherdumas/serenity/AK/Traits.h \ + /home/christopherdumas/serenity/AK/kstdio.h \ + /home/christopherdumas/serenity/Kernel/kstdio.h \ + /home/christopherdumas/serenity/AK/HashFunctions.h \ + /home/christopherdumas/serenity/AK/HashMap.h \ + /home/christopherdumas/serenity/AK/HashTable.h \ + /home/christopherdumas/serenity/AK/Assertions.h \ + /home/christopherdumas/serenity/LibC/assert.h \ + /home/christopherdumas/serenity/AK/DoublyLinkedList.h \ + /home/christopherdumas/serenity/AK/Vector.h \ + /home/christopherdumas/serenity/AK/kmalloc.h \ + /home/christopherdumas/serenity/LibGUI/GShortcut.h \ + /home/christopherdumas/serenity/Kernel/KeyCode.h \ + /home/christopherdumas/serenity/AK/AKString.h \ + /home/christopherdumas/serenity/AK/ByteBuffer.h \ + /home/christopherdumas/serenity/AK/Retainable.h \ + /home/christopherdumas/serenity/AK/RetainPtr.h \ + /home/christopherdumas/serenity/AK/Retained.h \ + /home/christopherdumas/serenity/AK/StringImpl.h \ + /home/christopherdumas/serenity/AK/StringView.h \ + /home/christopherdumas/serenity/LibGUI/GWindow.h \ + /home/christopherdumas/serenity/LibCore/CObject.h \ + /home/christopherdumas/serenity/AK/Function.h \ + /home/christopherdumas/serenity/AK/Weakable.h \ + /home/christopherdumas/serenity/LibGUI/GWindowType.h \ + /home/christopherdumas/serenity/SharedGraphics/Rect.h \ + /home/christopherdumas/serenity/SharedGraphics/Point.h \ + /home/christopherdumas/serenity/SharedGraphics/Size.h \ + /home/christopherdumas/serenity/SharedGraphics/TextAlignment.h \ + /home/christopherdumas/serenity/SharedGraphics/GraphicsBitmap.h \ + /home/christopherdumas/serenity/SharedGraphics/Color.h \ + /home/christopherdumas/serenity/AK/MappedFile.h \ + /home/christopherdumas/serenity/LibC/SharedBuffer.h \ + /home/christopherdumas/serenity/AK/WeakPtr.h \ + /home/christopherdumas/serenity/LibGUI/GWidget.h \ + /home/christopherdumas/serenity/LibCore/CElapsedTimer.h \ + /home/christopherdumas/serenity/LibC/time.h \ + /home/christopherdumas/serenity/LibGUI/GEvent.h \ + /home/christopherdumas/serenity/LibCore/CEvent.h \ + /home/christopherdumas/serenity/SharedGraphics/Font.h \ + /home/christopherdumas/serenity/LibGUI/GPainter.h \ + /home/christopherdumas/serenity/SharedGraphics/Painter.h \ + /home/christopherdumas/serenity/SharedGraphics/TextElision.h \ + /home/christopherdumas/serenity/SharedGraphics/PNGLoader.h + +/home/christopherdumas/serenity/LibGUI/GApplication.h: + +/home/christopherdumas/serenity/AK/Badge.h: + +/home/christopherdumas/serenity/AK/OwnPtr.h: + +/home/christopherdumas/serenity/AK/StdLibExtras.h: + +/home/christopherdumas/serenity/LibC/stdlib.h: + +/home/christopherdumas/serenity/LibC/sys/cdefs.h: + +/home/christopherdumas/serenity/LibC/sys/types.h: + +/home/christopherdumas/serenity/LibC/stdint.h: + +/home/christopherdumas/serenity/LibC/stddef.h: + +/home/christopherdumas/serenity/LibC/string.h: + +/home/christopherdumas/serenity/AK/Types.h: + +/home/christopherdumas/serenity/AK/Traits.h: + +/home/christopherdumas/serenity/AK/kstdio.h: + +/home/christopherdumas/serenity/Kernel/kstdio.h: + +/home/christopherdumas/serenity/AK/HashFunctions.h: + +/home/christopherdumas/serenity/AK/HashMap.h: + +/home/christopherdumas/serenity/AK/HashTable.h: + +/home/christopherdumas/serenity/AK/Assertions.h: + +/home/christopherdumas/serenity/LibC/assert.h: + +/home/christopherdumas/serenity/AK/DoublyLinkedList.h: + +/home/christopherdumas/serenity/AK/Vector.h: + +/home/christopherdumas/serenity/AK/kmalloc.h: + +/home/christopherdumas/serenity/LibGUI/GShortcut.h: + +/home/christopherdumas/serenity/Kernel/KeyCode.h: + +/home/christopherdumas/serenity/AK/AKString.h: + +/home/christopherdumas/serenity/AK/ByteBuffer.h: + +/home/christopherdumas/serenity/AK/Retainable.h: + +/home/christopherdumas/serenity/AK/RetainPtr.h: + +/home/christopherdumas/serenity/AK/Retained.h: + +/home/christopherdumas/serenity/AK/StringImpl.h: + +/home/christopherdumas/serenity/AK/StringView.h: + +/home/christopherdumas/serenity/LibGUI/GWindow.h: + +/home/christopherdumas/serenity/LibCore/CObject.h: + +/home/christopherdumas/serenity/AK/Function.h: + +/home/christopherdumas/serenity/AK/Weakable.h: + +/home/christopherdumas/serenity/LibGUI/GWindowType.h: + +/home/christopherdumas/serenity/SharedGraphics/Rect.h: + +/home/christopherdumas/serenity/SharedGraphics/Point.h: + +/home/christopherdumas/serenity/SharedGraphics/Size.h: + +/home/christopherdumas/serenity/SharedGraphics/TextAlignment.h: + +/home/christopherdumas/serenity/SharedGraphics/GraphicsBitmap.h: + +/home/christopherdumas/serenity/SharedGraphics/Color.h: + +/home/christopherdumas/serenity/AK/MappedFile.h: + +/home/christopherdumas/serenity/LibC/SharedBuffer.h: + +/home/christopherdumas/serenity/AK/WeakPtr.h: + +/home/christopherdumas/serenity/LibGUI/GWidget.h: + +/home/christopherdumas/serenity/LibCore/CElapsedTimer.h: + +/home/christopherdumas/serenity/LibC/time.h: + +/home/christopherdumas/serenity/LibGUI/GEvent.h: + +/home/christopherdumas/serenity/LibCore/CEvent.h: + +/home/christopherdumas/serenity/SharedGraphics/Font.h: + +/home/christopherdumas/serenity/LibGUI/GPainter.h: + +/home/christopherdumas/serenity/SharedGraphics/Painter.h: + +/home/christopherdumas/serenity/SharedGraphics/TextElision.h: + +/home/christopherdumas/serenity/SharedGraphics/PNGLoader.h: diff --git a/Demos/PaintTest/main.o b/Demos/PaintTest/main.o Binary files differnew file mode 100644 index 0000000000..953146a320 --- /dev/null +++ b/Demos/PaintTest/main.o diff --git a/Kernel/sync.sh.orig b/Kernel/sync.sh.orig new file mode 100755 index 0000000000..f514bce19c --- /dev/null +++ b/Kernel/sync.sh.orig @@ -0,0 +1,92 @@ +#!/bin/bash + +if [ "$1" = "-f" ]; then + rm -vf _fs_contents +fi + +if [ $(id -u) != 0 ]; then + echo "This needs to be run as root" + exit 1 +fi + +rm -vf _fs_contents.lock + +# If target filesystem image doesn't exist, create it. +if [ ! -f _fs_contents ]; then + dd if=/dev/zero of=_fs_contents bs=1M count=512 +fi + +mke2fs -F -I 128 _fs_contents + +chown 1000:1000 _fs_contents +mkdir -vp mnt +mount -o loop _fs_contents mnt/ +mkdir -vp mnt/bin +mkdir -vp mnt/etc +mkdir -vp mnt/proc +mkdir -vp mnt/tmp +chmod 1777 mnt/tmp +mkdir -vp mnt/dev +mkdir -vp mnt/dev/pts +mknod -m 666 mnt/dev/bxvga b 82 413 +mknod mnt/dev/tty0 c 4 0 +mknod mnt/dev/tty1 c 4 1 +mknod mnt/dev/tty2 c 4 2 +mknod mnt/dev/tty3 c 4 3 +mknod mnt/dev/random c 1 8 +mknod mnt/dev/null c 1 3 +mknod mnt/dev/zero c 1 5 +mknod mnt/dev/full c 1 7 +mknod -m 666 mnt/dev/debuglog c 1 18 +mknod mnt/dev/keyboard c 85 1 +mknod mnt/dev/psaux c 10 1 +mknod -m 666 mnt/dev/ptmx c 5 2 +ln -s /proc/self/fd/0 mnt/dev/stdin +ln -s /proc/self/fd/1 mnt/dev/stdout +ln -s /proc/self/fd/2 mnt/dev/stderr +cp -vR ../Base/* mnt/ +cp -vR ../Root/* mnt/ +mkdir -vp mnt/home/anon +mkdir -vp mnt/home/nona +cp ../ReadMe.md mnt/home/anon/ +chown -vR 100:100 mnt/home/anon +chown -vR 200:200 mnt/home/nona +find ../Userland/ -type f -executable -exec cp -v {} mnt/bin/ \; +chmod 4755 mnt/bin/su +cp -v ../Applications/Terminal/Terminal mnt/bin/Terminal +cp -v ../Applications/FontEditor/FontEditor mnt/bin/FontEditor +cp -v ../Applications/Launcher/Launcher mnt/bin/Launcher +cp -v ../Applications/FileManager/FileManager mnt/bin/FileManager +cp -v ../Applications/ProcessManager/ProcessManager mnt/bin/ProcessManager +cp -v ../Applications/About/About mnt/bin/About +cp -v ../Applications/TextEditor/TextEditor mnt/bin/TextEditor +cp -v ../Applications/IRCClient/IRCClient mnt/bin/IRCClient +ln -s IRCClient mnt/bin/irc +ln -s FileManager mnt/bin/fm +cp -v ../Servers/LookupServer/LookupServer mnt/bin/LookupServer +cp -v ../Servers/WindowServer/WindowServer mnt/bin/WindowServer +cp -v ../Applications/Taskbar/Taskbar mnt/bin/Taskbar +ln -s Taskbar mnt/bin/tb +cp -v ../Applications/Downloader/Downloader mnt/bin/Downloader +ln -s Downloader mnt/bin/dl +cp -v ../DevTools/VisualBuilder/VisualBuilder mnt/bin/VisualBuilder +ln -s VisualBuilder mnt/bin/vb +cp -v ../Games/Minesweeper/Minesweeper mnt/bin/Minesweeper +ln -s Minesweeper mnt/bin/ms +cp -v ../Games/Snake/Snake mnt/bin/Snake +ln -s Snake mnt/bin/sn +cp -v ../Shell/Shell mnt/bin/Shell +ln -s Shell mnt/bin/sh +cp -v kernel.map mnt/ +cp -v ../Demos/HelloWorld/HelloWorld mnt/bin/HelloWorld +ln -s HelloWorld mnt/bin/hw +cp -v ../Demos/RetroFetch/RetroFetch mnt/bin/RetroFetch +cp -v ../Demos/WidgetGallery/WidgetGallery mnt/bin/WidgetGallery +ln -s WidgetGallery mnt/bin/wg + +# Run local sync script, if it exists +if [ -f sync-local.sh ]; then + sh sync-local.sh +fi + +umount mnt || ( sleep 0.5 && sync && umount mnt ) diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp index d2f5121ca4..f19cc76485 100644 --- a/SharedGraphics/Painter.cpp +++ b/SharedGraphics/Painter.cpp @@ -279,25 +279,26 @@ void Painter::blit_tiled(const Point& position, const GraphicsBitmap& source, co auto clipped_rect = dst_rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; - const int first_row = clipped_rect.top() - dst_rect.top(); - const int last_row = clipped_rect.bottom() - dst_rect.top(); - const int first_column = clipped_rect.left() - dst_rect.left(); - const int last_column = clipped_rect.right() - dst_rect.left(); + const int first_row = (clipped_rect.top() - dst_rect.top()); + const int last_row = (clipped_rect.bottom() - dst_rect.top()); + const int first_column = (clipped_rect.left() - dst_rect.left()); RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x(); - const RGBA32* isrc = source.scanline(0) + src_rect.left() + first_column; - const RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column; const size_t dst_skip = m_target->pitch() / sizeof(RGBA32); - const size_t src_skip = source.pitch() / sizeof(RGBA32); - for (int row = first_row; row <= last_row; ++row) { - int y = (src - isrc) / src_skip % source.size().height(); - src = y * src_skip + isrc; - for (int x = 0; x <= (last_column - first_column); ++x) { - dst[x] = src[x % source.size().width()]; + if (source.format() == GraphicsBitmap::Format::RGB32 || source.format() == GraphicsBitmap::Format::RGBA32) { + int x_start = first_column + src_rect.left(); + for (int row = first_row; row <= last_row; ++row) { + const RGBA32* sl = source.scanline((row + src_rect.top()) + % source.size().height()); + for (int x = x_start; x < clipped_rect.width() + x_start; ++x) { + dst[x - x_start] = sl[x % source.size().width()]; + } + dst += dst_skip; } - dst += dst_skip; - src += src_skip; + return; } + + ASSERT_NOT_REACHED(); } void Painter::blit_with_alpha(const Point& position, const GraphicsBitmap& source, const Rect& src_rect) |