GUAC-656: Implement alloc/free for surface.
This commit is contained in:
parent
3b541f70ee
commit
5d6e04171c
@ -23,17 +23,36 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "guac_surface.h"
|
#include "guac_surface.h"
|
||||||
|
|
||||||
|
#include <cairo/cairo.h>
|
||||||
#include <guacamole/layer.h>
|
#include <guacamole/layer.h>
|
||||||
#include <guacamole/protocol.h>
|
#include <guacamole/protocol.h>
|
||||||
#include <guacamole/socket.h>
|
#include <guacamole/socket.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
guac_common_surface* guac_common_surface_alloc(guac_socket* socket, const guac_layer* layer, int w, int h) {
|
guac_common_surface* guac_common_surface_alloc(guac_socket* socket, const guac_layer* layer, int w, int h) {
|
||||||
/* STUB */
|
|
||||||
return NULL;
|
/* Init surface */
|
||||||
|
guac_common_surface* surface = malloc(sizeof(guac_common_surface));
|
||||||
|
surface->layer = layer;
|
||||||
|
surface->socket = socket;
|
||||||
|
surface->width = w;
|
||||||
|
surface->height = h;
|
||||||
|
surface->dirty = 0;
|
||||||
|
|
||||||
|
/* Create corresponding Cairo surface */
|
||||||
|
surface->stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w);
|
||||||
|
surface->buffer = malloc(surface->stride * h);
|
||||||
|
surface->surface = cairo_image_surface_create_for_data(surface->buffer, CAIRO_FORMAT_RGB24,
|
||||||
|
w, h, surface->stride);
|
||||||
|
|
||||||
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_common_surface_free(guac_common_surface* surface) {
|
void guac_common_surface_free(guac_common_surface* surface) {
|
||||||
/* STUB */
|
cairo_surface_destroy(surface->surface);
|
||||||
|
free(surface->buffer);
|
||||||
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_common_surface_draw(guac_common_surface* surface, cairo_surface_t* src, int x, int y) {
|
void guac_common_surface_draw(guac_common_surface* surface, cairo_surface_t* src, int x, int y) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <cairo/cairo.h>
|
||||||
#include <guacamole/layer.h>
|
#include <guacamole/layer.h>
|
||||||
#include <guacamole/protocol.h>
|
#include <guacamole/protocol.h>
|
||||||
#include <guacamole/socket.h>
|
#include <guacamole/socket.h>
|
||||||
@ -35,6 +36,16 @@
|
|||||||
*/
|
*/
|
||||||
typedef struct guac_common_surface {
|
typedef struct guac_common_surface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The layer this surface will draw to.
|
||||||
|
*/
|
||||||
|
const guac_layer* layer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The socket to send instructions on when flushing.
|
||||||
|
*/
|
||||||
|
guac_socket* socket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of this layer, in pixels.
|
* The width of this layer, in pixels.
|
||||||
*/
|
*/
|
||||||
@ -46,14 +57,14 @@ typedef struct guac_common_surface {
|
|||||||
int height;
|
int height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The layer this surface will draw to.
|
* The size of each image row, in bytes.
|
||||||
*/
|
*/
|
||||||
guac_layer* layer;
|
int stride;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The socket to send instructions on when flushing.
|
* The underlying buffer of the Cairo surface.
|
||||||
*/
|
*/
|
||||||
guac_socket* socket;
|
unsigned char* buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Cairo surface containins this Guacamole surface's current
|
* The Cairo surface containins this Guacamole surface's current
|
||||||
|
Loading…
Reference in New Issue
Block a user