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

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

Issue 659563002: cc: Replace RasterBuffer::Acquire/ReleaseCanvas with Playback function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add temporary size variable 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
« 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 15
15 namespace cc { 16 namespace cc {
16 namespace { 17 namespace {
17 18
18 class RasterTaskGraphRunner : public TaskGraphRunner, 19 class RasterTaskGraphRunner : public TaskGraphRunner,
19 public base::DelegateSimpleThread::Delegate { 20 public base::DelegateSimpleThread::Delegate {
20 public: 21 public:
21 RasterTaskGraphRunner() { 22 RasterTaskGraphRunner() {
22 size_t num_threads = RasterWorkerPool::GetNumRasterThreads(); 23 size_t num_threads = RasterWorkerPool::GetNumRasterThreads();
23 while (workers_.size() < num_threads) { 24 while (workers_.size() < num_threads) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (decode_it == graph->nodes.end()) 189 if (decode_it == graph->nodes.end())
189 InsertNodeForTask(graph, decode_task, priority, 0u); 190 InsertNodeForTask(graph, decode_task, priority, 0u);
190 191
191 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); 192 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task));
192 } 193 }
193 194
194 InsertNodeForTask(graph, raster_task, priority, dependencies); 195 InsertNodeForTask(graph, raster_task, priority, dependencies);
195 } 196 }
196 197
197 // static 198 // static
198 void RasterWorkerPool::AcquireBitmapForBuffer(SkBitmap* bitmap, 199 void RasterWorkerPool::PlaybackToMemory(void* memory,
199 void* buffer, 200 ResourceFormat format,
200 ResourceFormat buffer_format, 201 const gfx::Size& size,
201 const gfx::Size& size, 202 int stride,
202 int stride) { 203 const PicturePileImpl* picture_pile,
203 switch (buffer_format) { 204 const gfx::Rect& rect,
205 float scale,
206 RenderingStatsInstrumentation* stats) {
207 SkBitmap bitmap;
208 switch (format) {
204 case RGBA_4444: 209 case RGBA_4444:
205 bitmap->allocN32Pixels(size.width(), size.height()); 210 bitmap.allocN32Pixels(size.width(), size.height());
206 break; 211 break;
207 case RGBA_8888: 212 case RGBA_8888:
208 case BGRA_8888: { 213 case BGRA_8888: {
209 SkImageInfo info = 214 SkImageInfo info =
210 SkImageInfo::MakeN32Premul(size.width(), size.height()); 215 SkImageInfo::MakeN32Premul(size.width(), size.height());
211 if (!stride) 216 if (!stride)
212 stride = info.minRowBytes(); 217 stride = info.minRowBytes();
213 bitmap->installPixels(info, buffer, stride); 218 bitmap.installPixels(info, memory, stride);
214 break; 219 break;
215 } 220 }
216 case ALPHA_8: 221 case ALPHA_8:
217 case LUMINANCE_8: 222 case LUMINANCE_8:
218 case RGB_565: 223 case RGB_565:
219 case ETC1: 224 case ETC1:
220 NOTREACHED(); 225 NOTREACHED();
221 break; 226 break;
222 } 227 }
223 }
224 228
225 // static 229 SkCanvas canvas(bitmap);
226 void RasterWorkerPool::ReleaseBitmapForBuffer(SkBitmap* bitmap, 230 picture_pile->RasterToBitmap(&canvas, rect, scale, stats);
227 void* buffer, 231
228 ResourceFormat buffer_format) { 232 SkColorType buffer_color_type = ResourceFormatToSkColorType(format);
229 SkColorType buffer_color_type = ResourceFormatToSkColorType(buffer_format); 233 if (buffer_color_type != bitmap.colorType()) {
230 if (buffer_color_type != bitmap->colorType()) { 234 SkImageInfo dst_info = bitmap.info();
231 SkImageInfo dst_info = bitmap->info();
232 dst_info.fColorType = buffer_color_type; 235 dst_info.fColorType = buffer_color_type;
233 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 236 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
234 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 237 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
235 // is fixed. 238 // is fixed.
236 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); 239 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
237 DCHECK_EQ(0u, dst_row_bytes % 4); 240 DCHECK_EQ(0u, dst_row_bytes % 4);
238 bool success = bitmap->readPixels(dst_info, buffer, dst_row_bytes, 0, 0); 241 bool success = bitmap.readPixels(dst_info, memory, dst_row_bytes, 0, 0);
239 DCHECK_EQ(true, success); 242 DCHECK_EQ(true, success);
240 } 243 }
241 bitmap->reset();
242 } 244 }
243 245
244 } // namespace cc 246 } // 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