Skip to content

Commit

Permalink
[webview_flutter] Optimize tbm allocation
Browse files Browse the repository at this point in the history
Signed-off-by: MuHong Byun <[email protected]>
  • Loading branch information
bwikbs committed Feb 23, 2021
1 parent c5a8930 commit 99bc284
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/webview_flutter/tizen/src/webview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
height_(height),
tbmSurface_(nullptr),
isMouseLButtonDown_(false),
hasNavigationDelegate_(false) {
hasNavigationDelegate_(false),
needTbmAllocate_(true) {
SetTextureId(FlutterRegisterExternalTexture(textureRegistrar_));
InitWebView();

Expand Down Expand Up @@ -719,17 +720,22 @@ void WebView::InitWebView() {
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);
if (needTbmAllocate_) {
tbmSurface_ =
tbm_surface_create(width_, height_, TBM_FORMAT_ARGB8888);
needTbmAllocate_ = false;
}
result.imageAddress = (void*)tbmSurface_;
return result;
},
[this](LWE::WebContainer* c, bool isRendered) {
if (isRendered) {
FlutterMarkExternalTextureFrameAvailable(textureRegistrar_,
GetTextureId(), tbmSurface_);
tbm_surface_destroy(tbmSurface_);
tbmSurface_ = nullptr;
needTbmAllocate_ = true;
}
tbm_surface_destroy(tbmSurface_);
tbmSurface_ = nullptr;
});
#ifndef TV_PROFILE
auto settings = webViewInstance_->GetSettings();
Expand Down
1 change: 1 addition & 0 deletions packages/webview_flutter/tizen/src/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class WebView : public PlatformView {
bool isMouseLButtonDown_;
bool hasNavigationDelegate_;
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> channel_;
bool needTbmAllocate_;
};

#endif // FLUTTER_PLUGIN_WEBVIEW_FLUTTER_TIZEN_WEVIEW_H_

0 comments on commit 99bc284

Please sign in to comment.