Skip to content

Commit 84f34de

Browse files
committed
Change types
1 parent 4ac706a commit 84f34de

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

packages/webview_flutter/tizen/src/buffer_pool.cc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
#include "log.h"
88

9-
BufferUnit::BufferUnit(int index, int width, int height) : index_(index) {
9+
BufferUnit::BufferUnit(size_t index, int32_t width, int32_t height)
10+
: index_(index) {
1011
Reset(width, height);
1112
}
1213

@@ -38,7 +39,7 @@ tbm_surface_h BufferUnit::Surface() {
3839
return nullptr;
3940
}
4041

41-
void BufferUnit::Reset(int width, int height) {
42+
void BufferUnit::Reset(int32_t width, int32_t height) {
4243
if (width_ == width && height_ == height) {
4344
return;
4445
}
@@ -66,9 +67,9 @@ void BufferUnit::Reset(int width, int height) {
6667
gpu_buffer_->release_context = this;
6768
}
6869

69-
BufferPool::BufferPool(int width, int height, int pool_size) : last_index_(0) {
70-
for (int idx = 0; idx < pool_size; idx++) {
71-
pool_.emplace_back(new BufferUnit(idx, width, height));
70+
BufferPool::BufferPool(int32_t width, int32_t height, size_t pool_size) {
71+
for (size_t index = 0; index < pool_size; index++) {
72+
pool_.emplace_back(std::make_unique<BufferUnit>(index, width, height));
7273
}
7374
Prepare(width, height);
7475
}
@@ -77,8 +78,8 @@ BufferPool::~BufferPool() {}
7778

7879
BufferUnit* BufferPool::GetAvailableBuffer() {
7980
std::lock_guard<std::mutex> lock(mutex_);
80-
for (int idx = 0; idx < pool_.size(); idx++) {
81-
int current = (idx + last_index_) % pool_.size();
81+
for (size_t index = 0; index < pool_.size(); index++) {
82+
size_t current = (index + last_index_) % pool_.size();
8283
BufferUnit* buffer = pool_[current].get();
8384
if (buffer->MarkInUse()) {
8485
last_index_ = current;
@@ -93,15 +94,15 @@ void BufferPool::Release(BufferUnit* buffer) {
9394
buffer->UnmarkInUse();
9495
}
9596

96-
void BufferPool::Prepare(int width, int height) {
97+
void BufferPool::Prepare(int32_t width, int32_t height) {
9798
std::lock_guard<std::mutex> lock(mutex_);
98-
for (int idx = 0; idx < pool_.size(); idx++) {
99-
BufferUnit* buffer = pool_[idx].get();
99+
for (size_t index = 0; index < pool_.size(); index++) {
100+
BufferUnit* buffer = pool_[index].get();
100101
buffer->Reset(width, height);
101102
}
102103
}
103104

104-
SingleBufferPool::SingleBufferPool(int width, int height)
105+
SingleBufferPool::SingleBufferPool(int32_t width, int32_t height)
105106
: BufferPool(width, height, 1) {}
106107

107108
SingleBufferPool::~SingleBufferPool() {}

packages/webview_flutter/tizen/src/buffer_pool.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
class BufferUnit {
1616
public:
17-
explicit BufferUnit(int index, int width, int height);
17+
explicit BufferUnit(size_t index, int32_t width, int32_t height);
1818
~BufferUnit();
1919

20-
void Reset(int width, int height);
20+
void Reset(int32_t width, int32_t height);
2121

2222
bool MarkInUse();
2323
void UnmarkInUse();
@@ -35,34 +35,34 @@ class BufferUnit {
3535

3636
private:
3737
bool is_used_ = false;
38-
int index_;
39-
int width_ = 0;
40-
int height_ = 0;
38+
size_t index_;
39+
int32_t width_ = 0;
40+
int32_t height_ = 0;
4141
tbm_surface_h tbm_surface_ = nullptr;
4242
FlutterDesktopGpuBuffer* gpu_buffer_ = nullptr;
4343
};
4444

4545
class BufferPool {
4646
public:
47-
explicit BufferPool(int width, int height, int pool_size);
47+
explicit BufferPool(int32_t width, int32_t height, size_t pool_size);
4848
virtual ~BufferPool();
4949

5050
virtual BufferUnit* GetAvailableBuffer();
5151
virtual void Release(BufferUnit* buffer);
5252

53-
void Prepare(int with, int height);
53+
void Prepare(int32_t with, int32_t height);
5454

5555
protected:
5656
std::vector<std::unique_ptr<BufferUnit>> pool_;
5757

5858
private:
59-
int last_index_;
59+
size_t last_index_ = 0;
6060
std::mutex mutex_;
6161
};
6262

6363
class SingleBufferPool : public BufferPool {
6464
public:
65-
explicit SingleBufferPool(int width, int height);
65+
explicit SingleBufferPool(int32_t width, int32_t height);
6666
~SingleBufferPool();
6767

6868
virtual BufferUnit* GetAvailableBuffer() override;

0 commit comments

Comments
 (0)