From 3da4fdd0ebcbf23b29641882cebb93d24b6f752e Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Fri, 3 Sep 2021 23:12:04 -0400 Subject: Compositor: Add API to get the color of a pixel This just returns the color of a given pixel position from the front bitmap of the corresponding screen. --- Userland/Services/WindowServer/Compositor.cpp | 5 +++++ Userland/Services/WindowServer/Compositor.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index 0e6bf914dd..fb753efe73 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -78,6 +78,11 @@ const Gfx::Bitmap& Compositor::front_bitmap_for_screenshot(Badge, Screen& screen, Gfx::IntPoint const& position) const +{ + return screen.compositor_screen_data().m_front_bitmap->get_pixel(position); +} + void CompositorScreenData::init_bitmaps(Compositor& compositor, Screen& screen) { // Recreate the screen-number overlay as the Screen instances may have changed, or get rid of it if we no longer need it diff --git a/Userland/Services/WindowServer/Compositor.h b/Userland/Services/WindowServer/Compositor.h index bb11f73056..7ac4132888 100644 --- a/Userland/Services/WindowServer/Compositor.h +++ b/Userland/Services/WindowServer/Compositor.h @@ -176,6 +176,7 @@ public: const Gfx::Bitmap* cursor_bitmap_for_screenshot(Badge, Screen&) const; const Gfx::Bitmap& front_bitmap_for_screenshot(Badge, Screen&) const; + Gfx::Color color_at_position(Badge, Screen&, Gfx::IntPoint const&) const; void register_animation(Badge, Animation&); void unregister_animation(Badge, Animation&); -- cgit v1.2.3