Exemple #1
0
int TestRdTkNinePatch(int argc, char* argv[])
{
	rdtkEngine* engine = NULL;
	rdtkSurface* surface = NULL;
	DWORD scanline;
	DWORD width;
	DWORD height;
	BYTE* data = NULL;
	int ret = -1;

	if (!(engine = rdtk_engine_new()))
	{
		printf("%s: error creating rdtk engine (%"PRIu32")\n", __FUNCTION__, GetLastError());
		goto out;
	}

	width = 1024;
	height = 768;
	scanline = width * 4;

	/* let rdtk allocate the surface buffer */
	if (!(surface = rdtk_surface_new(engine, NULL, width, height, scanline)))
	{
		printf("%s: error creating auto-allocated surface (%"PRIu32")\n", __FUNCTION__, GetLastError());
		goto out;
	}
	rdtk_surface_free(surface);
	surface = NULL;


	/* test self-allocated buffer */
	if (!(data = calloc(height, scanline)))
	{
		printf("%s: error allocating surface buffer (%"PRIu32")\n", __FUNCTION__, GetLastError());
		goto out;
	}

	if (!(surface = rdtk_surface_new(engine, data, width, height, scanline)))
	{
		printf("%s: error creating self-allocated surface (%"PRIu32")\n", __FUNCTION__, GetLastError());
		goto out;
	}

	ret = 0;

out:
	rdtk_surface_free(surface);
	rdtk_engine_free(engine);
	free(data);

	return ret;
}
Exemple #2
0
int shadow_client_init_lobby(rdpShadowClient* client)
{
    int width;
    int height;
    rdtkEngine* engine;
    rdtkSurface* surface;
    RECTANGLE_16 invalidRect;
    rdpShadowSurface* lobby;
    rdpContext* context = (rdpContext*) client;
    rdpSettings* settings = context->settings;

    width = settings->DesktopWidth;
    height = settings->DesktopHeight;

    lobby = client->lobby = shadow_surface_new(client->server, 0, 0, width, height);

    if (!client->lobby)
        return -1;

    engine = rdtk_engine_new();

    surface = rdtk_surface_new(engine, lobby->data, lobby->width, lobby->height, lobby->scanline);

    rdtk_surface_fill(surface, 0, 0, width, height, 0x3BB9FF);
    //rdtk_label_draw(surface, 16, 16, 128, 32, NULL, "label", 0, 0);
    //rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button");
    //rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field");

    rdtk_surface_free(surface);

    rdtk_engine_free(engine);

    invalidRect.left = 0;
    invalidRect.top = 0;
    invalidRect.right = width;
    invalidRect.bottom = height;

    region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect);

    return 1;
}
Exemple #3
0
int main(int argc, char** argv)
{
	GC gc;
	int index;
	int depth;
	int x, y;
	int width;
	int height;
	BYTE* buffer;
	int scanline;
	int pf_count;
	XEvent event;
	XImage* image;
	Pixmap pixmap;
	Screen* screen;
	Visual* visual;
	int scanline_pad;
	int screen_number;
	Display* display;
	Window window;
	Window root_window;
	rdtkEngine* engine;
	rdtkSurface* surface;
	unsigned long border;
	unsigned long background;
	XPixmapFormatValues* pf;
	XPixmapFormatValues* pfs;
 
	display = XOpenDisplay(NULL);

	if (!display)
	{
		WLog_ERR(TAG, "Cannot open display");
		return winpr_exit(1);
	}

	x = 10;
	y = 10;
	width = 640;
	height = 480;

	screen_number = DefaultScreen(display);
	screen = ScreenOfDisplay(display, screen_number);
	visual = DefaultVisual(display, screen_number);
	gc = DefaultGC(display, screen_number);
	depth = DefaultDepthOfScreen(screen);
	root_window = RootWindow(display, screen_number);
	border = BlackPixel(display, screen_number);
	background = WhitePixel(display, screen_number);

	scanline_pad = 0;

	pfs = XListPixmapFormats(display, &pf_count);

	for (index = 0; index < pf_count; index++)
	{
		pf = &pfs[index];

		if (pf->depth == depth)
		{
			scanline_pad = pf->scanline_pad;
			break;
		}
	}

	XFree(pfs);

	engine = rdtk_engine_new();
	if (!engine)
		return winpr_exit(1);

	scanline = width * 4;
	buffer = (BYTE*) calloc(height, scanline);
	if (!buffer)
		return winpr_exit(1);

	surface = rdtk_surface_new(engine, buffer, width, height, scanline);

	rdtk_surface_fill(surface, 0, 0, width, height, 0x3BB9FF);
	rdtk_label_draw(surface, 16, 16, 128, 32, NULL, "label", 0, 0);
	rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button");
	rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field");

	window = XCreateSimpleWindow(display, root_window,
			x, y, width, height, 1, border, background);

	XSelectInput(display, window, ExposureMask | KeyPressMask);
	XMapWindow(display, window);

	XSetFunction(display, gc, GXcopy);
	XSetFillStyle(display, gc, FillSolid);

	pixmap = XCreatePixmap(display, window, width, height, depth);

	image = XCreateImage(display, visual, depth, ZPixmap, 0,
			(char*) buffer, width, height, scanline_pad, 0);
 
	while (1)
	{
		XNextEvent(display, &event);

		if (event.type == Expose)
		{
			XPutImage(display, pixmap, gc, image, 0, 0, 0, 0, width, height);
			XCopyArea(display, pixmap, window, gc, 0, 0, width, height, 0, 0);
		}

		if (event.type == KeyPress)
			break;

		if (event.type == ClientMessage)
			break;
	}

	XFlush(display);

	XDestroyImage(image);
	XCloseDisplay(display);

	rdtk_surface_free(surface);
	free(buffer);

	rdtk_engine_free(engine);

	return winpr_exit(0);
}