| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 InsertNodeForTask(graph, decode_task, priority, 0u); | 189 InsertNodeForTask(graph, decode_task, priority, 0u); |
| 190 | 190 |
| 191 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); | 191 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); |
| 192 } | 192 } |
| 193 | 193 |
| 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::AcquireBitmapForBuffer(SkBitmap* bitmap, | 198 void RasterWorkerPool::AcquireBitmapForBuffer(SkBitmap* bitmap, |
| 199 uint8_t* buffer, | 199 void* buffer, |
| 200 ResourceFormat buffer_format, | 200 ResourceFormat buffer_format, |
| 201 const gfx::Size& size, | 201 const gfx::Size& size, |
| 202 int stride) { | 202 int stride) { |
| 203 switch (buffer_format) { | 203 switch (buffer_format) { |
| 204 case RGBA_4444: | 204 case RGBA_4444: |
| 205 bitmap->allocN32Pixels(size.width(), size.height()); | 205 bitmap->allocN32Pixels(size.width(), size.height()); |
| 206 break; | 206 break; |
| 207 case RGBA_8888: | 207 case RGBA_8888: |
| 208 case BGRA_8888: { | 208 case BGRA_8888: { |
| 209 SkImageInfo info = | 209 SkImageInfo info = |
| 210 SkImageInfo::MakeN32Premul(size.width(), size.height()); | 210 SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 211 if (!stride) | 211 if (!stride) |
| 212 stride = info.minRowBytes(); | 212 stride = info.minRowBytes(); |
| 213 bitmap->installPixels(info, buffer, stride); | 213 bitmap->installPixels(info, buffer, stride); |
| 214 break; | 214 break; |
| 215 } | 215 } |
| 216 case ALPHA_8: | 216 case ALPHA_8: |
| 217 case LUMINANCE_8: | 217 case LUMINANCE_8: |
| 218 case RGB_565: | 218 case RGB_565: |
| 219 case ETC1: | 219 case ETC1: |
| 220 NOTREACHED(); | 220 NOTREACHED(); |
| 221 break; | 221 break; |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 // static | 225 // static |
| 226 void RasterWorkerPool::ReleaseBitmapForBuffer(SkBitmap* bitmap, | 226 void RasterWorkerPool::ReleaseBitmapForBuffer(SkBitmap* bitmap, |
| 227 uint8_t* buffer, | 227 void* buffer, |
| 228 ResourceFormat buffer_format) { | 228 ResourceFormat buffer_format) { |
| 229 SkColorType buffer_color_type = ResourceFormatToSkColorType(buffer_format); | 229 SkColorType buffer_color_type = ResourceFormatToSkColorType(buffer_format); |
| 230 if (buffer_color_type != bitmap->colorType()) { | 230 if (buffer_color_type != bitmap->colorType()) { |
| 231 SkImageInfo dst_info = bitmap->info(); | 231 SkImageInfo dst_info = bitmap->info(); |
| 232 dst_info.fColorType = buffer_color_type; | 232 dst_info.fColorType = buffer_color_type; |
| 233 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the | 233 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| 234 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 | 234 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 |
| 235 // is fixed. | 235 // is fixed. |
| 236 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); | 236 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); |
| 237 DCHECK_EQ(0u, dst_row_bytes % 4); | 237 DCHECK_EQ(0u, dst_row_bytes % 4); |
| 238 bool success = bitmap->readPixels(dst_info, buffer, dst_row_bytes, 0, 0); | 238 bool success = bitmap->readPixels(dst_info, buffer, dst_row_bytes, 0, 0); |
| 239 DCHECK_EQ(true, success); | 239 DCHECK_EQ(true, success); |
| 240 } | 240 } |
| 241 bitmap->reset(); | 241 bitmap->reset(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace cc | 244 } // namespace cc |
| OLD | NEW |