Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1150)

Side by Side Diff: cc/resources/raster_worker_pool.cc

Issue 562833004: cc: Move RasterBuffer implementations from ResourceProvider to RasterWorkerPool implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move NullCanvas change to separate patch Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 TaskGraph::Node::TaskComparator(decode_task)); 192 TaskGraph::Node::TaskComparator(decode_task));
193 if (decode_it == graph->nodes.end()) 193 if (decode_it == graph->nodes.end())
194 InsertNodeForTask(graph, decode_task, priority, 0u); 194 InsertNodeForTask(graph, decode_task, priority, 0u);
195 195
196 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); 196 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task));
197 } 197 }
198 198
199 InsertNodeForTask(graph, raster_task, priority, dependencies); 199 InsertNodeForTask(graph, raster_task, priority, dependencies);
200 } 200 }
201 201
202 // static
203 void RasterWorkerPool::AcquireBitmapForBuffer(SkBitmap* bitmap,
204 uint8_t* buffer,
205 ResourceFormat buffer_format,
206 const gfx::Size& size,
207 int stride) {
208 switch (buffer_format) {
209 case RGBA_4444:
210 bitmap->allocN32Pixels(size.width(), size.height());
211 break;
212 case RGBA_8888:
213 case BGRA_8888: {
214 SkImageInfo info =
215 SkImageInfo::MakeN32Premul(size.width(), size.height());
216 if (!stride)
217 stride = info.minRowBytes();
218 bitmap->installPixels(info, buffer, stride);
219 break;
220 }
221 case ALPHA_8:
222 case LUMINANCE_8:
223 case RGB_565:
224 case ETC1:
225 NOTREACHED();
226 break;
227 }
228 }
229
230 // static
231 void RasterWorkerPool::ReleaseBitmapForBuffer(SkBitmap* bitmap,
232 uint8_t* buffer,
233 ResourceFormat buffer_format) {
234 SkColorType buffer_color_type = ResourceFormatToSkColorType(buffer_format);
235 if (buffer_color_type != bitmap->colorType()) {
236 SkImageInfo dst_info = bitmap->info();
237 dst_info.fColorType = buffer_color_type;
238 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
239 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
240 // is fixed.
241 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
242 DCHECK_EQ(0u, dst_row_bytes % 4);
243 bool success = bitmap->readPixels(dst_info, buffer, dst_row_bytes, 0, 0);
244 DCHECK_EQ(true, success);
245 }
246 bitmap->reset();
247 }
248
202 } // namespace cc 249 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698