2 // Open Service Platform
\r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
\r
5 // Licensed under the Apache License, Version 2.0 (the License);
\r
6 // you may not use this file except in compliance with the License.
\r
7 // You may obtain a copy of the License at
\r
9 // http://www.apache.org/licenses/LICENSE-2.0
\r
11 // Unless required by applicable law or agreed to in writing, software
\r
12 // distributed under the License is distributed on an "AS IS" BASIS,
\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 // See the License for the specific language governing permissions and
\r
15 // limitations under the License.
\r
19 * @file FWebCtrl_Utility.cpp
\r
20 * @brief The file contains the definition of _Utility class.
\r
22 * The file contains the definition of _Utility class.
\r
26 #include <FAppUiApp.h>
\r
27 #include <FAppIAppFrame.h>
\r
28 #include <FBaseSysLog.h>
\r
29 #include <FApp_AppInfo.h>
\r
30 #include <FUiAnim_EflNode.h>
\r
31 #include <FUiAnim_VisualElementImpl.h>
\r
32 #include <FUiCtrlFrame.h>
\r
33 #include <FUi_ControlImpl.h>
\r
34 #include "FWebCtrl_Utility.h"
\r
36 using namespace Tizen::App;
\r
37 using namespace Tizen::Base;
\r
38 using namespace Tizen::Graphics;
\r
39 using namespace Tizen::Ui;
\r
40 using namespace Tizen::Ui::Controls;
\r
41 using namespace Tizen::Ui::Animations;
\r
43 namespace Tizen { namespace Web { namespace Controls
\r
47 static const float SEVICE_APP_FRAME_SIZE = 200;
\r
50 _Utility::_Utility(void)
\r
54 _Utility::~_Utility(void)
\r
60 _Utility::GetEvasFromUiApp(Tizen::Ui::Controls::Frame* pTempFrame)
\r
62 Frame* pFrame = null;
\r
64 if (_AppInfo::GetAppType() == _APP_TYPE_UI_APP)
\r
66 IAppFrame* pAppFrame = Application::GetInstance()->GetAppFrame();
\r
67 SysTryReturn(NID_WEB_CTRL, pAppFrame, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
\r
69 pFrame = pAppFrame->GetFrame();
\r
70 SysTryReturn(NID_WEB_CTRL, pFrame, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
\r
74 pFrame = new (std::nothrow) Frame();
\r
75 pFrame->Construct(Rectangle(0, 0, SEVICE_APP_FRAME_SIZE, SEVICE_APP_FRAME_SIZE));
\r
77 pTempFrame = pFrame;
\r
80 _ControlImpl* pControlimpl = _ControlImpl::GetInstance(*pFrame);
\r
81 SysTryReturn(NID_WEB_CTRL, pControlimpl, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
\r
83 VisualElement* pVisual = pControlimpl->GetCore().GetVisualElement();
\r
84 SysTryReturn(NID_WEB_CTRL, pVisual, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
\r
86 _VisualElementImpl* pWebVisualElementImpl = _VisualElementImpl::GetInstance(*pVisual);
\r
87 SysTryReturn(NID_WEB_CTRL,pWebVisualElementImpl, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
\r
89 _EflNode* pEflNode = dynamic_cast< _EflNode* >(pWebVisualElementImpl->GetNativeNode());
\r
90 SysTryReturn(NID_WEB_CTRL, pEflNode, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
\r
92 pEvas = pEflNode->GetEvas();
\r
93 SysTryReturn(NID_WEB_CTRL, pEvas, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
\r
100 _Utility::GetPixelBufferFromEvasObject(const Evas_Object* source, Tizen::Graphics::BufferInfo& bufferInfo)
\r
102 bufferInfo.pPixels = evas_object_image_data_get(source, EINA_FALSE);
\r
103 SysTryReturnResult(NID_WEB_CTRL, bufferInfo.pPixels, E_INVALID_DATA, "Failed to get pixel data from evas object.");
\r
105 evas_object_image_size_get(source, &bufferInfo.width, &bufferInfo.height);
\r
107 Evas_Colorspace colorSpace = evas_object_image_colorspace_get(source);
\r
109 switch (colorSpace)
\r
111 case EVAS_COLORSPACE_ARGB8888:
\r
112 bufferInfo.bitsPerPixel = 32;
\r
113 bufferInfo.pixelFormat = PIXEL_FORMAT_ARGB8888;
\r
116 case EVAS_COLORSPACE_YCBCR422P601_PL:
\r
117 bufferInfo.bitsPerPixel = 0;
\r
118 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
121 case EVAS_COLORSPACE_YCBCR422P709_PL:
\r
122 bufferInfo.bitsPerPixel = 0;
\r
123 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
126 case EVAS_COLORSPACE_RGB565_A5P:
\r
127 bufferInfo.bitsPerPixel = 0;
\r
128 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
131 case EVAS_COLORSPACE_GRY8:
\r
132 bufferInfo.bitsPerPixel = 0;
\r
133 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
136 case EVAS_COLORSPACE_YCBCR422601_PL:
\r
137 bufferInfo.bitsPerPixel = 0;
\r
138 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
141 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
\r
142 bufferInfo.bitsPerPixel = 0;
\r
143 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
146 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
\r
147 bufferInfo.bitsPerPixel = 0;
\r
148 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
152 bufferInfo.bitsPerPixel = 0;
\r
153 bufferInfo.pixelFormat = PIXEL_FORMAT_MIN;
\r
157 bufferInfo.pitch = bufferInfo.width * bufferInfo.bitsPerPixel / 8;
\r
159 SysLog(NID_WEB_CTRL, "color space : %d, pitch (%d), w-h (%d, %d)", colorSpace, bufferInfo.pitch, bufferInfo.width, bufferInfo.height);
\r
166 _Utility::CreateOrigin(const Ewk_Security_Origin* pSecurityOrigin)
\r
168 String protocol(ewk_security_origin_protocol_get(pSecurityOrigin));
\r
169 String host(ewk_security_origin_host_get(pSecurityOrigin));
\r
170 int port = ewk_security_origin_port_get(pSecurityOrigin);
\r
172 String origin = protocol + L"://" + host;
\r
176 origin.Append(L":");
\r
177 origin.Append(port);
\r
180 SysLog(NID_WEB_CTRL, "The current value of origin is %ls", origin.GetPointer());
\r