| Index: chrome/browser/android/thumbnail/thumbnail_store.cc
|
| diff --git a/chrome/browser/android/thumbnail/thumbnail_store.cc b/chrome/browser/android/thumbnail/thumbnail_store.cc
|
| index 52d92059275cf0530bf13f859855bb543ea756be..3f22a3e94a3abb31072889d644f36b0233450271 100644
|
| --- a/chrome/browser/android/thumbnail/thumbnail_store.cc
|
| +++ b/chrome/browser/android/thumbnail/thumbnail_store.cc
|
| @@ -38,8 +38,6 @@ const int kCurrentExtraVersion = 1;
|
| // Indicates whether we prefer to have more free CPU memory over GPU memory.
|
| const bool kPreferCPUMemory = true;
|
|
|
| -// TODO(): ETC1 texture sizes should be multiples of four, but some drivers only
|
| -// allow power-of-two ETC1 textures. Find better work around.
|
| size_t NextPowerOfTwo(size_t x) {
|
| --x;
|
| x |= x >> 1;
|
| @@ -50,10 +48,18 @@ size_t NextPowerOfTwo(size_t x) {
|
| return x + 1;
|
| }
|
|
|
| -gfx::Size GetEncodedSize(const gfx::Size& bitmap_size) {
|
| +size_t RoundUpMod4(size_t x) {
|
| + return (x + 3) & ~3;
|
| +}
|
| +
|
| +gfx::Size GetEncodedSize(const gfx::Size& bitmap_size, bool supports_npot) {
|
| DCHECK(!bitmap_size.IsEmpty());
|
| - return gfx::Size(NextPowerOfTwo(bitmap_size.width()),
|
| - NextPowerOfTwo(bitmap_size.height()));
|
| + if (!supports_npot)
|
| + return gfx::Size(NextPowerOfTwo(bitmap_size.width()),
|
| + NextPowerOfTwo(bitmap_size.height()));
|
| + else
|
| + return gfx::Size(RoundUpMod4(bitmap_size.width()),
|
| + RoundUpMod4(bitmap_size.height()));
|
| }
|
|
|
| template<typename T>
|
| @@ -365,11 +371,16 @@ void ThumbnailStore::CompressThumbnailIfNecessary(
|
| time_stamp,
|
| scale);
|
|
|
| - base::WorkerPool::PostTask(
|
| - FROM_HERE,
|
| - base::Bind(
|
| - &ThumbnailStore::CompressionTask, bitmap, post_compression_task),
|
| - true);
|
| + gfx::Size raw_data_size(bitmap.width(), bitmap.height());
|
| + gfx::Size encoded_size = GetEncodedSize(
|
| + raw_data_size, ui_resource_provider_->SupportsETC1NonPowerOfTwo());
|
| +
|
| + base::WorkerPool::PostTask(FROM_HERE,
|
| + base::Bind(&ThumbnailStore::CompressionTask,
|
| + bitmap,
|
| + encoded_size,
|
| + post_compression_task),
|
| + true);
|
| }
|
|
|
| void ThumbnailStore::ReadNextThumbnail() {
|
| @@ -539,6 +550,7 @@ void ThumbnailStore::PostWriteTask() {
|
|
|
| void ThumbnailStore::CompressionTask(
|
| SkBitmap raw_data,
|
| + gfx::Size encoded_size,
|
| const base::Callback<void(skia::RefPtr<SkPixelRef>, const gfx::Size&)>&
|
| post_compression_task) {
|
| skia::RefPtr<SkPixelRef> compressed_data;
|
| @@ -550,7 +562,6 @@ void ThumbnailStore::CompressionTask(
|
| size_t pixel_size = 4; // Pixel size is 4 bytes for kARGB_8888_Config.
|
| size_t stride = pixel_size * raw_data_size.width();
|
|
|
| - gfx::Size encoded_size = GetEncodedSize(raw_data_size);
|
| size_t encoded_bytes =
|
| etc1_get_encoded_data_size(encoded_size.width(), encoded_size.height());
|
| SkImageInfo info = {encoded_size.width(),
|
|
|