4 * Copyright (c) 2000 - 2013 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>
11 * Anastasia Lyupa <a.lyupa@samsung.com>
13 * This library is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU Lesser General Public License as published by the
15 * Free Software Foundation; either version 2.1 of the License, or (at your option)
18 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21 * License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library; if not, write to the Free Software Foundation, Inc., 51
25 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * - Samsung RnD Institute Russia
40 #include "dacollection.h"
43 #include "tizen_probe.h"
45 using namespace Tizen::Base;
46 using namespace Tizen::Ui;
47 using namespace Tizen::Graphics;
48 using namespace Tizen::Media;
51 #define LIBUTILX "libutilX.so.1"
53 typedef void* (*utilx_create_screen_shot_type)(Display* dpy, int width, int height);
54 typedef void (*utilx_release_screen_shot_type)(void);
56 static Tizen::Graphics::Bitmap* sysutil_capture_screen()
58 static utilx_create_screen_shot_type utilx_create_screen_shotp;
59 static utilx_release_screen_shot_type utilx_release_screen_shotp;
61 Bitmap* pBitmap = NULL;
63 if (unlikely(utilx_create_screen_shotp == NULL))
65 void* lib_handle = dlopen(LIBUTILX, RTLD_LAZY);
66 if (lib_handle == NULL) {
67 SetLastResult(ERR_DLOPEN);
70 utilx_create_screen_shotp = (utilx_create_screen_shot_type)dlsym(lib_handle, "utilx_create_screen_shot");
71 if (utilx_create_screen_shotp == NULL || dlerror() != NULL) {
72 SetLastResult(ERR_DLSYM);
77 if (unlikely(utilx_release_screen_shotp == NULL))
79 void* lib_handle = dlopen(LIBUTILX, RTLD_LAZY);
80 if (lib_handle == NULL) {
81 SetLastResult(ERR_DLOPEN);
84 utilx_release_screen_shotp = (utilx_release_screen_shot_type)dlsym(lib_handle, "utilx_release_screen_shot");
85 if (utilx_release_screen_shotp == NULL || dlerror() != NULL) {
86 SetLastResult(ERR_DLSYM);
91 Display* pDpy = XOpenDisplay(NULL);
94 SetLastResult(ERR_USER - 1);
98 int width = DisplayWidth(pDpy, DefaultScreen(pDpy));
99 int height = DisplayHeight(pDpy, DefaultScreen(pDpy));
101 void* pDump = utilx_create_screen_shotp(pDpy, width, height);
102 if (likely(pDump != NULL))
105 r = buffer.Construct(static_cast<byte*>(pDump), 0, width*height*4, width*height*4);\
106 if (likely(r == E_SUCCESS))
108 Tizen::Graphics::Dimension dim(width, height);
109 Bitmap* pBitmap = new Bitmap();
110 if (likely(pBitmap != NULL))
112 r = pBitmap->Construct(buffer, dim, BITMAP_PIXEL_FORMAT_ARGB8888);
113 if (unlikely(r != E_SUCCESS))
119 else { SetLastResult(E_SUCCESS); }
121 else { SetLastResult(ERR_OUTOFMEMORY); }
123 else { SetLastResult(r); }
125 else { SetLastResult(ERR_USER - 2); }
127 utilx_release_screen_shotp();
132 static Bitmap* getBitmapFromBuffer(void* pDump, int width, int height)
136 Bitmap* pBitmap = NULL;
138 r = buffer.Construct(static_cast<byte*>(pDump), 0, width*height*4, width*height*4);
139 if (likely(r == E_SUCCESS))
141 Tizen::Graphics::Dimension dim(width, height);
142 pBitmap = new Bitmap();
143 if (likely(pBitmap != NULL))
145 r = pBitmap->Construct(buffer, dim, BITMAP_PIXEL_FORMAT_ARGB8888);
146 if (unlikely(r != E_SUCCESS))
152 else { SetLastResult(E_SUCCESS); }
154 else { SetLastResult(ERR_OUTOFMEMORY); }
156 else { SetLastResult(r); }
161 // return 0 if succeed
162 // return -1 if failed to capture
167 probeInfo_t probeInfo; log_t log;
169 int ret = 0, width, height;
174 capbuf = captureScreenShotX(&width, &height);
177 bitmap = getBitmapFromBuffer((void*)capbuf, width, height);
181 setProbePoint(&probeInfo);
183 dstPath.Format(MAX_PATH_LENGTH, L"/tmp/da/%d.jpg", probeInfo.eventIndex);
185 r = img.EncodeToFile(*bitmap, IMG_FORMAT_JPG, dstPath, true);
189 APPEND_LOG_BASIC_NAME(LC_SNAPSHOT, "captureScreen");
190 APPEND_LOG_COMMON_NONE(0);
191 log.length += sprintf(log.data + log.length, "`,%S", dstPath.GetPointer());
192 printLog(&log, MSG_LOG);
205 sprintf(buf, "bitmap is null (%p, %d, %s)\n", capbuf, (int)r, GetErrorMessage(r));
214 releaseScreenShotX();
221 namespace Tizen { namespace Ui {
226 Evas* GetEvas(void) const;
231 void SetEcoreEvas(const _EcoreEvas& ecoreevas);
235 void _EcoreEvasMgr::SetEcoreEvas(const _EcoreEvas& ecoreevas)
237 typedef void (_EcoreEvasMgr::*methodType)(const _EcoreEvas& ecoreevas);
238 static methodType _ecoreevasmgr_setecoreevasp;
240 GET_REAL_FUNC_TIZEN(_ZN5Tizen2Ui13_EcoreEvasMgr12SetEcoreEvasERKNS0_10_EcoreEvasE,
241 LIBOSP_UIFW, _ecoreevasmgr_setecoreevasp);
244 evas_event_callback_add(ecoreevas.GetEvas(),
245 EVAS_CALLBACK_RENDER_FLUSH_POST, _cb_render_post, NULL);
248 (this->*_ecoreevasmgr_setecoreevasp)(ecoreevas);
252 result Control::SetShowState(bool state)
254 typedef result (Control::*methodType)(bool state);
255 static methodType control_setshowstatep;
258 GET_REAL_FUNC_TIZEN(_ZN5Tizen2Ui7Control12SetShowStateEb,
259 LIBOSP_UIFW, control_setshowstatep);
261 ret = (this->*control_setshowstatep)(state);
265 char *type, *classname;
266 if (find_uiobject_hash((void*)this, &type, &classname) == 1)
268 if (strcmp(type, "Panel") == 0 || strcmp(type, "OverlayPanel") == 0 || strcmp(type, "ScrollPanel") == 0)
271 // SCREENSHOT_DONE();
290 result Frame::SetCurrentForm(const Form& form)
292 typedef result (Frame::*methodType)(const Form& form);
293 static methodType frame_setcurrentformp;
296 GET_REAL_FUNC_TIZEN(_ZN5Tizen2Ui8Controls5Frame14SetCurrentFormERKNS1_4FormE,
297 LIBOSP_UIFW, frame_setcurrentformp);
299 ret = (this->*frame_setcurrentformp)(form);
303 // SCREENSHOT_DONE();
309 result Frame::SetCurrentForm(Form* pForm)
311 typedef result (Frame::*methodType)(Form* pForm);
312 static methodType frame_setcurrentformp;
315 GET_REAL_FUNC_TIZEN(_ZN5Tizen2Ui8Controls5Frame14SetCurrentFormEPNS1_4FormE,
316 LIBOSP_UIFW, frame_setcurrentformp);
318 ret = (this->*frame_setcurrentformp)(pForm);
322 // SCREENSHOT_DONE();
329 } // end of namespace Tizen::Ui::Controls
331 namespace Animations {
333 result FrameAnimator::SetCurrentForm(const Tizen::Ui::Controls::Form& form)
335 typedef result (FrameAnimator::*methodType)(const Tizen::Ui::Controls::Form& form);
336 static methodType frameanimator_setcurrentformp;
339 GET_REAL_FUNC_TIZEN(_ZN5Tizen2Ui10Animations13FrameAnimator14SetCurrentFormERKNS0_8Controls4FormE,
340 LIBOSP_UIFW, frameanimator_setcurrentformp);
342 ret = (this->*frameanimator_setcurrentformp)(form);
346 // SCREENSHOT_DONE();
352 result FrameAnimator::SetCurrentForm(Tizen::Ui::Controls::Form* pForm)
354 typedef result (FrameAnimator::*methodType)(Tizen::Ui::Controls::Form* pForm);
355 static methodType frameanimator_setcurrentformp;
358 GET_REAL_FUNC_TIZEN(_ZN5Tizen2Ui10Animations13FrameAnimator14SetCurrentFormEPNS0_8Controls4FormE,
359 LIBOSP_UIFW, frameanimator_setcurrentformp);
361 ret = (this->*frameanimator_setcurrentformp)(pForm);
365 // SCREENSHOT_DONE();
372 } // end of namespace Tizen::Ui::Animations
374 } } // end of namespace Tizen::Ui