Skip to content

Commit

Permalink
[webview_flutter_dev] Change webview interface && embedding lwe.so fi…
Browse files Browse the repository at this point in the history
…le (#15)

* temporal soluation

Signed-off-by: MuHong Byun <mh.byun@samsung.com>
  • Loading branch information
bwikbs committed Jan 27, 2021
1 parent 3413964 commit 571fa4a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/webview_flutter/example/lib/main.dart
Expand Up @@ -58,7 +58,7 @@ class _WebViewExampleState extends State<WebViewExample> {
// to allow calling Scaffold.of(context) so we can show a snackbar.
body: Builder(builder: (BuildContext context) {
return WebView(
initialUrl: 'http://www.naver.com',
initialUrl: 'https://www.apache.org/licenses/LICENSE-2.0.txt',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
Expand Down
Binary file not shown.
14 changes: 14 additions & 0 deletions packages/webview_flutter/tizen/inc/lwe/LWEWebView.h
Expand Up @@ -158,6 +158,20 @@ class LWE_EXPORT WebContainer {
onGLSwapBuffers,
float devicePixelRatio, const char* defaultFontName, const char* locale,
const char* timezoneID);

struct ExternalImageInfo {
void* imageAddress;
};

static WebContainer* CreateGLWithPlatformImage(
unsigned width, unsigned height,
const std::function<void(WebContainer*)>& onGLMakeCurrent,
const std::function<void(WebContainer*, bool mayNeedsSync)>&
onGLSwapBuffers,
const std::function<ExternalImageInfo(void)>& prepareImageCb,
const std::function<void(WebContainer*)>& renderedCb,
float devicePixelRatio, const char* defaultFontName, const char* locale,
const char* timezoneID);
// <--- end of function set for render with OpenGL

// Function set for headless
Expand Down
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions packages/webview_flutter/tizen/project_def.prop
Expand Up @@ -16,12 +16,12 @@ USER_CPP_UNDEFS =

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

# Libraries and objects
USER_LIB_DIRS = lib
USER_LIBS = lightweight-web-engine
USER_LIBS = lightweight-web-engine.mobile
USER_OBJS =

# User includes
Expand Down
25 changes: 14 additions & 11 deletions packages/webview_flutter/tizen/src/webview.cc
Expand Up @@ -21,6 +21,16 @@
#include <Ecore_Input_Evas.h>
#include <Ecore_IMF_Evas.h>


#define LWE_EXPORT
extern "C" size_t LWE_EXPORT createWebViewInstance(
unsigned x, unsigned y, unsigned width, unsigned height,
float devicePixelRatio, const char* defaultFontName, const char* locale,
const char* timezoneID,
const std::function<::LWE::WebContainer::ExternalImageInfo(void)>&
prepareImageCb,
const std::function<void(::LWE::WebContainer*)>& renderedCb);

std::string ExtractStringFromMap(const flutter::EncodableValue& arguments,
const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
Expand Down Expand Up @@ -438,23 +448,16 @@ void WebView::InitWebView() {
}
float scaleFactor = 1;

LWE::WebView* webview = LWE::WebView::Create(nullptr,0,0,width_, height_,scaleFactor, "SamsungOneUI", "ko-KR", "Asia/Seoul");
webViewInstance_ = webview->FetchWebContainer();
webViewInstance_->RegisterPreRenderingHandler(
[this]() -> LWE::WebContainer::RenderInfo {
LWE::WebContainer::RenderInfo result;
webViewInstance_ = (LWE::WebContainer*)createWebViewInstance(0,0,width_, height_,scaleFactor, "SamsungOneUI", "ko-KR", "Asia/Seoul",[this]() -> LWE::WebContainer::ExternalImageInfo {
LWE::WebContainer::ExternalImageInfo result;
tbmSurface_ = tbm_surface_create(width_, height_, TBM_FORMAT_ARGB8888);
tbm_surface_info_s tbmSurfaceInfo;
if (tbm_surface_map(tbmSurface_, TBM_SURF_OPTION_WRITE,
&tbmSurfaceInfo) == TBM_SURFACE_ERROR_NONE) {
result.updatedBufferAddress = (void*)tbmSurface_;
result.bufferStride = 0;
result.imageAddress = (void*)tbmSurface_;
}
return result;
});

webViewInstance_->RegisterOnRenderedHandler(
[this](LWE::WebContainer* c, LWE::WebContainer::RenderResult r) {
}, [this](LWE::WebContainer* c) {
FlutterMarkExternalTextureFrameAvailable(textureRegistrar_,
GetTextureId(), tbmSurface_);
tbm_surface_destroy(tbmSurface_);
Expand Down

0 comments on commit 571fa4a

Please sign in to comment.