93 lines
2.6 KiB
C
93 lines
2.6 KiB
C
/* context_wl.c - Wayland-mode RContext creation
|
|
*
|
|
* Raster graphics library
|
|
*
|
|
* Copyright (c) 2025 Window Maker Team
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*/
|
|
|
|
/*
|
|
* Wayland-side of the wraster context API.
|
|
*
|
|
* RCreateContextWayland creates a minimal RContext suitable for
|
|
* RImage operations (load, scale, combine, gradient) without an X11
|
|
* connection. No XOpenDisplay, no XCreateGC — the convert_image
|
|
* vtable is wired to wl_convert_image (pixman_image_t output).
|
|
*
|
|
* Compiled unconditionally (lives in libwraster regardless of
|
|
* --enable-x11-wraster) since it has no X11 dependencies.
|
|
*
|
|
* RDestroyContext is in context.c when X11 wraster is enabled, and
|
|
* stubbed (free-only) in wstubs_no_x11.c otherwise.
|
|
*/
|
|
|
|
#define WRASTER_NO_XLIB
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "wraster.h"
|
|
#include "convert_funcs.h"
|
|
|
|
/* TrueColor visual class constant (matches X.h definition). Used by
|
|
* convert/draw paths to select the TrueColor branch. We hard-code it
|
|
* here so we don't need <X11/X.h> when X11 wraster is disabled. */
|
|
#ifndef TrueColor
|
|
# define TrueColor 4
|
|
#endif
|
|
|
|
RContext *RCreateContextWayland(int width, int height,
|
|
const RContextAttributes *attribs)
|
|
{
|
|
RContext *context;
|
|
RContextAttributes *attr;
|
|
|
|
context = malloc(sizeof(RContext));
|
|
if (!context) {
|
|
RErrorCode = RERR_NOMEMORY;
|
|
return NULL;
|
|
}
|
|
memset(context, 0, sizeof(RContext));
|
|
|
|
attr = malloc(sizeof(RContextAttributes));
|
|
if (!attr) {
|
|
free(context);
|
|
RErrorCode = RERR_NOMEMORY;
|
|
return NULL;
|
|
}
|
|
if (attribs)
|
|
*attr = *attribs;
|
|
else
|
|
memset(attr, 0, sizeof(RContextAttributes));
|
|
|
|
context->attribs = attr;
|
|
|
|
/* 32-bit ARGB TrueColor — matches pixman ARGB32. */
|
|
context->depth = 32;
|
|
context->vclass = TrueColor;
|
|
context->red_offset = 16;
|
|
context->green_offset = 8;
|
|
context->blue_offset = 0;
|
|
context->black = 0xFF000000;
|
|
context->white = 0xFFFFFFFF;
|
|
|
|
(void)width;
|
|
(void)height;
|
|
|
|
context->convert_image = wl_convert_image;
|
|
context->convert_image_mask = wl_convert_image_mask;
|
|
|
|
return context;
|
|
}
|