| 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/resources/raster_worker_pool.h" | 5 #include "cc/resources/raster_worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 InsertNodeForTask(graph, raster_task, priority, dependencies); | 194 InsertNodeForTask(graph, raster_task, priority, dependencies); |
| 195 } | 195 } |
| 196 | 196 |
| 197 // static | 197 // static |
| 198 void RasterWorkerPool::PlaybackToMemory(void* memory, | 198 void RasterWorkerPool::PlaybackToMemory(void* memory, |
| 199 ResourceFormat format, | 199 ResourceFormat format, |
| 200 const gfx::Size& size, | 200 const gfx::Size& size, |
| 201 int stride, | 201 int stride, |
| 202 const RasterSource* raster_source, | 202 const RasterSource* raster_source, |
| 203 const gfx::Rect& rect, | 203 const gfx::Rect& rect, |
| 204 float scale, | 204 float scale) { |
| 205 RenderingStatsInstrumentation* stats) { | |
| 206 SkBitmap bitmap; | 205 SkBitmap bitmap; |
| 207 switch (format) { | 206 switch (format) { |
| 208 case RGBA_4444: | 207 case RGBA_4444: |
| 209 bitmap.allocN32Pixels(size.width(), size.height()); | 208 bitmap.allocN32Pixels(size.width(), size.height()); |
| 210 break; | 209 break; |
| 211 case RGBA_8888: | 210 case RGBA_8888: |
| 212 case BGRA_8888: { | 211 case BGRA_8888: { |
| 213 SkImageInfo info = | 212 SkImageInfo info = |
| 214 SkImageInfo::MakeN32Premul(size.width(), size.height()); | 213 SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 215 if (!stride) | 214 if (!stride) |
| 216 stride = info.minRowBytes(); | 215 stride = info.minRowBytes(); |
| 217 bitmap.installPixels(info, memory, stride); | 216 bitmap.installPixels(info, memory, stride); |
| 218 break; | 217 break; |
| 219 } | 218 } |
| 220 case ALPHA_8: | 219 case ALPHA_8: |
| 221 case LUMINANCE_8: | 220 case LUMINANCE_8: |
| 222 case RGB_565: | 221 case RGB_565: |
| 223 case ETC1: | 222 case ETC1: |
| 224 NOTREACHED(); | 223 NOTREACHED(); |
| 225 break; | 224 break; |
| 226 } | 225 } |
| 227 | 226 |
| 228 SkCanvas canvas(bitmap); | 227 SkCanvas canvas(bitmap); |
| 229 raster_source->PlaybackToCanvas(&canvas, rect, scale, stats); | 228 raster_source->PlaybackToCanvas(&canvas, rect, scale); |
| 230 | 229 |
| 231 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); | 230 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); |
| 232 if (buffer_color_type != bitmap.colorType()) { | 231 if (buffer_color_type != bitmap.colorType()) { |
| 233 SkImageInfo dst_info = bitmap.info(); | 232 SkImageInfo dst_info = bitmap.info(); |
| 234 dst_info.fColorType = buffer_color_type; | 233 dst_info.fColorType = buffer_color_type; |
| 235 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the | 234 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| 236 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 | 235 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 |
| 237 // is fixed. | 236 // is fixed. |
| 238 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); | 237 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); |
| 239 DCHECK_EQ(0u, dst_row_bytes % 4); | 238 DCHECK_EQ(0u, dst_row_bytes % 4); |
| 240 bool success = bitmap.readPixels(dst_info, memory, dst_row_bytes, 0, 0); | 239 bool success = bitmap.readPixels(dst_info, memory, dst_row_bytes, 0, 0); |
| 241 DCHECK_EQ(true, success); | 240 DCHECK_EQ(true, success); |
| 242 } | 241 } |
| 243 } | 242 } |
| 244 | 243 |
| 245 } // namespace cc | 244 } // namespace cc |
| OLD | NEW |