blob: b4c589030e9ef236c8fa443d3202451368c45482 [file] [log] [blame]
codeworkxf1be2fe2012-03-24 17:38:29 +01001/*
2**
3** Copyright 2009 Samsung Electronics Co, Ltd.
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16**
17**
18*/
19
20///////////////////////////////////////////////////
21// include
22///////////////////////////////////////////////////
23#define LOG_NDEBUG 0
24#define LOG_TAG "FimgApi"
25#include <utils/Log.h>
26
27#include "FimgApi.h"
28
29//---------------------------------------------------------------------------//
30// Global Function
31//---------------------------------------------------------------------------//
32#ifndef REAL_DEBUG
33 void VOID_FUNC(const char* format, ...)
34 {}
35#endif
36
37//---------------------------------------------------------------------------//
38// FimgApi
39//---------------------------------------------------------------------------//
40
41//---------------------------------------------------------------------------//
42// Method Function Implementation
43//---------------------------------------------------------------------------//
44
45FimgApi::FimgApi()
46{
47 m_flagCreate = false;
48}
49
50FimgApi::~FimgApi()
51{
52 if(m_flagCreate == true)
53 PRINT("%s::this is not Destroyed fail \n", __func__);
54}
55
56bool FimgApi::Create(void)
57{
58 bool ret = false;
59
60 if(t_Lock() == false) {
61 PRINT("%s::t_Lock() fail \n", __func__);
62 goto CREATE_DONE;
63 }
64
65 if(m_flagCreate == true) {
66 PRINT("%s::Already Created fail \n", __func__);
67 goto CREATE_DONE;
68 }
69
70 if(t_Create() == false) {
71 PRINT("%s::t_Create() fail \n", __func__);
72 goto CREATE_DONE;
73 }
74
75 m_flagCreate = true;
76
77 ret = true;
78
79CREATE_DONE :
80
81 t_UnLock();
82
83 return ret;
84}
85
86bool FimgApi::Destroy(void)
87{
88 bool ret = false;
89
90 if(t_Lock() == false) {
91 PRINT("%s::t_Lock() fail \n", __func__);
92 goto DESTROY_DONE;
93 }
94
95 if(m_flagCreate == false) {
96 PRINT("%s::Already Destroyed fail \n", __func__);
97 goto DESTROY_DONE;
98 }
99
100 if(t_Destroy() == false) {
101 PRINT("%s::t_Destroy() fail \n", __func__);
102 goto DESTROY_DONE;
103 }
104
105 m_flagCreate = false;
106
107 ret = true;
108
109DESTROY_DONE :
110
111 t_UnLock();
112
113 return ret;
114}
115
116bool FimgApi::Stretch(FimgRect * src, FimgRect * dst, FimgClip *clip, FimgFlag * flag)
117{
118 bool ret = false;
119
120 if(t_Lock() == false) {
121 PRINT("%s::t_Lock() fail \n", __func__);
122 goto STRETCH_DONE;
123 }
124
125 if(m_flagCreate == false) {
126 PRINT("%s::This is not Created fail \n", __func__);
127 goto STRETCH_DONE;
128 }
129
130 if(t_Stretch(src, dst, clip, flag) == false) {
131 goto STRETCH_DONE;
132 }
133
134 ret = true;
135
136STRETCH_DONE :
137
138 t_UnLock();
139
140 return ret;
141}
142
143bool FimgApi::Sync(void)
144{
145 bool ret = false;
146
147 if(m_flagCreate == false) {
148 PRINT("%s::This is not Created fail \n", __func__);
149 goto SYNC_DONE;
150 }
151
152 if(t_Sync() == false) {
153 goto SYNC_DONE;
154 }
155
156 ret = true;
157
158SYNC_DONE :
159
160 return ret;
161}
162
163bool FimgApi::t_Create(void)
164{
165 PRINT("%s::This is empty virtual function fail\n", __func__);
166 return false;
167}
168
169bool FimgApi::t_Destroy(void)
170{
171 PRINT("%s::This is empty virtual function fail\n", __func__);
172 return false;
173}
174
175bool FimgApi::t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag)
176{
177 PRINT("%s::This is empty virtual function fail\n", __func__);
178 return false;
179}
180
181bool FimgApi::t_Sync(void)
182{
183 PRINT("%s::This is empty virtual function fail\n", __func__);
184 return false;
185}
186
187bool FimgApi::t_Lock(void)
188{
189 PRINT("%s::This is empty virtual function fail\n", __func__);
190 return false;
191}
192
193bool FimgApi::t_UnLock(void)
194{
195 PRINT("%s::This is empty virtual function fail\n", __func__);
196 return false;
197}
198
199
200//---------------------------------------------------------------------------//
201// extern function
202//---------------------------------------------------------------------------//
203extern "C" int stretchFimgApi(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag)
204{
205 FimgApi * fimgApi = createFimgApi();
206
207 if(fimgApi == NULL) {
208 PRINT("%s::createFimgApi() fail \n", __func__);
209 return -1;
210 }
211
212 if(fimgApi->Stretch(src, dst, clip, flag) == false) {
213 if(fimgApi != NULL)
214 destroyFimgApi(fimgApi);
215
216 return -1;
217 }
218
219 if(fimgApi != NULL)
220 destroyFimgApi(fimgApi);
221
222 return 0;
223}
224
225extern "C" int SyncFimgApi(void)
226{
227 FimgApi * fimgApi = createFimgApi();
228 if(fimgApi == NULL) {
229 PRINT("%s::createFimgApi() fail \n", __func__);
230 return -1;
231 }
232
233 if(fimgApi->Sync() == false) {
234 if(fimgApi != NULL)
235 destroyFimgApi(fimgApi);
236
237 return -1;
238 }
239
240 if(fimgApi != NULL)
241 destroyFimgApi(fimgApi);
242
243 return 0;
244}
245