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 b1d7b70a229377349362890f448ac2190c8a795a..cf44ed6150d8a837c1eef10a9e696143685df0d1 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/SkDrawFilter.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; |
| } |
| @@ -181,8 +182,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_conversion = |
|
reveman
2015/09/30 09:55:15
Can we instead include the non-conversion case in
christiank
2015/11/26 15:35:35
I can't think of an obvious way to do this. I stil
reveman
2015/11/27 16:46:49
fyi, I don't we ever convert from rgba to bgra in
|
| + SkColorTypeToResourceFormat(info.colorType()) != format; |
| // Use unknown pixel geometry to disable LCD text. |
| SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); |
| @@ -199,7 +200,7 @@ void TileTaskWorkerPool::PlaybackToMemory(void* memory, |
| if (!include_images) |
| image_filter = skia::AdoptRef(new SkipImageFilter); |
| - if (!needs_copy) { |
| + if (!needs_conversion) { |
| skia::RefPtr<SkSurface> surface = skia::AdoptRef( |
| SkSurface::NewRasterDirect(info, memory, stride, &surface_props)); |
| skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); |
| @@ -221,16 +222,40 @@ void TileTaskWorkerPool::PlaybackToMemory(void* memory, |
| { |
| TRACE_EVENT0("cc", "TileTaskWorkerPool::PlaybackToMemory::ConvertPixels"); |
| - 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; |
|
reveman
2015/09/30 09:55:15
nit: move to case where it's used
christiank
2015/11/26 15:35:35
Done.
|
| + switch (format) { |
| + case ETC1: |
| + texture_compressor = |
| + TextureCompressor::Create(TextureCompressor::kFormatETC1); |
|
christiank
2015/09/30 07:49:42
reveman (cited from 1197423003):
"hm, I think we s
reveman
2015/09/30 09:55:15
Creating it here each time is fine for now. Ideall
|
| + texture_compressor->Compress(reinterpret_cast<const uint8_t*>( |
| + surface->peekPixels(nullptr, nullptr)), |
| + reinterpret_cast<uint8_t*>(memory), |
| + size.width(), size.height(), |
| + TextureCompressor::kQualityHigh); |
| + return; |
| + case RGBA_8888: |
| + case RGBA_4444: |
| + case BGRA_8888: |
| + case ALPHA_8: |
| + case LUMINANCE_8: |
| + case RGB_565: |
| + case RED_8: |
| + 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; |
| + } |
| + |
| + NOTREACHED(); |
| } |
| } |