mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
tiled backgrounds no longer has strange off-by-one pixel errors
This commit is contained in:
parent
c23882dde1
commit
aa50e5bb13
9 changed files with 346 additions and 16 deletions
22
Demos/PaintTest/Makefile
Normal file
22
Demos/PaintTest/Makefile
Normal file
|
@ -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
|
||||
|
BIN
Demos/PaintTest/PaintTest
Executable file
BIN
Demos/PaintTest/PaintTest
Executable file
Binary file not shown.
50
Demos/PaintTest/main.cpp
Normal file
50
Demos/PaintTest/main.cpp
Normal file
|
@ -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();
|
||||
}
|
165
Demos/PaintTest/main.d
Normal file
165
Demos/PaintTest/main.d
Normal file
|
@ -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:
|
BIN
Demos/PaintTest/main.o
Normal file
BIN
Demos/PaintTest/main.o
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue