+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#define _GNU_SOURCE
+
#include <Elementary.h>
#include <string.h>
#include <Ecore_Evas.h>
#include <Ecore_X.h>
#include <Evas.h>
+#include <dlfcn.h>
#include <X11/Xlib.h>
#include <livebox-service.h>
#include "livebox.h"
+#include "livebox_internal.h"
#include "debug.h"
#define IS_PD 1
#define PUBLIC __attribute__((visibility("default")))
+static struct static_info {
+ Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data);
+ Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data);
+} s_info = {
+ .alloc_canvas = NULL,
+ .alloc_canvas_with_stride = NULL,
+};
+
/*!
* \brief
* Abstracted Data Type of Virtual Window
return ret;
}
-#if AUTO_ALIGN
static void *alloc_fb(void *data, int size)
{
struct info *info = data;
* Acquire a buffer for canvas.
*/
info->handle = livebox_acquire_buffer_NEW(info->id, info->is_pd,
- info->w, info->h, sizeof(int), AUTO_ALIGN, /* 0 == auto_align off */
+ info->w, info->h, sizeof(int), (livebox_conf_auto_align() || !s_info.alloc_canvas_with_stride),
event_handler_cb, info);
/*!
info->is_hw = 0;
return buffer;
}
-#else
-static void *alloc_fb(void *data, int size, int *stride, int *bpp)
+
+static void *alloc_stride_fb(void *data, int size, int *stride, int *bpp)
{
- struct info *info = data;
void *buffer;
- int _stride;
- int _bpp;
-
- if (info->ee) {
- ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h);
- LOGD("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info);
- }
- /*!
- * Acquire a buffer for canvas.
- */
- info->handle = livebox_acquire_buffer_NEW(info->id, info->is_pd,
- info->w, info->h, sizeof(int), AUTO_ALIGN, /* 0 == auto_align off */
- event_handler_cb, info);
-
- *bpp = sizeof(int);
- _stride = livebox_buffer_stride(info->handle);
- if (_stride < 0) {
- _stride = info->w * *bpp;
- }
- *stride = _stride;
- DbgPrint("bpp: %d, stride: %d\n", *bpp, *stride);
+ buffer = alloc_fb(data, size);
+ if (buffer) {
+ struct info *info = data;
+ int _stride;
- /*!
- * If it supports the H/W accelerated buffer,
- * Use it.
- */
- if (livebox_support_hw_buffer(info->handle)) {
- if (livebox_create_hw_buffer(info->handle) == 0) {
- buffer = livebox_buffer_hw_buffer(info->handle);
- if (buffer) {
- LOGD("HW Accelerated buffer is created %p, (%dx%d)\n", info, info->w, info->h);
- info->is_hw = 1;
- return buffer;
- }
+ *bpp = sizeof(int);
+ _stride = livebox_buffer_stride(info->handle);
+ if (_stride < 0) {
+ _stride = info->w * *bpp;
}
- LOGE("Failed to allocate HW Accelerated buffer\n");
+ *stride = _stride;
+ DbgPrint("bpp: %d, stride: %d\n", *bpp, *stride);
}
- /*!
- * Or use the buffer of a S/W backend.
- */
- buffer = livebox_ref_buffer(info->handle);
- LOGD("SW buffer is created (%dx%d)\n", info->w, info->h);
- info->is_hw = 0;
return buffer;
}
-#endif
static void free_fb(void *data, void *ptr)
{
struct info *info;
Evas_Object *rect;
+ if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride) {
+ s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new");
+ if (!s_info.alloc_canvas_with_stride) {
+ DbgPrint("allocfunc_with_stirde_new is not found\n");
+ }
+
+ s_info.alloc_canvas = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_new");
+ if (!s_info.alloc_canvas) {
+ ErrPrint("allocfunc_new is not found\n");
+ }
+
+ if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas) {
+ ErrPrint("No way to allocate canvas\n");
+ return NULL;
+ }
+ }
+
if (!id) {
ErrPrint("Invalid parameter\n");
return NULL;
info->w = 1;
info->h = 1;
-#if AUTO_ALIGN
- info->ee = ecore_evas_buffer_allocfunc_new(1, 1, alloc_fb, free_fb, info);
-#else
- info->ee = ecore_evas_buffer_allocfunc_with_stride_new(1, 1, alloc_fb, free_fb, info);
+ if (!livebox_conf_auto_align() && s_info.alloc_canvas_with_stride) {
+ info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info);
+ } else {
+ info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info);
+ }
+
if (!info->ee) {
ErrPrint("Failed to create ecore_evas (%dx%d)\n", 1, 1);
free(info->id);
free(info);
return NULL;
}
-#endif
info->e = ecore_evas_get(info->ee);
if (!info->e) {