summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMustafa Quraish <mustafaq9@gmail.com>2021-09-03 23:12:04 -0400
committerAndreas Kling <kling@serenityos.org>2021-09-11 19:05:46 +0200
commit3da4fdd0ebcbf23b29641882cebb93d24b6f752e (patch)
tree4ab7f3e1b91b3303dde01f7d3f7f0bdfe781118e
parent04ba31b8c5ec71bf57cc34d58f8dd1d08bea87ab (diff)
downloadserenity-3da4fdd0ebcbf23b29641882cebb93d24b6f752e.zip
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.
-rw-r--r--Userland/Services/WindowServer/Compositor.cpp5
-rw-r--r--Userland/Services/WindowServer/Compositor.h1
2 files changed, 6 insertions, 0 deletions
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<ClientConnectio
return *screen.compositor_screen_data().m_front_bitmap;
}
+Gfx::Color Compositor::color_at_position(Badge<ClientConnection>, 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<ClientConnection>, Screen&) const;
const Gfx::Bitmap& front_bitmap_for_screenshot(Badge<ClientConnection>, Screen&) const;
+ Gfx::Color color_at_position(Badge<ClientConnection>, Screen&, Gfx::IntPoint const&) const;
void register_animation(Badge<Animation>, Animation&);
void unregister_animation(Badge<Animation>, Animation&);