Skip to content

Commit

Permalink
Fetch the real colorspace for the drawable when creating scratch bitm…
Browse files Browse the repository at this point in the history
…aps.
  • Loading branch information
waddlesplash committed Mar 21, 2022
1 parent 8eda2dc commit 441ad19
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions xlib/Drawables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Drawables.h"

#include <interface/Bitmap.h>
#include <interface/Screen.h>

#include <set>
#include <atomic>
Expand Down Expand Up @@ -400,6 +401,12 @@ XWindow::border_pixel(long border_color)
UnlockLooper();
}

color_space
XWindow::colorspace()
{
return BScreen(Window()).ColorSpace();
}

bool
XWindow::resize(BSize newSize)
{
Expand Down Expand Up @@ -827,6 +834,12 @@ XPixmap::~XPixmap()
delete _offscreen;
}

color_space
XPixmap::colorspace()
{
return _offscreen->ColorSpace();
}

bool
XPixmap::resize(BSize newSize)
{
Expand Down
5 changes: 5 additions & 0 deletions xlib/Drawables.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class XDrawable : XLIBE_DRAWABLES_PROTECTED BView {
virtual ~XDrawable() override;

BView* view() { return this; }
virtual color_space colorspace() = 0;

Display* display() const { return _display; }
Drawable id() const { return _id; }
Expand Down Expand Up @@ -112,6 +113,8 @@ class XWindow : public XDrawable {

void create_bwindow();

virtual color_space colorspace() override;

virtual bool resize(BSize newSize) override;

int border_width() { return _border_width; }
Expand Down Expand Up @@ -164,6 +167,8 @@ class XPixmap : public XDrawable {
XPixmap(Display* dpy, BRect frame, unsigned int depth);
virtual ~XPixmap() override;

virtual color_space colorspace() override;

int depth() { return _depth; }
BBitmap* offscreen() { return _offscreen; }

Expand Down
3 changes: 1 addition & 2 deletions xlib/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ XPutImage(Display *display, Drawable d, GC gc, XImage* image,
size.height = scratchBounds.Height();

delete drawable->scratch_bitmap;
drawable->scratch_bitmap = new BBitmap(BRect(BPoint(0, 0), size), 0, B_RGB32);
// TODO: or FIXME: get the actual color space?
drawable->scratch_bitmap = new BBitmap(BRect(BPoint(0, 0), size), 0, drawable->colorspace());
}

// TODO: Optimization: Import only the bits we are about to draw!
Expand Down

0 comments on commit 441ad19

Please sign in to comment.