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