-
Notifications
You must be signed in to change notification settings - Fork 52
[webview_flutter] Update minor things #118
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-3.91 MB
(73%)
packages/webview_flutter/tizen/lib/aarch64/liblightweight-web-engine.flutter.so
Binary file not shown.
Binary file modified
BIN
-560 KB
(92%)
packages/webview_flutter/tizen/lib/armel/liblightweight-web-engine.flutter.so
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "buffer_pool.h" | ||
|
|
||
| #include "log.h" | ||
|
|
||
| #define BUFFER_POOL_SIZE 5 | ||
|
|
||
| BufferUnit::BufferUnit(int index, int width, int height) | ||
| : isUsed_(false), | ||
| index_(index), | ||
| width_(0), | ||
| height_(0), | ||
| tbm_surface_(nullptr) { | ||
| Reset(width, height); | ||
| } | ||
|
|
||
| BufferUnit::~BufferUnit() { | ||
| if (tbm_surface_) { | ||
| tbm_surface_destroy(tbm_surface_); | ||
| tbm_surface_ = nullptr; | ||
| } | ||
| } | ||
|
|
||
| bool BufferUnit::MarkInUse() { | ||
| if (!isUsed_) { | ||
| isUsed_ = true; | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| int BufferUnit::Index() { return index_; } | ||
|
|
||
| bool BufferUnit::IsUsed() { return isUsed_ && tbm_surface_; } | ||
|
|
||
| tbm_surface_h BufferUnit::Surface() { | ||
| if (IsUsed()) { | ||
| return tbm_surface_; | ||
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| void BufferUnit::UnmarkInUse() { isUsed_ = false; } | ||
|
|
||
| void BufferUnit::Reset(int width, int height) { | ||
| if (width_ == width && height_ == height) { | ||
| return; | ||
| } | ||
| width_ = width; | ||
| height_ = height; | ||
| if (tbm_surface_) { | ||
| tbm_surface_destroy(tbm_surface_); | ||
| tbm_surface_ = nullptr; | ||
| } | ||
| tbm_surface_ = tbm_surface_create(width_, height_, TBM_FORMAT_ARGB8888); | ||
bbrto21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| BufferPool::BufferPool(int width, int height) { | ||
| for (int idx = 0; idx < BUFFER_POOL_SIZE; idx++) { | ||
| pool_.emplace_back(new BufferUnit(idx, width, height)); | ||
| } | ||
| Prepare(width, height); | ||
| } | ||
|
|
||
| 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++) { | ||
| BufferUnit* buffer = pool_[idx].get(); | ||
| if (buffer->MarkInUse()) { | ||
| return buffer; | ||
| } | ||
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| void BufferPool::Release(BufferUnit* unit) { | ||
| std::lock_guard<std::mutex> lock(mutex_); | ||
| unit->UnmarkInUse(); | ||
| } | ||
|
|
||
| void BufferPool::Prepare(int width, int height) { | ||
| std::lock_guard<std::mutex> lock(mutex_); | ||
| for (int idx = 0; idx < pool_.size(); idx++) { | ||
| BufferUnit* buffer = pool_[idx].get(); | ||
| buffer->Reset(width, height); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_PLUGIN_WEBVIEW_FLUTTER_TIZEN_WEBVIEW_BUFFER_POOL_H_ | ||
| #define FLUTTER_PLUGIN_WEBVIEW_FLUTTER_TIZEN_WEBVIEW_BUFFER_POOL_H_ | ||
|
|
||
| #include <tbm_surface.h> | ||
|
|
||
| #include <memory> | ||
| #include <mutex> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| class BufferUnit { | ||
| public: | ||
| explicit BufferUnit(int index, int width, int height); | ||
| ~BufferUnit(); | ||
| void Reset(int width, int height); | ||
| bool MarkInUse(); | ||
| void UnmarkInUse(); | ||
| int Index(); | ||
| bool IsUsed(); | ||
| tbm_surface_h Surface(); | ||
|
|
||
| private: | ||
| bool isUsed_; | ||
| int index_; | ||
| int width_; | ||
| int height_; | ||
| tbm_surface_h tbm_surface_; | ||
| }; | ||
|
|
||
| class BufferPool { | ||
| public: | ||
| explicit BufferPool(int width, int height); | ||
| ~BufferPool(); | ||
|
|
||
| BufferUnit* GetAvailableBuffer(); | ||
| BufferUnit* Find(tbm_surface_h surface); | ||
| void Release(BufferUnit* unit); | ||
| void Prepare(int with, int height); | ||
|
|
||
| private: | ||
| std::mutex mutex_; | ||
| std::vector<std::unique_ptr<BufferUnit>> pool_; | ||
| }; | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.