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

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

Issue 666273002: cc: Added raster source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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_unittest.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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/threading/simple_thread.h" 12 #include "base/threading/simple_thread.h"
13 #include "cc/base/scoped_ptr_deque.h" 13 #include "cc/base/scoped_ptr_deque.h"
14 #include "cc/resources/picture_pile_impl.h" 14 #include "cc/resources/raster_source.h"
15 #include "third_party/skia/include/core/SkCanvas.h"
15 16
16 namespace cc { 17 namespace cc {
17 namespace { 18 namespace {
18 19
19 class RasterTaskGraphRunner : public TaskGraphRunner, 20 class RasterTaskGraphRunner : public TaskGraphRunner,
20 public base::DelegateSimpleThread::Delegate { 21 public base::DelegateSimpleThread::Delegate {
21 public: 22 public:
22 RasterTaskGraphRunner() { 23 RasterTaskGraphRunner() {
23 size_t num_threads = RasterWorkerPool::GetNumRasterThreads(); 24 size_t num_threads = RasterWorkerPool::GetNumRasterThreads();
24 while (workers_.size() < num_threads) { 25 while (workers_.size() < num_threads) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 192 }
192 193
193 InsertNodeForTask(graph, raster_task, priority, dependencies); 194 InsertNodeForTask(graph, raster_task, priority, dependencies);
194 } 195 }
195 196
196 // static 197 // static
197 void RasterWorkerPool::PlaybackToMemory(void* memory, 198 void RasterWorkerPool::PlaybackToMemory(void* memory,
198 ResourceFormat format, 199 ResourceFormat format,
199 const gfx::Size& size, 200 const gfx::Size& size,
200 int stride, 201 int stride,
201 const PicturePileImpl* picture_pile, 202 const RasterSource* raster_source,
202 const gfx::Rect& rect, 203 const gfx::Rect& rect,
203 float scale, 204 float scale,
204 RenderingStatsInstrumentation* stats) { 205 RenderingStatsInstrumentation* stats) {
205 SkBitmap bitmap; 206 SkBitmap bitmap;
206 switch (format) { 207 switch (format) {
207 case RGBA_4444: 208 case RGBA_4444:
208 bitmap.allocN32Pixels(size.width(), size.height()); 209 bitmap.allocN32Pixels(size.width(), size.height());
209 break; 210 break;
210 case RGBA_8888: 211 case RGBA_8888:
211 case BGRA_8888: { 212 case BGRA_8888: {
212 SkImageInfo info = 213 SkImageInfo info =
213 SkImageInfo::MakeN32Premul(size.width(), size.height()); 214 SkImageInfo::MakeN32Premul(size.width(), size.height());
214 if (!stride) 215 if (!stride)
215 stride = info.minRowBytes(); 216 stride = info.minRowBytes();
216 bitmap.installPixels(info, memory, stride); 217 bitmap.installPixels(info, memory, stride);
217 break; 218 break;
218 } 219 }
219 case ALPHA_8: 220 case ALPHA_8:
220 case LUMINANCE_8: 221 case LUMINANCE_8:
221 case RGB_565: 222 case RGB_565:
222 case ETC1: 223 case ETC1:
223 NOTREACHED(); 224 NOTREACHED();
224 break; 225 break;
225 } 226 }
226 227
227 SkCanvas canvas(bitmap); 228 SkCanvas canvas(bitmap);
228 picture_pile->RasterToBitmap(&canvas, rect, scale, stats); 229 raster_source->PlaybackToCanvas(&canvas, rect, scale, stats);
229 230
230 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); 231 SkColorType buffer_color_type = ResourceFormatToSkColorType(format);
231 if (buffer_color_type != bitmap.colorType()) { 232 if (buffer_color_type != bitmap.colorType()) {
232 SkImageInfo dst_info = bitmap.info(); 233 SkImageInfo dst_info = bitmap.info();
233 dst_info.fColorType = buffer_color_type; 234 dst_info.fColorType = buffer_color_type;
234 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 235 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
235 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 236 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
236 // is fixed. 237 // is fixed.
237 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); 238 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
238 DCHECK_EQ(0u, dst_row_bytes % 4); 239 DCHECK_EQ(0u, dst_row_bytes % 4);
239 bool success = bitmap.readPixels(dst_info, memory, dst_row_bytes, 0, 0); 240 bool success = bitmap.readPixels(dst_info, memory, dst_row_bytes, 0, 0);
240 DCHECK_EQ(true, success); 241 DCHECK_EQ(true, success);
241 } 242 }
242 } 243 }
243 244
244 } // namespace cc 245 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/resources/raster_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698