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

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: rebase and fix gpu raster issue 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
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/resources/raster_worker_pool_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/resources/raster_worker_pool_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698