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

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: thread safe Created 6 years, 2 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"
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 15
16 namespace cc { 16 namespace cc {
17 namespace { 17 namespace {
18 18
19 class RasterTaskGraphRunner : public TaskGraphRunner, 19 class RasterTaskGraphRunner : public TaskGraphRunner,
20 public base::DelegateSimpleThread::Delegate { 20 public base::DelegateSimpleThread::Delegate {
21 public: 21 public:
22 RasterTaskGraphRunner() { 22 RasterTaskGraphRunner() {
23 size_t num_threads = RasterWorkerPool::GetNumRasterThreads(); 23 size_t num_threads = RasterWorkerPool::GetNumRasterThreads();
24 while (workers_.size() < num_threads) { 24 while (workers_.size() < num_threads) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 192
193 InsertNodeForTask(graph, raster_task, priority, dependencies); 193 InsertNodeForTask(graph, raster_task, priority, dependencies);
194 } 194 }
195 195
196 // static 196 // static
197 void RasterWorkerPool::PlaybackToMemory(void* memory, 197 void RasterWorkerPool::PlaybackToMemory(void* memory,
198 ResourceFormat format, 198 ResourceFormat format,
199 const gfx::Size& size, 199 const gfx::Size& size,
200 int stride, 200 int stride,
201 const PicturePileImpl* picture_pile, 201 const RasterSource* raster_source,
202 const gfx::Rect& rect, 202 const gfx::Rect& rect,
203 float scale, 203 float scale,
204 RenderingStatsInstrumentation* stats) { 204 RenderingStatsInstrumentation* stats) {
205 SkBitmap bitmap; 205 SkBitmap bitmap;
206 switch (format) { 206 switch (format) {
207 case RGBA_4444: 207 case RGBA_4444:
208 bitmap.allocN32Pixels(size.width(), size.height()); 208 bitmap.allocN32Pixels(size.width(), size.height());
209 break; 209 break;
210 case RGBA_8888: 210 case RGBA_8888:
211 case BGRA_8888: { 211 case BGRA_8888: {
212 SkImageInfo info = 212 SkImageInfo info =
213 SkImageInfo::MakeN32Premul(size.width(), size.height()); 213 SkImageInfo::MakeN32Premul(size.width(), size.height());
214 if (!stride) 214 if (!stride)
215 stride = info.minRowBytes(); 215 stride = info.minRowBytes();
216 bitmap.installPixels(info, memory, stride); 216 bitmap.installPixels(info, memory, stride);
217 break; 217 break;
218 } 218 }
219 case ALPHA_8: 219 case ALPHA_8:
220 case LUMINANCE_8: 220 case LUMINANCE_8:
221 case RGB_565: 221 case RGB_565:
222 case ETC1: 222 case ETC1:
223 NOTREACHED(); 223 NOTREACHED();
224 break; 224 break;
225 } 225 }
226 226
227 SkCanvas canvas(bitmap); 227 SkCanvas canvas(bitmap);
228 picture_pile->RasterToBitmap(&canvas, rect, scale, stats); 228 raster_source->RasterToBitmap(&canvas, rect, scale, stats);
229 229
230 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); 230 SkColorType buffer_color_type = ResourceFormatToSkColorType(format);
231 if (buffer_color_type != bitmap.colorType()) { 231 if (buffer_color_type != bitmap.colorType()) {
232 SkImageInfo dst_info = bitmap.info(); 232 SkImageInfo dst_info = bitmap.info();
233 dst_info.fColorType = buffer_color_type; 233 dst_info.fColorType = buffer_color_type;
234 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 234 // 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 235 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
236 // is fixed. 236 // is fixed.
237 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); 237 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
238 DCHECK_EQ(0u, dst_row_bytes % 4); 238 DCHECK_EQ(0u, dst_row_bytes % 4);
239 bool success = bitmap.readPixels(dst_info, memory, dst_row_bytes, 0, 0); 239 bool success = bitmap.readPixels(dst_info, memory, dst_row_bytes, 0, 0);
240 DCHECK_EQ(true, success); 240 DCHECK_EQ(true, success);
241 } 241 }
242 } 242 }
243 243
244 } // namespace cc 244 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698