4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
12 * This library is free software; you can redistribute it and/or modify it under
13 * the terms of the GNU Lesser General Public License as published by the
14 * Free Software Foundation; either version 2.1 of the License, or (at your option)
17 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 * License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this library; if not, write to the Free Software Foundation, Inc., 51
24 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
38 #include "dacollection.h"
41 #include "osp_probe.h"
43 using namespace Tizen::Base;
44 using namespace Tizen::Ui;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Media;
49 #define LIBUTILX "libutilX.so.1"
51 typedef void* (*utilx_create_screen_shot_type)(Display* dpy, int width, int height);
52 typedef void (*utilx_release_screen_shot_type)(void);
54 static Tizen::Graphics::Bitmap* sysutil_capture_screen()
56 static utilx_create_screen_shot_type utilx_create_screen_shotp;
57 static utilx_release_screen_shot_type utilx_release_screen_shotp;
59 Bitmap* pBitmap = NULL;
61 if(unlikely(utilx_create_screen_shotp == NULL))
63 void* lib_handle = dlopen(LIBUTILX, RTLD_LAZY);
64 if(lib_handle == NULL) {
65 SetLastResult(ERR_DLOPEN);
68 utilx_create_screen_shotp = (utilx_create_screen_shot_type)dlsym(lib_handle, "utilx_create_screen_shot");
69 if(utilx_create_screen_shotp == NULL || dlerror() != NULL) {
70 SetLastResult(ERR_DLSYM);
75 if(unlikely(utilx_release_screen_shotp == NULL))
77 void* lib_handle = dlopen(LIBUTILX, RTLD_LAZY);
78 if(lib_handle == NULL) {
79 SetLastResult(ERR_DLOPEN);
82 utilx_release_screen_shotp = (utilx_release_screen_shot_type)dlsym(lib_handle, "utilx_release_screen_shot");
83 if(utilx_release_screen_shotp == NULL || dlerror() != NULL) {
84 SetLastResult(ERR_DLSYM);
89 Display* pDpy = XOpenDisplay(NULL);
92 SetLastResult(ERR_USER - 1);
96 int width = DisplayWidth(pDpy, DefaultScreen(pDpy));
97 int height = DisplayHeight(pDpy, DefaultScreen(pDpy));
99 void* pDump = utilx_create_screen_shotp(pDpy, width, height);
100 if(likely(pDump != NULL))
103 r = buffer.Construct(static_cast<byte*>(pDump), 0, width*height*4, width*height*4);\
104 if(likely(r == E_SUCCESS))
106 Tizen::Graphics::Dimension dim(width, height);
107 Bitmap* pBitmap = new Bitmap();
108 if(likely(pBitmap != NULL))
110 r = pBitmap->Construct(buffer, dim, BITMAP_PIXEL_FORMAT_ARGB8888);
111 if(unlikely(r != E_SUCCESS))
117 else { SetLastResult(E_SUCCESS); }
119 else { SetLastResult(ERR_OUTOFMEMORY); }
121 else { SetLastResult(r); }
123 else { SetLastResult(ERR_USER - 2); }
125 utilx_release_screen_shotp();
130 static Bitmap* getBitmapFromBuffer(void* pDump, int width, int height)
134 Bitmap* pBitmap = NULL;
136 r = buffer.Construct(static_cast<byte*>(pDump), 0, width*height*4, width*height*4);
137 if(likely(r == E_SUCCESS))
139 Tizen::Graphics::Dimension dim(width, height);
140 pBitmap = new Bitmap();
141 if(likely(pBitmap != NULL))
143 r = pBitmap->Construct(buffer, dim, BITMAP_PIXEL_FORMAT_ARGB8888);
144 if(unlikely(r != E_SUCCESS))
150 else { SetLastResult(E_SUCCESS); }
152 else { SetLastResult(ERR_OUTOFMEMORY); }
154 else { SetLastResult(r); }
159 // return 0 if succeed
160 // return -1 if failed to capture
165 DECLARE_COMMON_VARIABLE;
167 int ret = 0, width, height;
172 capbuf = captureScreenShotX(&width, &height);
175 bitmap = getBitmapFromBuffer((void*)capbuf, width, height);
179 setProbePoint(&probeInfo);
181 dstPath.Format(MAX_PATH_LENGTH, L"/tmp/da/%d.jpg", probeInfo.eventIndex);
183 r = img.EncodeToFile(*bitmap, IMG_FORMAT_JPG, dstPath, true);
187 APPEND_LOG_BASIC_NAME(LC_SNAPSHOT, "captureScreen");
188 APPEND_LOG_COMMON_NONE(0);
189 log.length += sprintf(log.data + log.length, "`,%S", dstPath.GetPointer());
190 printLog(&log, MSG_LOG);
203 sprintf(buf, "bitmap is null (%p, %d, %s)\n", capbuf, (int)r, GetErrorMessage(r));
213 releaseScreenShotX();
220 namespace Tizen { namespace Ui {
225 Evas* GetEvas(void) const;
230 void SetEcoreEvas(const _EcoreEvas& ecoreevas);
234 void _EcoreEvasMgr::SetEcoreEvas(const _EcoreEvas& ecoreevas)
236 typedef void (_EcoreEvasMgr::*methodType)(const _EcoreEvas& ecoreevas);
237 static methodType _ecoreevasmgr_setecoreevasp;
239 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui13_EcoreEvasMgr12SetEcoreEvasERKNS0_10_EcoreEvasE,
240 LIBOSP_UIFW, _ecoreevasmgr_setecoreevasp);
243 evas_event_callback_add(ecoreevas.GetEvas(),
244 EVAS_CALLBACK_RENDER_FLUSH_POST, _cb_render_post, NULL);
247 (this->*_ecoreevasmgr_setecoreevasp)(ecoreevas);
251 result Control::SetShowState(bool state)
253 typedef result (Control::*methodType)(bool state);
254 static methodType control_setshowstatep;
257 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui7Control12SetShowStateEb,
258 LIBOSP_UIFW, control_setshowstatep);
260 ret = (this->*control_setshowstatep)(state);
264 char *type, *classname;
265 if(find_object_hash((void*)this, &type, &classname) == 1)
267 if(strcmp(type, "Panel") == 0 || strcmp(type, "OverlayPanel") == 0 || strcmp(type, "ScrollPanel") == 0)
270 // SCREENSHOT_DONE();
289 result Frame::SetCurrentForm(const Form& form)
291 typedef result (Frame::*methodType)(const Form& form);
292 static methodType frame_setcurrentformp;
295 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui8Controls5Frame14SetCurrentFormERKNS1_4FormE,
296 LIBOSP_UIFW, frame_setcurrentformp);
298 ret = (this->*frame_setcurrentformp)(form);
302 // SCREENSHOT_DONE();
308 } // end of namespace Tizen::Ui::Controls
310 namespace Animations {
312 result FrameAnimator::SetCurrentForm(const Tizen::Ui::Controls::Form& form)
314 typedef result (FrameAnimator::*methodType)(const Tizen::Ui::Controls::Form& form);
315 static methodType frameanimator_setcurrentformp;
318 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui10Animations13FrameAnimator14SetCurrentFormERKNS0_8Controls4FormE,
319 LIBOSP_UIFW, frameanimator_setcurrentformp);
321 ret = (this->*frameanimator_setcurrentformp)(form);
325 // SCREENSHOT_DONE();
331 } // end of namespace Tizen::Ui::Animations
333 } } // end of namespace Tizen::Ui