Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/raster/tile_task_worker_pool.h" | 5 #include "cc/raster/tile_task_worker_pool.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/playback/raster_source.h" | 10 #include "cc/playback/raster_source.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); | 85 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (!stride) | 88 if (!stride) |
| 89 stride = info.minRowBytes(); | 89 stride = info.minRowBytes(); |
| 90 DCHECK_GT(stride, 0u); | 90 DCHECK_GT(stride, 0u); |
| 91 | 91 |
| 92 switch (format) { | 92 switch (format) { |
| 93 case RGBA_8888: | 93 case RGBA_8888: |
| 94 case BGRA_8888: { | 94 case BGRA_8888: { |
| 95 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | 95 sk_sp<SkSurface> surface = |
| 96 SkSurface::NewRasterDirect(info, memory, stride, &surface_props)); | 96 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); |
| 97 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, | 97 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, |
| 98 canvas_playback_rect, scale, | 98 canvas_playback_rect, scale, |
| 99 playback_settings); | 99 playback_settings); |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 case RGBA_4444: | 102 case RGBA_4444: |
| 103 case ETC1: { | 103 case ETC1: { |
| 104 skia::RefPtr<SkSurface> surface = | 104 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); |
| 105 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props)); | |
| 106 // TODO(reveman): Improve partial raster support by reducing the size of | 105 // TODO(reveman): Improve partial raster support by reducing the size of |
| 107 // playback rect passed to PlaybackToCanvas. crbug.com/519070 | 106 // playback rect passed to PlaybackToCanvas. crbug.com/519070 |
| 108 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, | 107 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, |
| 109 canvas_bitmap_rect, scale, | 108 canvas_bitmap_rect, scale, |
| 110 playback_settings); | 109 playback_settings); |
| 111 | 110 |
| 112 if (format == ETC1) { | 111 if (format == ETC1) { |
| 113 TRACE_EVENT0("cc", | 112 TRACE_EVENT0("cc", |
| 114 "TileTaskWorkerPool::PlaybackToMemory::CompressETC1"); | 113 "TileTaskWorkerPool::PlaybackToMemory::CompressETC1"); |
| 115 DCHECK_EQ(size.width() % 4, 0); | 114 DCHECK_EQ(size.width() % 4, 0); |
| 116 DCHECK_EQ(size.height() % 4, 0); | 115 DCHECK_EQ(size.height() % 4, 0); |
| 117 scoped_ptr<TextureCompressor> texture_compressor = | 116 scoped_ptr<TextureCompressor> texture_compressor = |
| 118 TextureCompressor::Create(TextureCompressor::kFormatETC1); | 117 TextureCompressor::Create(TextureCompressor::kFormatETC1); |
| 119 texture_compressor->Compress(reinterpret_cast<const uint8_t*>( | 118 texture_compressor->Compress(reinterpret_cast<const uint8_t*>( |
| 120 surface->peekPixels(nullptr, nullptr)), | 119 surface->peekPixels(nullptr, nullptr)), |
| 121 reinterpret_cast<uint8_t*>(memory), | 120 reinterpret_cast<uint8_t*>(memory), |
| 122 size.width(), size.height(), | 121 size.width(), size.height(), |
| 123 TextureCompressor::kQualityHigh); | 122 TextureCompressor::kQualityHigh); |
| 124 } else { | 123 } else { |
| 125 TRACE_EVENT0("cc", | 124 TRACE_EVENT0("cc", |
| 126 "TileTaskWorkerPool::PlaybackToMemory::ConvertRGBA4444"); | 125 "TileTaskWorkerPool::PlaybackToMemory::ConvertRGBA4444"); |
| 127 SkImageInfo dst_info = SkImageInfo::Make( | 126 SkImageInfo dst_info = SkImageInfo::Make( |
| 128 info.width(), info.height(), ResourceFormatToSkColorType(format), | 127 info.width(), info.height(), ResourceFormatToSkColorType(format), |
| 129 info.alphaType(), info.profileType()); | 128 info.alphaType(), info.profileType()); |
| 130 bool rv = | 129 bool rv = |
| 131 surface->getCanvas()->readPixels(dst_info, memory, stride, 0, 0); | 130 surface->getCanvas()->readPixels(dst_info, memory, stride, 0, 0); |
|
reed1
2016/04/05 14:06:17
nit: could change to surface->readPixels() // but
tomhudson
2016/04/05 14:52:50
Done.
| |
| 132 DCHECK(rv); | 131 DCHECK(rv); |
| 133 } | 132 } |
| 134 return; | 133 return; |
| 135 } | 134 } |
| 136 case ALPHA_8: | 135 case ALPHA_8: |
| 137 case LUMINANCE_8: | 136 case LUMINANCE_8: |
| 138 case RGB_565: | 137 case RGB_565: |
| 139 case RED_8: | 138 case RED_8: |
| 140 case LUMINANCE_F16: | 139 case LUMINANCE_F16: |
| 141 NOTREACHED(); | 140 NOTREACHED(); |
| 142 return; | 141 return; |
| 143 } | 142 } |
| 144 | 143 |
| 145 NOTREACHED(); | 144 NOTREACHED(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 } // namespace cc | 147 } // namespace cc |
| OLD | NEW |