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

Side by Side Diff: cc/raster/gpu_rasterizer.cc

Issue 1819683002: Use sk_sp-based picture recording APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/raster/gpu_rasterizer.h" 5 #include "cc/raster/gpu_rasterizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 SkPictureRecorder recorder; 48 SkPictureRecorder recorder;
49 const gfx::Size size = write_lock->GetResourceSize(); 49 const gfx::Size size = write_lock->GetResourceSize();
50 const int flags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag; 50 const int flags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag;
51 skia::RefPtr<SkCanvas> canvas = skia::SharePtr( 51 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(
52 recorder.beginRecording(size.width(), size.height(), NULL, flags)); 52 recorder.beginRecording(size.width(), size.height(), NULL, flags));
53 canvas->save(); 53 canvas->save();
54 const bool include_images = true; 54 const bool include_images = true;
55 raster_source->PlaybackToCanvas(canvas.get(), raster_full_rect, playback_rect, 55 raster_source->PlaybackToCanvas(canvas.get(), raster_full_rect, playback_rect,
56 scale, include_images); 56 scale, include_images);
57 canvas->restore(); 57 canvas->restore();
58 skia::RefPtr<SkPicture> picture = 58 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
59 skia::AdoptRef(recorder.endRecordingAsPicture());
60 59
61 // Turn on distance fields for layers that have ever animated. 60 // Turn on distance fields for layers that have ever animated.
62 bool use_distance_field_text = 61 bool use_distance_field_text =
63 use_distance_field_text_ || 62 use_distance_field_text_ ||
64 raster_source->ShouldAttemptToUseDistanceFieldText(); 63 raster_source->ShouldAttemptToUseDistanceFieldText();
65 64
66 // Playback picture into resource. 65 // Playback picture into resource.
67 { 66 {
68 ScopedGpuRaster gpu_raster( 67 ScopedGpuRaster gpu_raster(
69 resource_provider_->output_surface()->worker_context_provider()); 68 resource_provider_->output_surface()->worker_context_provider());
70 write_lock->InitSkSurface(use_distance_field_text, 69 write_lock->InitSkSurface(use_distance_field_text,
71 raster_source->CanUseLCDText(), 70 raster_source->CanUseLCDText(),
72 msaa_sample_count_); 71 msaa_sample_count_);
73 72
74 SkSurface* sk_surface = write_lock->sk_surface(); 73 SkSurface* sk_surface = write_lock->sk_surface();
75 74
76 // Allocating an SkSurface will fail after a lost context. Pretend we 75 // Allocating an SkSurface will fail after a lost context. Pretend we
77 // rasterized, as the contents of the resource don't matter anymore. 76 // rasterized, as the contents of the resource don't matter anymore.
78 if (!sk_surface) 77 if (!sk_surface)
79 return; 78 return;
80 79
81 SkMultiPictureDraw multi_picture_draw; 80 SkMultiPictureDraw multi_picture_draw;
82 multi_picture_draw.add(sk_surface->getCanvas(), picture.get()); 81 multi_picture_draw.add(sk_surface->getCanvas(), picture.get());
83 multi_picture_draw.draw(false); 82 multi_picture_draw.draw(false);
84 write_lock->ReleaseSkSurface(); 83 write_lock->ReleaseSkSurface();
85 } 84 }
86 } 85 }
87 86
88 } // namespace cc 87 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698