Skip to content

Commit

Permalink
metering to debug #184
Browse files Browse the repository at this point in the history
From the looks of it a lot of pixmaps that are generated with the
root window depth are created and Icewm just expects frames to have
the same depth as the root window.

What will have to be done is to create a YFrameDecor window as a
child of YFrameWindow with a default visual and depth so that frame
decorations can be moved to that window.  It only needs to be placed
below all of the other children and things will display correctly.

This is non-trivial and requires creating a new class that takes over
all the graphics work of the actual frame.
  • Loading branch information
bbidulock committed Oct 18, 2017
1 parent 0865edd commit 5efc64d
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/decorate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void YFrameWindow::layoutShape() {
int const t((frameDecors() & fdResize) ? 0 : 1);

Pixmap shape = XCreatePixmap(xapp->display(), desktop->handle(), width(), height(), 1);
Graphics g(shape, width(), height());
Graphics g(shape, width(), height(), 1);

g.setColorPixel(1);
g.fillRect(0, 0, width(), height());
Expand Down
2 changes: 1 addition & 1 deletion src/icewmbg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ ref<YPixmap> Background::renderBackground(ref<YPixmap> back, YColor* color) {
}
}

ref<YPixmap> cBack = YPixmap::create(width, height);
ref<YPixmap> cBack = YPixmap::create(width, height, xapp->depth());
Graphics g(cBack, 0, 0);
g.setColor(color);
g.fillRect(0, 0, width, height);
Expand Down
5 changes: 5 additions & 0 deletions src/wmbutton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ void YFrameButton::paint(Graphics &g, const YRect &/*r*/) {
pixmap = getPixmap(0);
}

if (pixmap->depth() != g.rdepth()) {
tlog("YFrameButton::%s: attempt to use pixmap 0x%lx of depth %d with gc of depth %d\n",
__func__, pixmap->pixmap(), pixmap->depth(), g.rdepth());
}

if (wmLook == lookWarp4) {
if (fAction == actionNull) {
g.fillRect(0, 0, width(), height());
Expand Down
7 changes: 6 additions & 1 deletion src/wmframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,11 @@ void YFrameWindow::activateWindow(bool raise) {
void YFrameWindow::paint(Graphics &g, const YRect &/*r*/) {
YColor *bg;

if (g.rdepth() != depth()) {
tlog("YFrameWindow::%s: attempt to use gc of depth %d on window 0x%lx of depth %d\n",
__func__, g.rdepth(), handle(), depth());
return;
}
if (!(frameDecors() & (fdResize | fdBorder)))
return ;

Expand Down Expand Up @@ -2532,7 +2537,7 @@ ref<YIcon> newClientIcon(int count, int reclen, long * elem) {
}
MSG(("client icon: %ld %d %d %d %d", pixmap, w, h, depth, xapp->depth()));
if (depth == 1) {
ref<YPixmap> img = YPixmap::create(w, h);
ref<YPixmap> img = YPixmap::create(w, h, xapp->depth());
Graphics g(img, 0, 0);

g.setColorPixel(0xffffff);
Expand Down
2 changes: 1 addition & 1 deletion src/wmtitle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void YFrameTitleBar::paint(Graphics &g, const YRect &/*r*/) {
void YFrameTitleBar::renderShape(Pixmap shape) {
if (LOOK(lookPixmap | lookMetal | lookGtk | lookFlat))
{
Graphics g(shape, getFrame()->width(), getFrame()->height());
Graphics g(shape, getFrame()->width(), getFrame()->height(), xapp->depth());

int onLeft(0);
int onRight(width());
Expand Down
2 changes: 1 addition & 1 deletion src/yimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class YImage: public refcounted {
YImage(int width, int height) { fWidth = width; fHeight = height; }
virtual ~YImage() {};

ref<YPixmap> createPixmap(Pixmap pixmap, Pixmap mask, int w, int h);
ref<YPixmap> createPixmap(Pixmap pixmap, Pixmap mask, int w, int h, int depth);

private:
int fWidth;
Expand Down
7 changes: 4 additions & 3 deletions src/yimage_gdk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ ref<YPixmap> YImageGDK::renderToPixmap() {

return createPixmap(pixmap, mask,
gdk_pixbuf_get_width(fPixbuf),
gdk_pixbuf_get_height(fPixbuf));
gdk_pixbuf_get_height(fPixbuf),
xapp->depth());
}

ref<YPixmap> YImage::createPixmap(Pixmap pixmap, Pixmap mask, int w, int h) {
ref<YPixmap> YImage::createPixmap(Pixmap pixmap, Pixmap mask, int w, int h, int depth) {
ref<YPixmap> n;

n.init(new YPixmap(pixmap, mask, w, h));
n.init(new YPixmap(pixmap, mask, w, h, depth));
return n;
}

Expand Down
44 changes: 38 additions & 6 deletions src/ypaint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Graphics::Graphics(YWindow & window,
{
rWidth = window.width();
rHeight = window.height();
rDepth = window.depth();
gc = XCreateGC(display(), drawable(), vmask, gcv);
#ifdef CONFIG_XFREETYPE
fXftDraw = 0;
Expand All @@ -222,6 +223,7 @@ Graphics::Graphics(YWindow & window):
{
rWidth = window.width();
rHeight = window.height();
rDepth = window.depth();
XGCValues gcv; gcv.graphics_exposures = False;
gc = XCreateGC(display(), drawable(), GCGraphicsExposures, &gcv);
#ifdef CONFIG_XFREETYPE
Expand All @@ -236,31 +238,32 @@ Graphics::Graphics(const ref<YPixmap> &pixmap, int x_org, int y_org):
{
rWidth = pixmap->width();
rHeight = pixmap->height();
rDepth = pixmap->depth();
XGCValues gcv; gcv.graphics_exposures = False;
gc = XCreateGC(display(), drawable(), GCGraphicsExposures, &gcv);
#ifdef CONFIG_XFREETYPE
fXftDraw = 0;
#endif
}

Graphics::Graphics(Drawable drawable, int w, int h,
Graphics::Graphics(Drawable drawable, int w, int h, int depth,
unsigned long vmask, XGCValues * gcv):
fDrawable(drawable),
fColor(NULL), fFont(null),
xOrigin(0), yOrigin(0),
rWidth(w), rHeight(h)
rWidth(w), rHeight(h), rDepth(depth)
{
gc = XCreateGC(display(), drawable, vmask, gcv);
#ifdef CONFIG_XFREETYPE
fXftDraw = 0;
#endif
}

Graphics::Graphics(Drawable drawable, int w, int h):
Graphics::Graphics(Drawable drawable, int w, int h, int depth):
fDrawable(drawable),
fColor(NULL), fFont(null),
xOrigin(0), yOrigin(0),
rWidth(w), rHeight(h)
rWidth(w), rHeight(h), rDepth(depth)
{
XGCValues gcv; gcv.graphics_exposures = False;
gc = XCreateGC(display(), drawable, GCGraphicsExposures, &gcv);
Expand All @@ -285,7 +288,7 @@ Graphics::~Graphics() {
XftDraw* Graphics::handleXft() {
if (fXftDraw == 0) {
fXftDraw = XftDrawCreate(display(), drawable(),
visual(), colormap());
visual(), xapp->colormap());
}
return fXftDraw;
}
Expand All @@ -311,6 +314,20 @@ void Graphics::copyDrawable(Drawable const d,
dx - xOrigin, dy - yOrigin);
}

void Graphics::copyPixmap(const ref<YPixmap> &p,
const int x, const int y, const int w, const int h,
const int dx, const int dy)
{
if (p == null)
return;
if (p->depth() == rdepth()) {
copyDrawable(p->pixmap(), x, y, w, h, dx, dy);
return;
}
tlog("Graphics::%s: attempt to copy pixmap 0x%lx of depth %d using gc of depth %d\n",
__func__, p->pixmap(), p->depth(), rdepth());
}

/******************************************************************************/

void Graphics::drawPoint(int x, int y) {
Expand Down Expand Up @@ -628,10 +645,15 @@ void Graphics::fillArc(int x, int y, int width, int height, int a1, int a2) {

void Graphics::setColor(YColor * aColor) {
fColor = aColor;
XSetForeground(display(), gc, fColor->pixel());
unsigned long pixel = fColor->pixel();
if (rdepth() == 32)
pixel |= 0xff000000;
XSetForeground(display(), gc, pixel);
}

void Graphics::setColorPixel(unsigned long pixel) {
if (rdepth() == 32)
pixel |= 0xff000000;
XSetForeground(display(), gc, pixel);
}

Expand Down Expand Up @@ -674,6 +696,11 @@ void Graphics::drawImage(ref<YImage> pix, int x, int y, int w, int h, int dx, in
}

void Graphics::drawPixmap(ref<YPixmap> pix, int const x, int const y) {
if (pix->depth() != rdepth()) {
tlog("Graphics::%s: attempt to draw pixmap 0x%lx of depth %d with gc of depth %d\n",
__func__, pix->pixmap(), pix->depth(), rdepth());
return;
}
if (pix->mask())
drawClippedPixmap(pix->pixmap(),
pix->mask(),
Expand All @@ -685,6 +712,11 @@ void Graphics::drawPixmap(ref<YPixmap> pix, int const x, int const y) {

void Graphics::drawPixmap(ref<YPixmap> pix, int const sx, int const sy,
const int w, const int h, const int dx, const int dy) {
if (pix->depth() != rdepth()) {
tlog("Graphics::%s: attempt to draw pixmap 0x%lx of depth %d with gc of depth %d\n",
__func__, pix->pixmap(), pix->depth(), rdepth());
return;
}
if (pix->mask())
drawClippedPixmap(pix->pixmap(),
pix->mask(),
Expand Down
13 changes: 5 additions & 8 deletions src/ypaint.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class Graphics {
Graphics(YWindow & window, unsigned long vmask, XGCValues * gcv);
Graphics(YWindow & window);
Graphics(const ref<YPixmap> &pixmap, int x_org, int y_org);
Graphics(Drawable drawable, int w, int h, unsigned long vmask, XGCValues * gcv);
Graphics(Drawable drawable, int w, int h);
Graphics(Drawable drawable, int w, int h, int depth, unsigned long vmask, XGCValues * gcv);
Graphics(Drawable drawable, int w, int h, int depth);
~Graphics();

void copyArea(const int x, const int y, const int width, const int height,
Expand All @@ -158,11 +158,7 @@ class Graphics {
}
#endif
void copyPixmap(const ref<YPixmap> &p, const int x, const int y,
const int w, const int h, const int dx, const int dy)
{
if (p != null)
copyDrawable(p->pixmap(), x, y, w, h, dx, dy);
}
const int w, const int h, const int dx, const int dy);

void drawPoint(int x, int y);
void drawLine(int x1, int y1, int x2, int y2);
Expand Down Expand Up @@ -256,6 +252,7 @@ class Graphics {
int yorigin() const { return yOrigin; }
int rwidth() const { return rWidth; }
int rheight() const { return rHeight; }
int rdepth() const { return rDepth; }

void setClipRectangles(XRectangle *rect, int count);
void setClipMask(Pixmap mask = None);
Expand All @@ -270,7 +267,7 @@ class Graphics {
YColor * fColor;
ref<YFont> fFont;
int xOrigin, yOrigin;
int rWidth, rHeight;
int rWidth, rHeight, rDepth;
};

#endif
Expand Down
20 changes: 11 additions & 9 deletions src/ypixmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ static Pixmap createPixmap(int w, int h, int depth) {
return XCreatePixmap(xapp->display(), desktop->handle(), w, h, depth);
}

#if 0
static Pixmap createPixmap(int w, int h) {
return createPixmap(w, h, xapp->depth());
}
#endif

static Pixmap createMask(int w, int h) {
return XCreatePixmap(xapp->display(), desktop->handle(), w, h, 1);
Expand All @@ -23,21 +25,21 @@ void YPixmap::replicate(bool horiz, bool copyMask) {
if (dim >= 128) return;
dim = 128 + dim - 128 % dim;

Pixmap nPixmap(horiz ? createPixmap(dim, height())
: createPixmap(width(), dim));
Pixmap nPixmap(horiz ? createPixmap(dim, height(), depth())
: createPixmap(width(), dim, depth()));
Pixmap nMask(copyMask ? (horiz ? createMask(dim, height())
: createMask(width(), dim)) : None);

if (horiz)
Graphics(nPixmap, dim, height()).repHorz(fPixmap, width(), height(), 0, 0, dim);
Graphics(nPixmap, dim, height(), depth()).repHorz(fPixmap, width(), height(), 0, 0, dim);
else
Graphics(nPixmap, width(), dim).repVert(fPixmap, width(), height(), 0, 0, dim);
Graphics(nPixmap, width(), dim, depth()).repVert(fPixmap, width(), height(), 0, 0, dim);

if (nMask != None) {
if (horiz)
Graphics(nMask, dim, height()).repHorz(fMask, width(), height(), 0, 0, dim);
Graphics(nMask, dim, height(), depth()).repHorz(fMask, width(), height(), 0, 0, dim);
else
Graphics(nMask, width(), dim).repVert(fMask, width(), height(), 0, 0, dim);
Graphics(nMask, width(), dim, depth()).repVert(fMask, width(), height(), 0, 0, dim);
}

if (fPixmap != None)
Expand Down Expand Up @@ -76,13 +78,13 @@ ref<YPixmap> YPixmap::scale(int const w, int const h) {
return pixmap;
}

ref<YPixmap> YPixmap::create(int w, int h, bool useMask) {
ref<YPixmap> YPixmap::create(int w, int h, int depth, bool useMask) {
ref<YPixmap> n;

Pixmap pixmap = createPixmap(w, h);
Pixmap pixmap = createPixmap(w, h, depth);
Pixmap mask = useMask ? createMask(w, h) : None;
if (pixmap != None && (!useMask || mask != None)) {
n.init(new YPixmap(pixmap, mask, w, h));
n.init(new YPixmap(pixmap, mask, w, h, depth));
}
return n;
}
Expand Down
7 changes: 5 additions & 2 deletions src/ypixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class YImage;

class YPixmap: public virtual refcounted {
public:
static ref<YPixmap> create(int w, int h, bool mask = false);
static ref<YPixmap> create(int w, int h, int depth, bool mask = false);
static ref<YPixmap> load(upath filename);
// static ref<YPixmap> scale(ref<YPixmap> source, int width, int height);
static ref<YPixmap> createFromImage(ref<YImage> image);
Expand All @@ -32,14 +32,16 @@ class YPixmap: public virtual refcounted {
#endif
int width() const { return fWidth; }
int height() const { return fHeight; }
int depth() const { return fDepth; }
ref<YPixmap> scale(int w, int h);

protected:
YPixmap(Pixmap pixmap, Pixmap mask, int w, int h) {
YPixmap(Pixmap pixmap, Pixmap mask, int w, int h, int depth) {
fPixmap = pixmap;
fMask = mask;
fWidth = w;
fHeight = h;
fDepth = depth;
}
virtual ~YPixmap();

Expand All @@ -48,6 +50,7 @@ class YPixmap: public virtual refcounted {
private:
int fWidth;
int fHeight;
int fDepth;
#if 1
Pixmap fPixmap;
Pixmap fMask;
Expand Down
2 changes: 1 addition & 1 deletion src/ywindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ void YWindow::handleEvent(const XEvent &event) {

ref<YPixmap> YWindow::beginPaint(YRect &r) {
// return new YPixmap(width(), height());
ref<YPixmap> pix = YPixmap::create(r.width(), r.height());
ref<YPixmap> pix = YPixmap::create(r.width(), r.height(), depth());
return pix;
}

Expand Down

1 comment on commit 5efc64d

@bbidulock
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually metering for #183

Please sign in to comment.