Skip to content

[webview_flutter_dev] Change webview interface && embedding lwe.so file #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webview_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some routine to calculate the scale factor on the engine side, Should it be shared by the engine?
This is just my curiosity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess.. we should use engine's value. we need to modify platform view's interface for that.


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