1 #ifndef DALI_TIZEN_WEB_ENGINE_LWE_H
2 #define DALI_TIZEN_WEB_ENGINE_LWE_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
24 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
25 #include <dali/devel-api/threading/mutex.h>
26 #include <dali/public-api/adaptor-framework/native-image-source.h>
27 #include <dali/public-api/adaptor-framework/timer.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
29 #include <LWEWebView.h>
32 #ifndef DALI_USE_TBMSURFACE
33 #define DALI_USE_TBMSURFACE
36 #ifdef DALI_USE_TBMSURFACE
37 #include <tbm_surface.h>
39 #include <dali/public-api/images/buffer-image.h>
51 * @brief Implementation of the Tizen WebEngineLWE class which has Tizen platform dependency.
53 class TizenWebEngineLWE : public Dali::WebEnginePlugin, public Dali::ConnectionTracker
65 virtual ~TizenWebEngineLWE();
68 * @copydoc Dali::WebEnginePlugin::Create()
70 void Create( int width, int height, const std::string& locale, const std::string& timezoneId ) override;
73 * @copydoc Dali::WebEnginePlugin::GetSettings()
75 Dali::WebEngineSettings& GetSettings() const override;
78 * @copydoc Dali::WebEnginePlugin::GetContext()
80 Dali::WebEngineContext& GetContext() const override;
83 * @copydoc Dali::WebEnginePlugin::GetCookieManager()
85 Dali::WebEngineCookieManager& GetCookieManager() const override;
88 * @copydoc Dali::WebEnginePlugin::GetBackForwardList()
90 Dali::WebEngineBackForwardList& GetBackForwardList() const override;
93 * @copydoc Dali::WebEnginePlugin::Create()
95 void Create( int width, int height, int argc, char** argv ) override;
98 * @copydoc Dali::WebEnginePlugin::Destroy()
100 void Destroy() override;
103 * @copydoc Dali::WebEnginePlugin::GetNativeImageSource()
105 Dali::NativeImageInterfacePtr GetNativeImageSource() override;
108 * @copydoc Dali::WebEnginePlugin::LoadUrl()
110 void LoadUrl( const std::string& url ) override;
113 * @copydoc Dali::WebEnginePlugin::GetTitle()
115 std::string GetTitle() const override;
118 * @copydoc Dali::WebEnginePlugin::GetFavicon()
120 Dali::PixelData GetFavicon() const override;
123 * @copydoc Dali::WebEnginePlugin::GetUrl()
125 const std::string& GetUrl() override;
128 * @copydoc Dali::WebEnginePlugin::LoadHTMLString()
130 void LoadHtmlString( const std::string& string ) override;
133 * @copydoc Dali::WebEnginePlugin::Reload()
135 void Reload() override;
138 * @copydoc Dali::WebEnginePlugin::StopLoading()
140 void StopLoading() override;
143 * @copydoc Dali::WebEnginePlugin::Suspend()
145 void Suspend() override;
148 * @copydoc Dali::WebEnginePlugin::Resume()
150 void Resume() override;
153 * @copydoc Dali::WebEnginePlugin::ScrollBy()
155 void ScrollBy( int deltaX, int deltaY ) override;
158 * @copydoc Dali::WebEnginePlugin::SetScrollPosition()
160 void SetScrollPosition( int x, int y ) override;
163 * @copydoc Dali::WebEnginePlugin::GetScrollPosition()
165 void GetScrollPosition( int& x, int& y ) const override;
168 * @copydoc Dali::WebEnginePlugin::GetScrollSize()
170 void GetScrollSize( int& width, int& height ) const override;
173 * @copydoc Dali::WebEnginePlugin::GetContentSize()
175 void GetContentSize( int& width, int& height ) const override;
178 * @copydoc Dali::WebEnginePlugin::GoBack()
180 void GoBack() override;
183 * @copydoc Dali::WebEnginePlugin::GoForward()
185 void GoForward() override;
188 * @copydoc Dali::WebEnginePlugin::CanGoBack()
190 bool CanGoBack() override;
193 * @copydoc Dali::WebEnginePlugin::CanGoForward()
195 bool CanGoForward() override;
198 * @copydoc Dali::WebEnginePlugin::EvaluateJavaScript()
200 void EvaluateJavaScript( const std::string& script, std::function< void(const std::string&) > resultHandler ) override;
203 * @copydoc Dali::WebEnginePlugin::AddJavaScriptMessageHandler()
205 void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler ) override;
208 * @copydoc Dali::WebEnginePlugin::ClearAllTilesResources()
210 void ClearAllTilesResources() override;
213 * @copydoc Dali::WebEnginePlugin::ClearHistory()
215 void ClearHistory() override;
218 * @copydoc Dali::WebEnginePlugin::GetUserAgent()
220 const std::string& GetUserAgent() const override;
223 * @copydoc Dali::WebEnginePlugin::SetUserAgent()
225 void SetUserAgent( const std::string& userAgent ) override;
228 * @copydoc Dali::WebEnginePlugin::SetSize()
230 void SetSize( int width, int height ) override;
233 * @copydoc Dali::WebEnginePlugin::SendTouchEvent()
235 bool SendTouchEvent( const Dali::TouchEvent& touch ) override;
238 * @copydoc Dali::WebEnginePlugin::SendKeyEvent()
240 bool SendKeyEvent( const Dali::KeyEvent& event ) override;
243 * @copydoc Dali::WebEnginePlugin::SetFocus()
245 void SetFocus( bool focused ) override;
248 * @copydoc Dali::WebEnginePlugin::PageLoadStartedSignal()
250 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal() override
252 return mPageLoadStartedSignal;
256 * @copydoc Dali::WebEnginePlugin::PageLoadFinishedSignal()
258 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal() override
260 return mPageLoadFinishedSignal;
264 * @copydoc Dali::WebEnginePlugin::PageLoadErrorSignal()
266 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() override
268 return mPageLoadErrorSignal;
272 * @copydoc Dali::WebEnginePlugin::ScrollEdgeReachedSignal()
274 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() override
276 return mScrollEdgeReachedSignal;
283 void DestroyInstance();
285 void DispatchMouseDownEvent(float x, float y);
287 void DispatchMouseUpEvent(float x, float y);
289 void DispatchMouseMoveEvent(float x, float y, bool isLButtonPressed, bool isRButtonPressed);
291 void DispatchKeyDownEvent(LWE::KeyValue keyCode);
293 void DispatchKeyPressEvent(LWE::KeyValue keyCode);
295 void DispatchKeyUpEvent(LWE::KeyValue keyCode);
301 size_t mOutputHeight;
302 size_t mOutputStride;
303 uint8_t* mOutputBuffer;
304 bool mIsMouseLbuttonDown;
307 pthread_mutex_t mOutputBufferMutex;
308 LWE::WebContainer* mWebContainer;
309 #ifdef DALI_USE_TBMSURFACE
310 tbm_surface_h mTbmSurface;
311 Dali::NativeImageSourcePtr mNativeImageSourcePtr;
313 Dali::BufferImage mBufferImage;
316 std::function<void(LWE::WebContainer*, const LWE::WebContainer::RenderResult&)> mOnRenderedHandler;
317 std::function<void(LWE::WebContainer*, LWE::ResourceError)> mOnReceivedError;
318 std::function<void(LWE::WebContainer*, const std::string&)> mOnPageFinishedHandler;
319 std::function<void(LWE::WebContainer*, const std::string&)> mOnPageStartedHandler;
320 std::function<void(LWE::WebContainer*, const std::string&)> mOnLoadResourceHandler;
322 EventThreadCallback mUpdateBufferTrigger;
323 Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadStartedSignal;
324 Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadFinishedSignal;
325 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType mPageLoadErrorSignal;
326 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
329 } // namespace Plugin