Chromium Code Reviews| Index: cc/raster/tile_task_worker_pool.cc |
| diff --git a/cc/raster/tile_task_worker_pool.cc b/cc/raster/tile_task_worker_pool.cc |
| index d349514c4e84ceba7d91cbf997c7e5c320cc2c84..0a2b18f31da4ffaaaf1cc0b9038209f3124f5b54 100644 |
| --- a/cc/raster/tile_task_worker_pool.cc |
| +++ b/cc/raster/tile_task_worker_pool.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/trace_event/trace_event.h" |
| #include "cc/playback/raster_source.h" |
| +#include "cc/raster/texture_compressor.h" |
| #include "skia/ext/refptr.h" |
| #include "third_party/skia/include/core/SkCanvas.h" |
| #include "third_party/skia/include/core/SkSurface.h" |
| @@ -141,11 +142,11 @@ static bool IsSupportedPlaybackToMemoryFormat(ResourceFormat format) { |
| case RGBA_4444: |
| case RGBA_8888: |
| case BGRA_8888: |
| + case ETC1: |
| return true; |
| case ALPHA_8: |
| case LUMINANCE_8: |
| case RGB_565: |
| - case ETC1: |
| case RED_8: |
| return false; |
| } |
| @@ -167,8 +168,8 @@ void TileTaskWorkerPool::PlaybackToMemory(void* memory, |
| // Uses kPremul_SkAlphaType since the result is not known to be opaque. |
| SkImageInfo info = |
| SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); |
| - SkColorType buffer_color_type = ResourceFormatToSkColorType(format); |
| - bool needs_copy = buffer_color_type != info.colorType(); |
| + bool needs_copy = IsResourceFormatCompressed(format) || |
|
reveman
2015/07/21 04:26:33
nit: s/needs_copy/needs_conversion/
The only form
|
| + ResourceFormatToSkColorType(format) != info.colorType(); |
| // Use unknown pixel geometry to disable LCD text. |
| SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); |
| @@ -196,16 +197,30 @@ void TileTaskWorkerPool::PlaybackToMemory(void* memory, |
| raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect, |
| canvas_playback_rect, scale); |
| - SkImageInfo dst_info = |
| - SkImageInfo::Make(info.width(), info.height(), buffer_color_type, |
| - info.alphaType(), info.profileType()); |
| - // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| - // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 |
| - // is fixed. |
| - const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); |
| - DCHECK_EQ(0u, dst_row_bytes % 4); |
| - bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); |
| - DCHECK_EQ(true, success); |
| + scoped_ptr<TextureCompressor> texture_compressor; |
| + switch (format) { |
| + case ETC1: |
| + texture_compressor = |
| + TextureCompressor::Create(TextureCompressor::kFormatETC1); |
|
reveman
2015/07/21 04:26:33
hm, I think we should assume that creating a textu
|
| + break; |
| + default: |
|
reveman
2015/07/21 04:26:33
Please explicitly list all formats here and add a
|
| + SkImageInfo dst_info = SkImageInfo::Make( |
| + info.width(), info.height(), ResourceFormatToSkColorType(format), |
| + info.alphaType(), info.profileType()); |
| + // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| + // bitmap data. There will be no need to call SkAlign4 once |
| + // crbug.com/293728 is fixed. |
| + const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); |
| + DCHECK_EQ(0u, dst_row_bytes % 4); |
| + bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); |
| + DCHECK_EQ(true, success); |
| + return; |
| + } |
| + |
| + texture_compressor->Compress( |
| + reinterpret_cast<const uint8_t*>(surface->peekPixels(nullptr, nullptr)), |
| + reinterpret_cast<uint8_t*>(memory), size.width(), size.height(), |
| + TextureCompressor::kQualityHigh); |
| } |
| } // namespace cc |