diff --git a/Applications/About/Makefile b/Applications/About/Makefile index b656c4bc66..19612e3f20 100644 --- a/Applications/About/Makefile +++ b/Applications/About/Makefile @@ -14,12 +14,12 @@ DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/Downloader/Makefile b/Applications/Downloader/Makefile index 4138c392f9..9d417a883a 100644 --- a/Applications/Downloader/Makefile +++ b/Applications/Downloader/Makefile @@ -15,12 +15,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ AR = i686-pc-serenity-ar -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/FileManager/Makefile b/Applications/FileManager/Makefile index 5da4851114..5b94becf18 100644 --- a/Applications/FileManager/Makefile +++ b/Applications/FileManager/Makefile @@ -16,12 +16,12 @@ DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/FontEditor/Makefile b/Applications/FontEditor/Makefile index 7999e83d7a..b8d335bc1e 100644 --- a/Applications/FontEditor/Makefile +++ b/Applications/FontEditor/Makefile @@ -18,12 +18,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ AR = i686-pc-serenity-ar -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/IRCClient/Makefile b/Applications/IRCClient/Makefile index 67c23d6ecc..bb2ebaf1b0 100644 --- a/Applications/IRCClient/Makefile +++ b/Applications/IRCClient/Makefile @@ -24,12 +24,12 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STA CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ AR = i686-pc-serenity-ar -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/Launcher/Makefile b/Applications/Launcher/Makefile index 65a86c9074..30651fe518 100644 --- a/Applications/Launcher/Makefile +++ b/Applications/Launcher/Makefile @@ -14,12 +14,12 @@ DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/ProcessManager/Makefile b/Applications/ProcessManager/Makefile index 66137bc38e..489897e559 100644 --- a/Applications/ProcessManager/Makefile +++ b/Applications/ProcessManager/Makefile @@ -17,12 +17,12 @@ DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/Taskbar/Makefile b/Applications/Taskbar/Makefile index 3e6edc3144..50277448bf 100644 --- a/Applications/Taskbar/Makefile +++ b/Applications/Taskbar/Makefile @@ -16,12 +16,12 @@ DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/Terminal/Makefile b/Applications/Terminal/Makefile index 28d161d099..f5d0a2ee47 100644 --- a/Applications/Terminal/Makefile +++ b/Applications/Terminal/Makefile @@ -15,12 +15,12 @@ DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Applications/TextEditor/Makefile b/Applications/TextEditor/Makefile index 4944eef8e2..2e9f5fa92b 100644 --- a/Applications/TextEditor/Makefile +++ b/Applications/TextEditor/Makefile @@ -14,12 +14,12 @@ DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ -LDFLAGS = -L../../LibC -L../../LibGUI +LDFLAGS = -L../../LibC -L../../LibCore -L../../LibGUI all: $(APP) $(APP): $(OBJS) - $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh index 1d117e4374..5530d0c3af 100755 --- a/Kernel/makeall.sh +++ b/Kernel/makeall.sh @@ -10,6 +10,8 @@ $make_cmd -C ../LibC && \ $make_cmd -C ../LibM clean && \ $make_cmd -C ../LibM && \ (cd ../LibM && ./install.sh) && \ +$make_cmd -C ../LibCore clean && \ +$make_cmd -C ../LibCore && \ $make_cmd -C ../Servers/LookupServer clean && \ $make_cmd -C ../Servers/LookupServer && \ $make_cmd -C ../Servers/WindowServer clean && \ diff --git a/LibCore/.gitignore b/LibCore/.gitignore new file mode 100644 index 0000000000..70cec2cdec --- /dev/null +++ b/LibCore/.gitignore @@ -0,0 +1,3 @@ +*.o +*.d +libcore.a diff --git a/LibGUI/GElapsedTimer.cpp b/LibCore/CElapsedTimer.cpp similarity index 86% rename from LibGUI/GElapsedTimer.cpp rename to LibCore/CElapsedTimer.cpp index e5ebe38dce..b156147a8b 100644 --- a/LibGUI/GElapsedTimer.cpp +++ b/LibCore/CElapsedTimer.cpp @@ -1,8 +1,8 @@ -#include +#include #include #include -void GElapsedTimer::start() +void CElapsedTimer::start() { m_valid = true; gettimeofday(&m_start_time, nullptr); @@ -18,7 +18,7 @@ inline void timersub(const struct timeval* a, const struct timeval* b, struct ti } } -int GElapsedTimer::elapsed() const +int CElapsedTimer::elapsed() const { ASSERT(is_valid()); struct timeval now; diff --git a/LibGUI/GElapsedTimer.h b/LibCore/CElapsedTimer.h similarity index 82% rename from LibGUI/GElapsedTimer.h rename to LibCore/CElapsedTimer.h index ec43bb0b2a..b7aa84bfee 100644 --- a/LibGUI/GElapsedTimer.h +++ b/LibCore/CElapsedTimer.h @@ -2,9 +2,9 @@ #include -class GElapsedTimer { +class CElapsedTimer { public: - GElapsedTimer() { } + CElapsedTimer() { } bool is_valid() const { return m_valid; } void start(); diff --git a/LibCore/Makefile b/LibCore/Makefile new file mode 100644 index 0000000000..97af9c2fad --- /dev/null +++ b/LibCore/Makefile @@ -0,0 +1,32 @@ +OBJS = \ + CElapsedTimer.o + +LIBS = + +LIBRARY = libcore.a +STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation +WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough +FLAVOR_FLAGS = -fno-exceptions -fno-rtti +OPTIMIZATION_FLAGS = -Os +INCLUDE_FLAGS = -I../LibC -I../Servers -I.. -I. + +DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS -DLIBGUI + +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-pc-serenity-g++ +LD = i686-pc-serenity-ld +AR = i686-pc-serenity-ar + +all: $(LIBRARY) + +$(LIBRARY): $(OBJS) + @echo "LIB $@"; $(AR) rcs $@ $(OBJS) $(LIBS) + +.cpp.o: + @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< + +-include $(OBJS:%.o=%.d) + +clean: + @echo "CLEAN"; rm -f $(LIBRARY) $(OBJS) *.d + diff --git a/LibGUI/GWidget.h b/LibGUI/GWidget.h index ffeb546d71..8b441b005c 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -174,5 +174,5 @@ private: bool m_fill_with_background_color { false }; bool m_visible { true }; - GElapsedTimer m_click_clock; + CElapsedTimer m_click_clock; }; diff --git a/LibGUI/Makefile b/LibGUI/Makefile index f0a4ec1ccc..39d60524aa 100644 --- a/LibGUI/Makefile +++ b/LibGUI/Makefile @@ -52,7 +52,6 @@ LIBGUI_OBJS = \ GAbstractView.o \ GItemView.o \ GIcon.o \ - GElapsedTimer.o \ GFrame.o \ GTreeView.o \ GFileSystemModel.o \ @@ -69,8 +68,6 @@ LIBGUI_OBJS = \ OBJS = $(SHAREDGRAPHICS_OBJS) $(LIBGUI_OBJS) -LIBS = -lc - LIBRARY = libgui.a STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough @@ -88,7 +85,7 @@ AR = i686-pc-serenity-ar all: $(LIBRARY) $(LIBRARY): $(OBJS) - @echo "LIB $@"; $(AR) rcs $@ $(OBJS) $(LIBS) + @echo "LIB $@"; $(AR) rcs $@ $(OBJS) .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 78795fec37..c4efa8d4ad 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -813,7 +813,6 @@ void WSWindowManager::compose() dst.move_by(dirty_rect_in_window_coordinates.location()); m_back_painter->fill_rect(window.rect(), window.background_color()); - m_back_painter->blit(dst, *backing_store, dirty_rect_in_window_coordinates, window.opacity()); if (backing_store->width() < window.width()) { diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp index 69573a6910..55e4acfb49 100644 --- a/SharedGraphics/Painter.cpp +++ b/SharedGraphics/Painter.cpp @@ -238,6 +238,33 @@ void Painter::blit_with_opacity(const Point& position, const GraphicsBitmap& sou } } +void Painter::blit_dimmed(const Point& position, const GraphicsBitmap& source, const Rect& src_rect) +{ + Rect safe_src_rect = Rect::intersection(src_rect, source.rect()); + Rect dst_rect(position, safe_src_rect.size()); + dst_rect.move_by(state().translation); + auto clipped_rect = Rect::intersection(dst_rect, 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(); + RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x(); + const RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column; + const size_t dst_skip = m_target->width(); + const unsigned src_skip = source.width(); + + for (int row = first_row; row <= last_row; ++row) { + for (int x = 0; x <= (last_column - first_column); ++x) { + dst[x] = Color::from_rgba(src[x]).to_grayscale().darkened().value(); + } + dst += dst_skip; + src += src_skip; + } +} + + void Painter::blit_with_alpha(const Point& position, const GraphicsBitmap& source, const Rect& src_rect) { ASSERT(source.has_alpha_channel()); diff --git a/SharedGraphics/Painter.h b/SharedGraphics/Painter.h index 4515e02b7f..4e8fb2d386 100644 --- a/SharedGraphics/Painter.h +++ b/SharedGraphics/Painter.h @@ -27,6 +27,7 @@ public: void draw_focus_rect(const Rect&); void draw_scaled_bitmap(const Rect& dst_rect, const GraphicsBitmap&, const Rect& src_rect); void blit(const Point&, const GraphicsBitmap&, const Rect& src_rect, float opacity = 1.0f); + void blit_dimmed(const Point&, const GraphicsBitmap&, const Rect& src_rect); void draw_text(const Rect&, const char* text, int length, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); void draw_text(const Rect&, const char* text, int length, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); diff --git a/Userland/Makefile b/Userland/Makefile index 66707b88a0..3235ec5f82 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -98,7 +98,7 @@ CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARC CXX = i686-pc-serenity-g++ LD = i686-pc-serenity-g++ AR = i686-pc-serenity-r -LDFLAGS = -L ../LibC +LDFLAGS = -L../LibC -L../LibCore -L../LibGUI all: $(OBJS) $(APPS) @@ -169,13 +169,13 @@ more: more.o $(LD) -o $@ $(LDFLAGS) $< -lc guitest2: guitest2.o - $(LD) -o $@ $(LDFLAGS) -L../LibGUI $< -lgui -lc + $(LD) -o $@ $(LDFLAGS) $< -lgui -lcore -lc sysctl: sysctl.o $(LD) -o $@ $(LDFLAGS) $< -lc pape: pape.o - $(LD) -o $@ $(LDFLAGS) -L../LibGUI $< -lgui -lc + $(LD) -o $@ $(LDFLAGS) $< -lgui -lcore -lc cp: cp.o $(LD) -o $@ $(LDFLAGS) $< -lc @@ -223,10 +223,10 @@ host: host.o $(LD) -o $@ $(LDFLAGS) $< -lc qs: qs.o - $(LD) -o $@ $(LDFLAGS) -L../LibGUI $< -lgui -lc + $(LD) -o $@ $(LDFLAGS) $< -lgui -lcore -lc mv: mv.o - $(LD) -o $@ $(LDFLAGS) -L../LibGUI $< -lgui -lc + $(LD) -o $@ $(LDFLAGS) $< -lc .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<