Skip to content

Commit 571fa4a

Browse files
committed
[webview_flutter_dev] Change webview interface && embedding lwe.so file (#15)
* temporal soluation Signed-off-by: MuHong Byun <[email protected]>
1 parent 3413964 commit 571fa4a

File tree

7 files changed

+32
-15
lines changed

7 files changed

+32
-15
lines changed

packages/webview_flutter/example/lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class _WebViewExampleState extends State<WebViewExample> {
5858
// to allow calling Scaffold.of(context) so we can show a snackbar.
5959
body: Builder(builder: (BuildContext context) {
6060
return WebView(
61-
initialUrl: 'http://www.naver.com',
61+
initialUrl: 'https://www.apache.org/licenses/LICENSE-2.0.txt',
6262
javascriptMode: JavascriptMode.unrestricted,
6363
onWebViewCreated: (WebViewController webViewController) {
6464
_controller.complete(webViewController);

packages/webview_flutter/tizen/inc/lwe/LWEWebView.h

+14
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ class LWE_EXPORT WebContainer {
158158
onGLSwapBuffers,
159159
float devicePixelRatio, const char* defaultFontName, const char* locale,
160160
const char* timezoneID);
161+
162+
struct ExternalImageInfo {
163+
void* imageAddress;
164+
};
165+
166+
static WebContainer* CreateGLWithPlatformImage(
167+
unsigned width, unsigned height,
168+
const std::function<void(WebContainer*)>& onGLMakeCurrent,
169+
const std::function<void(WebContainer*, bool mayNeedsSync)>&
170+
onGLSwapBuffers,
171+
const std::function<ExternalImageInfo(void)>& prepareImageCb,
172+
const std::function<void(WebContainer*)>& renderedCb,
173+
float devicePixelRatio, const char* defaultFontName, const char* locale,
174+
const char* timezoneID);
161175
// <--- end of function set for render with OpenGL
162176

163177
// Function set for headless
Binary file not shown.
Binary file not shown.

packages/webview_flutter/tizen/project_def.prop

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ USER_CPP_UNDEFS =
1616

1717
# Compiler/linker flags
1818
USER_CFLAGS_MISC =
19-
USER_CPPFLAGS_MISC = -c -fmessage-length=0
20-
USER_LFLAGS = -llightweight-web-engine
19+
USER_CPPFLAGS_MISC = -c -fmessage-length=0
20+
USER_LFLAGS = -llightweight-web-engine.mobile -Wl,-rpath=/opt/usr/globalapps/org.tizen.webview_flutter_tizen_example/lib/arm
2121

2222
# Libraries and objects
2323
USER_LIB_DIRS = lib
24-
USER_LIBS = lightweight-web-engine
24+
USER_LIBS = lightweight-web-engine.mobile
2525
USER_OBJS =
2626

2727
# User includes

packages/webview_flutter/tizen/src/webview.cc

+14-11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
#include <Ecore_Input_Evas.h>
2222
#include <Ecore_IMF_Evas.h>
2323

24+
25+
#define LWE_EXPORT
26+
extern "C" size_t LWE_EXPORT createWebViewInstance(
27+
unsigned x, unsigned y, unsigned width, unsigned height,
28+
float devicePixelRatio, const char* defaultFontName, const char* locale,
29+
const char* timezoneID,
30+
const std::function<::LWE::WebContainer::ExternalImageInfo(void)>&
31+
prepareImageCb,
32+
const std::function<void(::LWE::WebContainer*)>& renderedCb);
33+
2434
std::string ExtractStringFromMap(const flutter::EncodableValue& arguments,
2535
const char* key) {
2636
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
@@ -438,23 +448,16 @@ void WebView::InitWebView() {
438448
}
439449
float scaleFactor = 1;
440450

441-
LWE::WebView* webview = LWE::WebView::Create(nullptr,0,0,width_, height_,scaleFactor, "SamsungOneUI", "ko-KR", "Asia/Seoul");
442-
webViewInstance_ = webview->FetchWebContainer();
443-
webViewInstance_->RegisterPreRenderingHandler(
444-
[this]() -> LWE::WebContainer::RenderInfo {
445-
LWE::WebContainer::RenderInfo result;
451+
webViewInstance_ = (LWE::WebContainer*)createWebViewInstance(0,0,width_, height_,scaleFactor, "SamsungOneUI", "ko-KR", "Asia/Seoul",[this]() -> LWE::WebContainer::ExternalImageInfo {
452+
LWE::WebContainer::ExternalImageInfo result;
446453
tbmSurface_ = tbm_surface_create(width_, height_, TBM_FORMAT_ARGB8888);
447454
tbm_surface_info_s tbmSurfaceInfo;
448455
if (tbm_surface_map(tbmSurface_, TBM_SURF_OPTION_WRITE,
449456
&tbmSurfaceInfo) == TBM_SURFACE_ERROR_NONE) {
450-
result.updatedBufferAddress = (void*)tbmSurface_;
451-
result.bufferStride = 0;
457+
result.imageAddress = (void*)tbmSurface_;
452458
}
453459
return result;
454-
});
455-
456-
webViewInstance_->RegisterOnRenderedHandler(
457-
[this](LWE::WebContainer* c, LWE::WebContainer::RenderResult r) {
460+
}, [this](LWE::WebContainer* c) {
458461
FlutterMarkExternalTextureFrameAvailable(textureRegistrar_,
459462
GetTextureId(), tbmSurface_);
460463
tbm_surface_destroy(tbmSurface_);

0 commit comments

Comments
 (0)