remove execute permissions
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr_backend.c
1 /**************************************************************************
2
3 libtbm
4
5 Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
6
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
8 Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
9
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
20 of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 **************************************************************************/
31
32 #include "config.h"
33
34 #include <unistd.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <sys/types.h>
38 #include "tbm_bufmgr_int.h"
39
40 tbm_bufmgr_backend
41 tbm_backend_alloc (void)
42 {
43     tbm_bufmgr_backend bufmgr_backend;
44
45     bufmgr_backend = calloc (1, sizeof(struct _tbm_bufmgr_backend));
46     if (!bufmgr_backend)
47         return NULL;
48
49     return bufmgr_backend;
50 }
51
52 void
53 tbm_backend_free (tbm_bufmgr_backend backend)
54 {
55     if (!backend)
56         return;
57
58     free (backend);
59     backend = NULL;
60 }
61
62 int
63 tbm_backend_init (tbm_bufmgr bufmgr, tbm_bufmgr_backend backend)
64 {
65     int flags = 0;
66
67     if (!bufmgr)
68     {
69         TBM_LOG ("[libtbm:%d] "
70             "error (%s): fail to init tbm backend... bufmgr is null\n",
71             getpid(), __FUNCTION__);
72         return 0;
73     }
74
75     if (!backend)
76     {
77         TBM_LOG ("[libtbm:%d] "
78             "error (%s): fail to init tbm backend... backend is null\n",
79             getpid(), __FUNCTION__);
80         return 0;
81     }
82
83     flags = backend->flags;
84     /* check the backend flags */
85     if (!(flags&TBM_CACHE_CTRL_BACKEND))
86     {
87         if (!backend->bo_cache_flush)
88         {
89             TBM_LOG ("[libtbm:%d] "
90                 "error (%s): TBM_FLAG_CACHE_CTRL_TBM needs backend->bo_cache_flush\n",
91                 getpid(), __FUNCTION__);
92             return 0;
93         }
94     }
95
96     /* log for tbm flags */
97     TBM_LOG ("[libtbm:%d] ", getpid());
98     TBM_LOG ("cache_crtl:");
99     if (flags&TBM_CACHE_CTRL_BACKEND)
100         TBM_LOG ("BACKEND ");
101     else
102         TBM_LOG ("TBM ");
103     TBM_LOG ("lock_crtl:");
104     if (flags&TBM_LOCK_CTRL_BACKEND)
105         TBM_LOG ("BACKEND ");
106     else
107         TBM_LOG ("TBM ");
108     TBM_LOG ("\n");
109
110     bufmgr->backend = backend;
111
112     return 1;
113 }
114
115 void *
116 tbm_backend_get_bufmgr_priv (tbm_bo bo)
117 {
118     tbm_bufmgr_backend backend = bo->bufmgr->backend;
119
120     return backend->priv;
121 }
122
123 void
124 tbm_backend_set_bo_priv (tbm_bo bo, void *bo_priv)
125 {
126     bo->priv = bo_priv;
127 }
128
129 void *
130 tbm_backend_get_bo_priv (tbm_bo bo)
131 {
132     return bo->priv;
133 }
134
135
136