/* * Copyright (C) 2013 Glyptodon LLC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "config.h" #include "client.h" #include "guac_cursor.h" #include "guac_display.h" #include "guac_surface.h" #include "vnc.h" #include #include #include #include #include #include #include /* Define cairo_format_stride_for_width() if missing */ #ifndef HAVE_CAIRO_FORMAT_STRIDE_FOR_WIDTH #define cairo_format_stride_for_width(format, width) (width*4) #endif #include #include #include #include #include void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { guac_client* gc = rfbClientGetClientData(client, GUAC_VNC_CLIENT_KEY); guac_vnc_client* vnc_client = (guac_vnc_client*) gc->data; /* Cairo image buffer */ int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); unsigned char* buffer = malloc(h*stride); unsigned char* buffer_row_current = buffer; /* VNC image buffer */ unsigned int fb_stride = bpp * w; unsigned char* fb_row_current = client->rcSource; unsigned char* fb_mask = client->rcMask; int dx, dy; /* Copy image data from VNC client to RGBA buffer */ for (dy = 0; dy> client->format.redShift) * 0x100 / (client->format.redMax + 1); green = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); /* Output ARGB */ if (vnc_client->settings->swap_red_blue) *(buffer_current++) = (alpha << 24) | (blue << 16) | (green << 8) | red; else *(buffer_current++) = (alpha << 24) | (red << 16) | (green << 8) | blue; /* Next VNC pixel */ fb_current += bpp; } } /* Update stored cursor information */ guac_common_cursor_set_argb(vnc_client->display->cursor, x, y, buffer, w, h, stride); /* Free surface */ free(buffer); /* libvncclient does not free rcMask as it does rcSource */ free(client->rcMask); }