Skip to content
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
4 changes: 4 additions & 0 deletions packages/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.1

* Apply texture api change.

## 0.4.0

* Support emulator.
Expand Down
4 changes: 2 additions & 2 deletions packages/webview_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore

```yaml
dependencies:
webview_flutter: ^2.3.0
webview_flutter_tizen: ^0.3.11
webview_flutter: ^3.0.1
webview_flutter_tizen: ^0.4.1
```

## Example
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_tizen
description: Tizen implementation of the webview plugin
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/webview_flutter
version: 0.4.0
version: 0.4.1

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
19 changes: 6 additions & 13 deletions packages/webview_flutter/tizen/src/buffer_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ void BufferUnit::Reset(int width, int height) {
gpu_buffer_->width = width_;
gpu_buffer_->height = height_;
gpu_buffer_->buffer = tbm_surface_;
gpu_buffer_->release_callback = [](void* release_context) {
BufferUnit* bu = (BufferUnit*)release_context;
bu->UnmarkInUse();
};
gpu_buffer_->release_context = this;
}

BufferPool::BufferPool(int width, int height, int pool_size) : last_index_(0) {
Expand All @@ -80,16 +85,6 @@ BufferPool::BufferPool(int width, int height, int pool_size) : last_index_(0) {

BufferPool::~BufferPool() {}

BufferUnit* BufferPool::Find(tbm_surface_h surface) {
for (int idx = 0; idx < pool_.size(); idx++) {
BufferUnit* buffer = pool_[idx].get();
if (buffer->Surface() == surface) {
return buffer;
}
}
return nullptr;
}

BufferUnit* BufferPool::GetAvailableBuffer() {
std::lock_guard<std::mutex> lock(mutex_);
for (int idx = 0; idx < pool_.size(); idx++) {
Expand Down Expand Up @@ -126,9 +121,7 @@ BufferUnit* SingleBufferPool::GetAvailableBuffer() {
return pool_[0].get();
}

BufferUnit* SingleBufferPool::Find(tbm_surface_h surface) {
return pool_[0].get();
}
void SingleBufferPool::Release(BufferUnit* unit) {}

#ifndef NDEBUG
#include <cairo.h>
Expand Down
5 changes: 2 additions & 3 deletions packages/webview_flutter/tizen/src/buffer_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class BufferPool {
~BufferPool();

virtual BufferUnit* GetAvailableBuffer();
virtual BufferUnit* Find(tbm_surface_h surface);
void Release(BufferUnit* unit);
virtual void Release(BufferUnit* unit);
void Prepare(int with, int height);

protected:
Expand All @@ -60,7 +59,7 @@ class SingleBufferPool : public BufferPool {
~SingleBufferPool();

virtual BufferUnit* GetAvailableBuffer();
virtual BufferUnit* Find(tbm_surface_h surface);
virtual void Release(BufferUnit* unit);
};

#endif
16 changes: 2 additions & 14 deletions packages/webview_flutter/tizen/src/webview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
texture_variant_ = new flutter::TextureVariant(flutter::GpuBufferTexture(
[this](size_t width, size_t height) -> const FlutterDesktopGpuBuffer* {
return this->ObtainGpuBuffer(width, height);
},
[this](void* buffer) -> void { this->DestructBuffer(buffer); }));
}));
SetTextureId(texture_registrar_->RegisterTexture(texture_variant_));
InitWebView();

Expand Down Expand Up @@ -804,11 +803,10 @@ void WebView::InitWebView() {
if (candidate_surface_) {
tbm_pool_->Release(candidate_surface_);
candidate_surface_ = nullptr;
} else {
texture_registrar_->MarkTextureFrameAvailable(GetTextureId());
}
candidate_surface_ = working_surface_;
working_surface_ = nullptr;
texture_registrar_->MarkTextureFrameAvailable(GetTextureId());
}
},
use_sw_backend_);
Expand Down Expand Up @@ -1022,13 +1020,3 @@ FlutterDesktopGpuBuffer* WebView::ObtainGpuBuffer(size_t width, size_t height) {
candidate_surface_ = nullptr;
return rendered_surface_->GpuBuffer();
}

void WebView::DestructBuffer(void* buffer) {
if (buffer) {
std::lock_guard<std::mutex> lock(mutex_);
BufferUnit* unit = tbm_pool_->Find((tbm_surface_h)buffer);
if (unit && unit != rendered_surface_) {
tbm_pool_->Release(unit);
}
}
}
1 change: 0 additions & 1 deletion packages/webview_flutter/tizen/src/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class WebView : public PlatformView {
void ShowPanel();

FlutterDesktopGpuBuffer* ObtainGpuBuffer(size_t width, size_t height);
void DestructBuffer(void* buffer);

private:
void HandleMethodCall(
Expand Down