WINGs/wcolorpanel: replace pixmap/copy/fill X11 calls with render backend
Converts 60 X11 calls (XCreatePixmap, XFreePixmap, XCopyArea, XFillRectangle) to render backend vtable dispatch. Remaining 40 calls are all in the magnifier feature (screen capture, inherently platform-specific) and will be handled separately.
This commit is contained in:
parent
9ccfd33971
commit
0e26aa878c
|
|
@ -1059,9 +1059,11 @@ static WMColorPanel *makeColorPanel(WMScreen * scrPtr, const char *name)
|
||||||
/* Pixmap to indicate selection positions
|
/* Pixmap to indicate selection positions
|
||||||
* wheelframe MUST be mapped.
|
* wheelframe MUST be mapped.
|
||||||
*/
|
*/
|
||||||
panel->selectionImg = XCreatePixmap(scrPtr->display, WMWidgetXID(panel->win), 4, 4, scrPtr->depth);
|
const W_RenderBackend *R = scrPtr->renderBackend;
|
||||||
XFillRectangle(scrPtr->display, panel->selectionImg, bgc, 0, 0, 4, 4);
|
void *rctx = scrPtr->renderBackendCtx;
|
||||||
XFillRectangle(scrPtr->display, panel->selectionImg, wgc, 1, 1, 2, 2);
|
panel->selectionImg = R->pixmap_create(rctx, 4, 4, scrPtr->depth);
|
||||||
|
R->fill_rect(rctx, panel->selectionImg, scrPtr->black, 0, 0, 4, 4);
|
||||||
|
R->fill_rect(rctx, panel->selectionImg, scrPtr->white, 1, 1, 2, 2);
|
||||||
|
|
||||||
readConfiguration(panel);
|
readConfiguration(panel);
|
||||||
readXColors(panel);
|
readXColors(panel);
|
||||||
|
|
@ -1104,12 +1106,14 @@ void WMFreeColorPanel(WMColorPanel * panel)
|
||||||
|
|
||||||
/* pixmaps */
|
/* pixmaps */
|
||||||
wheelDestroyMatrix(panel->wheelMtrx);
|
wheelDestroyMatrix(panel->wheelMtrx);
|
||||||
|
const W_RenderBackend *R = scr->renderBackend;
|
||||||
|
void *rctx = scr->renderBackendCtx;
|
||||||
if (panel->wheelImg)
|
if (panel->wheelImg)
|
||||||
XFreePixmap(scr->display, panel->wheelImg);
|
R->pixmap_free(rctx, panel->wheelImg);
|
||||||
if (panel->selectionImg)
|
if (panel->selectionImg)
|
||||||
XFreePixmap(scr->display, panel->selectionImg);
|
R->pixmap_free(rctx, panel->selectionImg);
|
||||||
if (panel->selectionBackImg)
|
if (panel->selectionBackImg)
|
||||||
XFreePixmap(scr->display, panel->selectionBackImg);
|
R->pixmap_free(rctx, panel->selectionBackImg);
|
||||||
RReleaseImage(panel->customPaletteImg);
|
RReleaseImage(panel->customPaletteImg);
|
||||||
|
|
||||||
/* structs */
|
/* structs */
|
||||||
|
|
@ -1214,7 +1218,7 @@ void WMSetColorPanelPickerMode(WMColorPanel * panel, WMColorPanelMode mode)
|
||||||
if (mode != WMWheelModeColorPanel) {
|
if (mode != WMWheelModeColorPanel) {
|
||||||
WMUnmapWidget(panel->wheelFrm);
|
WMUnmapWidget(panel->wheelFrm);
|
||||||
if (panel->selectionBackImg) {
|
if (panel->selectionBackImg) {
|
||||||
XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg);
|
scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->selectionBackImg);
|
||||||
panel->selectionBackImg = None;
|
panel->selectionBackImg = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1229,7 +1233,7 @@ void WMSetColorPanelPickerMode(WMColorPanel * panel, WMColorPanelMode mode)
|
||||||
if (mode != WMCustomPaletteModeColorPanel) {
|
if (mode != WMCustomPaletteModeColorPanel) {
|
||||||
WMUnmapWidget(panel->customPaletteFrm);
|
WMUnmapWidget(panel->customPaletteFrm);
|
||||||
if (panel->selectionBackImg) {
|
if (panel->selectionBackImg) {
|
||||||
XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg);
|
scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->selectionBackImg);
|
||||||
panel->selectionBackImg = None;
|
panel->selectionBackImg = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1704,7 +1708,7 @@ static void magnifyPutCursor(WMWidget * w, void *data)
|
||||||
|
|
||||||
/* Destroy wheelBackImg, so it'll update properly */
|
/* Destroy wheelBackImg, so it'll update properly */
|
||||||
if (panel->selectionBackImg) {
|
if (panel->selectionBackImg) {
|
||||||
XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg);
|
scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->selectionBackImg);
|
||||||
panel->selectionBackImg = None;
|
panel->selectionBackImg = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2039,17 +2043,16 @@ static void wheelRender(W_ColorPanel * panel)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel->wheelImg)
|
if (panel->wheelImg)
|
||||||
XFreePixmap(scr->display, panel->wheelImg);
|
scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->wheelImg);
|
||||||
|
|
||||||
RConvertImage(scr->rcontext, image, &panel->wheelImg);
|
RConvertImage(scr->rcontext, image, &panel->wheelImg);
|
||||||
RReleaseImage(image);
|
RReleaseImage(image);
|
||||||
|
|
||||||
/* Check if backimage exists. If it doesn't, allocate and fill it */
|
/* Check if backimage exists. If it doesn't, allocate and fill it */
|
||||||
if (!panel->selectionBackImg) {
|
if (!panel->selectionBackImg) {
|
||||||
panel->selectionBackImg = XCreatePixmap(scr->display,
|
panel->selectionBackImg = scr->renderBackend->pixmap_create(scr->renderBackendCtx, 4, 4, scr->depth);
|
||||||
W_VIEW(panel->wheelFrm)->window, 4, 4, scr->depth);
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->wheelImg, panel->selectionBackImg,
|
||||||
XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg,
|
panel->colx - 2, panel->coly - 2, 4, 4, 0, 0);
|
||||||
scr->copyGC, panel->colx - 2, panel->coly - 2, 4, 4, 0, 0);
|
|
||||||
/* -2 is hot spot correction */
|
/* -2 is hot spot correction */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2064,12 +2067,12 @@ static void wheelPaint(W_ColorPanel * panel)
|
||||||
{
|
{
|
||||||
W_Screen *scr = WMWidgetScreen(panel->win);
|
W_Screen *scr = WMWidgetScreen(panel->win);
|
||||||
|
|
||||||
XCopyArea(scr->display, panel->wheelImg, panel->wheelView->window,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->wheelImg, (WMDrawable)panel->wheelView->window,
|
||||||
scr->copyGC, 0, 0, colorWheelSize + 4, colorWheelSize + 4, 0, 0);
|
0, 0, colorWheelSize + 4, colorWheelSize + 4, 0, 0);
|
||||||
|
|
||||||
/* Draw selection image */
|
/* Draw selection image */
|
||||||
XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg, (WMDrawable)panel->wheelView->window,
|
||||||
scr->copyGC, 0, 0, 4, 4, panel->colx - 2, panel->coly - 2);
|
0, 0, 4, 4, panel->colx - 2, panel->coly - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wheelHandleEvents(WMEvent * event, void *data)
|
static void wheelHandleEvents(WMEvent * event, void *data)
|
||||||
|
|
@ -2179,11 +2182,11 @@ static void wheelUpdateSelection(W_ColorPanel * panel)
|
||||||
panel->lastChanged = WMWheelModeColorPanel;
|
panel->lastChanged = WMWheelModeColorPanel;
|
||||||
|
|
||||||
/* Redraw color selector (and make a backup of the part it will cover) */
|
/* Redraw color selector (and make a backup of the part it will cover) */
|
||||||
XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->wheelImg, panel->selectionBackImg,
|
||||||
scr->copyGC, panel->colx - 2, panel->coly - 2, 4, 4, 0, 0);
|
panel->colx - 2, panel->coly - 2, 4, 4, 0, 0);
|
||||||
/* "-2" is correction for hotspot location */
|
/* "-2" is correction for hotspot location */
|
||||||
XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg, (WMDrawable)panel->wheelView->window,
|
||||||
scr->copyGC, 0, 0, 4, 4, panel->colx - 2, panel->coly - 2);
|
0, 0, 4, 4, panel->colx - 2, panel->coly - 2);
|
||||||
/* see above */
|
/* see above */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2191,8 +2194,8 @@ static void wheelUndrawSelection(W_ColorPanel * panel)
|
||||||
{
|
{
|
||||||
W_Screen *scr = WMWidgetScreen(panel->win);
|
W_Screen *scr = WMWidgetScreen(panel->win);
|
||||||
|
|
||||||
XCopyArea(scr->display, panel->selectionBackImg, panel->wheelView->window,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionBackImg, (WMDrawable)panel->wheelView->window,
|
||||||
scr->copyGC, 0, 0, 4, 4, panel->colx - 2, panel->coly - 2);
|
0, 0, 4, 4, panel->colx - 2, panel->coly - 2);
|
||||||
/* see above */
|
/* see above */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2841,26 +2844,25 @@ static void customSetPalette(W_ColorPanel * panel)
|
||||||
RImage *scaledImg;
|
RImage *scaledImg;
|
||||||
Pixmap image;
|
Pixmap image;
|
||||||
|
|
||||||
image = XCreatePixmap(scr->display, W_DRAWABLE(scr), customPaletteWidth, customPaletteHeight, scr->depth);
|
image = scr->renderBackend->pixmap_create(scr->renderBackendCtx, customPaletteWidth, customPaletteHeight, scr->depth);
|
||||||
scaledImg = RScaleImage(panel->customPaletteImg, customPaletteWidth, customPaletteHeight);
|
scaledImg = RScaleImage(panel->customPaletteImg, customPaletteWidth, customPaletteHeight);
|
||||||
RConvertImage(scr->rcontext, scaledImg, &image);
|
RConvertImage(scr->rcontext, scaledImg, &image);
|
||||||
RReleaseImage(scaledImg);
|
RReleaseImage(scaledImg);
|
||||||
|
|
||||||
XCopyArea(scr->display, image, panel->customPaletteContentView->window,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, image, (WMDrawable)panel->customPaletteContentView->window,
|
||||||
scr->copyGC, 0, 0, customPaletteWidth, customPaletteHeight, 0, 0);
|
0, 0, customPaletteWidth, customPaletteHeight, 0, 0);
|
||||||
|
|
||||||
/* Check backimage exists. If it doesn't, allocate and fill it */
|
/* Check backimage exists. If it doesn't, allocate and fill it */
|
||||||
if (!panel->selectionBackImg) {
|
if (!panel->selectionBackImg) {
|
||||||
panel->selectionBackImg = XCreatePixmap(scr->display,
|
panel->selectionBackImg = scr->renderBackend->pixmap_create(scr->renderBackendCtx, 4, 4, scr->depth);
|
||||||
panel->customPaletteContentView->window, 4, 4, scr->depth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XCopyArea(scr->display, image, panel->selectionBackImg, scr->copyGC,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, image, panel->selectionBackImg,
|
||||||
panel->palx - 2, panel->paly - 2, 4, 4, 0, 0);
|
panel->palx - 2, panel->paly - 2, 4, 4, 0, 0);
|
||||||
XCopyArea(scr->display, panel->selectionImg,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg,
|
||||||
panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4,
|
(WMDrawable)panel->customPaletteContentView->window, 0, 0, 4, 4,
|
||||||
panel->palx - 2, panel->paly - 2);
|
panel->palx - 2, panel->paly - 2);
|
||||||
XFreePixmap(scr->display, image);
|
scr->renderBackend->pixmap_free(scr->renderBackendCtx, image);
|
||||||
|
|
||||||
panel->palXRatio = (double)(panel->customPaletteImg->width) / (double)(customPaletteWidth);
|
panel->palXRatio = (double)(panel->customPaletteImg->width) / (double)(customPaletteWidth);
|
||||||
panel->palYRatio = (double)(panel->customPaletteImg->height) / (double)(customPaletteHeight);
|
panel->palYRatio = (double)(panel->customPaletteImg->height) / (double)(customPaletteHeight);
|
||||||
|
|
@ -2872,9 +2874,9 @@ static void customPalettePositionSelection(W_ColorPanel * panel, int x, int y)
|
||||||
unsigned long ofs;
|
unsigned long ofs;
|
||||||
|
|
||||||
/* undraw selection */
|
/* undraw selection */
|
||||||
XCopyArea(scr->display, panel->selectionBackImg,
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionBackImg,
|
||||||
panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4,
|
(WMDrawable)panel->customPaletteContentView->window, 0, 0, 4, 4,
|
||||||
panel->palx - 2, panel->paly - 2);
|
panel->palx - 2, panel->paly - 2);
|
||||||
|
|
||||||
panel->palx = x;
|
panel->palx = x;
|
||||||
panel->paly = y;
|
panel->paly = y;
|
||||||
|
|
@ -2890,8 +2892,8 @@ static void customPalettePositionSelection(W_ColorPanel * panel, int x, int y)
|
||||||
panel->lastChanged = WMCustomPaletteModeColorPanel;
|
panel->lastChanged = WMCustomPaletteModeColorPanel;
|
||||||
|
|
||||||
/* Redraw color selector (and make a backup of the part it will cover) */
|
/* Redraw color selector (and make a backup of the part it will cover) */
|
||||||
XCopyArea(scr->display, panel->customPaletteContentView->window, panel->selectionBackImg, scr->copyGC, panel->palx - 2, panel->paly - 2, 4, 4, 0, 0); /* "-2" is correction for hotspot location */
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, (WMDrawable)panel->customPaletteContentView->window, panel->selectionBackImg, panel->palx - 2, panel->paly - 2, 4, 4, 0, 0); /* "-2" is correction for hotspot location */
|
||||||
XCopyArea(scr->display, panel->selectionImg, panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, panel->palx - 2, panel->paly - 2); /* see above */
|
scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg, (WMDrawable)panel->customPaletteContentView->window, 0, 0, 4, 4, panel->palx - 2, panel->paly - 2); /* see above */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void customPalettePositionSelectionOutBounds(W_ColorPanel * panel, int x, int y)
|
static void customPalettePositionSelectionOutBounds(W_ColorPanel * panel, int x, int y)
|
||||||
|
|
@ -3263,7 +3265,6 @@ static void customPaletteHistoryCallback(WMWidget * w, void *data)
|
||||||
static void colorListPaintItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
|
static void colorListPaintItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
|
||||||
{
|
{
|
||||||
WMScreen *scr = WMWidgetScreen(lPtr);
|
WMScreen *scr = WMWidgetScreen(lPtr);
|
||||||
Display *dpy = WMScreenDisplay(scr);
|
|
||||||
WMView *view = W_VIEW(lPtr);
|
WMView *view = W_VIEW(lPtr);
|
||||||
RColor *color = (RColor *) WMGetListItem(lPtr, index)->clientData;
|
RColor *color = (RColor *) WMGetListItem(lPtr, index)->clientData;
|
||||||
W_ColorPanel *panel = WMGetHangedData(lPtr);
|
W_ColorPanel *panel = WMGetHangedData(lPtr);
|
||||||
|
|
@ -3276,13 +3277,13 @@ static void colorListPaintItem(WMList * lPtr, int index, Drawable d, char *text,
|
||||||
y = rect->pos.y;
|
y = rect->pos.y;
|
||||||
|
|
||||||
if (state & WLDSSelected)
|
if (state & WLDSSelected)
|
||||||
XFillRectangle(dpy, d, WMColorGC(scr->white), x, y, width, height);
|
scr->renderBackend->fill_rect(scr->renderBackendCtx, d, scr->white, x, y, width, height);
|
||||||
else
|
else
|
||||||
XFillRectangle(dpy, d, WMColorGC(view->backColor), x, y, width, height);
|
scr->renderBackend->fill_rect(scr->renderBackendCtx, d, view->backColor, x, y, width, height);
|
||||||
|
|
||||||
fillColor = WMCreateRGBColor(scr, color->red << 8, color->green << 8, color->blue << 8, True);
|
fillColor = WMCreateRGBColor(scr, color->red << 8, color->green << 8, color->blue << 8, True);
|
||||||
|
|
||||||
XFillRectangle(dpy, d, WMColorGC(fillColor), x, y, 15, height);
|
scr->renderBackend->fill_rect(scr->renderBackendCtx, d, fillColor, x, y, 15, height);
|
||||||
WMReleaseColor(fillColor);
|
WMReleaseColor(fillColor);
|
||||||
|
|
||||||
WMDrawString(scr, d, scr->black, panel->font12, x + 18, y, text, strlen(text));
|
WMDrawString(scr, d, scr->black, panel->font12, x + 18, y, text, strlen(text));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue