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

Side by Side Diff: cc/playback/display_list_raster_source.cc

Issue 1819683002: Use sk_sp-based picture recording APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skspify GetPicture/GetFlattenedPicture Created 4 years, 9 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/playback/display_list_raster_source.h ('k') | cc/playback/drawing_display_item.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/playback/display_list_raster_source.h" 5 #include "cc/playback/display_list_raster_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 DCHECK(display_list_.get()); 253 DCHECK(display_list_.get());
254 gfx::Rect canvas_target_playback_rect = 254 gfx::Rect canvas_target_playback_rect =
255 canvas_playback_rect - canvas_bitmap_rect.OffsetFromOrigin(); 255 canvas_playback_rect - canvas_bitmap_rect.OffsetFromOrigin();
256 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); 256 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_);
257 for (int i = 0; i < repeat_count; ++i) { 257 for (int i = 0; i < repeat_count; ++i) {
258 display_list_->Raster(canvas, callback, canvas_target_playback_rect, 258 display_list_->Raster(canvas, callback, canvas_target_playback_rect,
259 contents_scale); 259 contents_scale);
260 } 260 }
261 } 261 }
262 262
263 skia::RefPtr<SkPicture> DisplayListRasterSource::GetFlattenedPicture() { 263 sk_sp<SkPicture> DisplayListRasterSource::GetFlattenedPicture() {
264 TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture"); 264 TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture");
265 265
266 gfx::Rect display_list_rect(size_); 266 gfx::Rect display_list_rect(size_);
267 SkPictureRecorder recorder; 267 SkPictureRecorder recorder;
268 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(), 268 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(),
269 display_list_rect.height()); 269 display_list_rect.height());
270 if (!display_list_rect.IsEmpty()) { 270 if (!display_list_rect.IsEmpty()) {
271 PrepareForPlaybackToCanvas(canvas, display_list_rect, display_list_rect, 271 PrepareForPlaybackToCanvas(canvas, display_list_rect, display_list_rect,
272 1.f); 272 1.f);
273 RasterCommon(canvas, nullptr, display_list_rect, display_list_rect, 1.f); 273 RasterCommon(canvas, nullptr, display_list_rect, display_list_rect, 1.f);
274 } 274 }
275 skia::RefPtr<SkPicture> picture =
276 skia::AdoptRef(recorder.endRecordingAsPicture());
277 275
278 return picture; 276 return recorder.finishRecordingAsPicture();
279 } 277 }
280 278
281 size_t DisplayListRasterSource::GetPictureMemoryUsage() const { 279 size_t DisplayListRasterSource::GetPictureMemoryUsage() const {
282 if (!display_list_) 280 if (!display_list_)
283 return 0; 281 return 0;
284 return display_list_->ApproximateMemoryUsage() + 282 return display_list_->ApproximateMemoryUsage() +
285 painter_reported_memory_usage_; 283 painter_reported_memory_usage_;
286 } 284 }
287 285
288 bool DisplayListRasterSource::PerformSolidColorAnalysis( 286 bool DisplayListRasterSource::PerformSolidColorAnalysis(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 base::trace_event::MemoryAllocatorDump* dump = 383 base::trace_event::MemoryAllocatorDump* dump =
386 pmd->CreateAllocatorDump(dump_name); 384 pmd->CreateAllocatorDump(dump_name);
387 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 385 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
388 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 386 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
389 memory_usage); 387 memory_usage);
390 } 388 }
391 return true; 389 return true;
392 } 390 }
393 391
394 } // namespace cc 392 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/display_list_raster_source.h ('k') | cc/playback/drawing_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698