2016-02-27 08:17:05 +00:00
|
|
|
/*
|
2016-03-25 19:59:40 +00:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
2016-02-27 08:17:05 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-02-27 08:17:05 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2016-02-27 08:17:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2016-02-27 08:29:22 +00:00
|
|
|
#include "buffer.h"
|
2016-02-27 08:17:05 +00:00
|
|
|
#include "layer.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
guacenc_layer* guacenc_layer_alloc() {
|
|
|
|
|
|
|
|
/* Allocate new layer */
|
|
|
|
guacenc_layer* layer = (guacenc_layer*) calloc(1, sizeof(guacenc_layer));
|
|
|
|
if (layer == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2016-02-27 08:29:22 +00:00
|
|
|
/* Allocate associated buffer (width, height, and image storage) */
|
|
|
|
layer->buffer = guacenc_buffer_alloc();
|
|
|
|
if (layer->buffer == NULL) {
|
|
|
|
free(layer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-02-28 22:55:29 +00:00
|
|
|
/* Allocate buffer for frame rendering */
|
|
|
|
layer->frame = guacenc_buffer_alloc();
|
|
|
|
if (layer->frame== NULL) {
|
|
|
|
guacenc_buffer_free(layer->buffer);
|
|
|
|
free(layer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-02-27 08:17:05 +00:00
|
|
|
/* Layers default to fully opaque */
|
|
|
|
layer->opacity = 0xFF;
|
|
|
|
|
2016-02-28 20:15:38 +00:00
|
|
|
/* Default parented to default layer */
|
|
|
|
layer->parent_index = 0;
|
2016-02-27 22:51:33 +00:00
|
|
|
|
2016-02-27 08:17:05 +00:00
|
|
|
return layer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void guacenc_layer_free(guacenc_layer* layer) {
|
2016-02-27 08:29:22 +00:00
|
|
|
|
|
|
|
/* Ignore NULL layers */
|
|
|
|
if (layer == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-02-28 22:55:29 +00:00
|
|
|
/* Free internal frame buffer */
|
|
|
|
guacenc_buffer_free(layer->frame);
|
|
|
|
|
2016-02-27 08:29:22 +00:00
|
|
|
/* Free underlying buffer */
|
|
|
|
guacenc_buffer_free(layer->buffer);
|
|
|
|
|
2016-02-27 08:17:05 +00:00
|
|
|
free(layer);
|
2016-02-27 08:29:22 +00:00
|
|
|
|
2016-02-27 08:17:05 +00:00
|
|
|
}
|
|
|
|
|