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

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

Issue 1066273002: Use SkPictureRecorder::endRecordingAsPicture() instead of endRecording() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/display_list_raster_source.cc ('k') | cc/resources/picture.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 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/resources/gpu_rasterizer.h" 5 #include "cc/resources/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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 float scale) { 45 float scale) {
46 // Play back raster_source into temp SkPicture. 46 // Play back raster_source into temp SkPicture.
47 SkPictureRecorder recorder; 47 SkPictureRecorder recorder;
48 gfx::Size size = write_lock->resource()->size; 48 gfx::Size size = write_lock->resource()->size;
49 const int flags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag; 49 const int flags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag;
50 skia::RefPtr<SkCanvas> canvas = skia::SharePtr( 50 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(
51 recorder.beginRecording(size.width(), size.height(), NULL, flags)); 51 recorder.beginRecording(size.width(), size.height(), NULL, flags));
52 canvas->save(); 52 canvas->save();
53 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); 53 raster_source->PlaybackToCanvas(canvas.get(), rect, scale);
54 canvas->restore(); 54 canvas->restore();
55 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); 55 skia::RefPtr<SkPicture> picture =
56 skia::AdoptRef(recorder.endRecordingAsPicture());
56 57
57 // Turn on distance fields for layers that have ever animated. 58 // Turn on distance fields for layers that have ever animated.
58 bool use_distance_field_text = 59 bool use_distance_field_text =
59 use_distance_field_text_ || 60 use_distance_field_text_ ||
60 raster_source->ShouldAttemptToUseDistanceFieldText(); 61 raster_source->ShouldAttemptToUseDistanceFieldText();
61 62
62 // Playback picture into resource. 63 // Playback picture into resource.
63 { 64 {
64 ScopedGpuRaster gpu_raster( 65 ScopedGpuRaster gpu_raster(
65 resource_provider_->output_surface()->worker_context_provider()); 66 resource_provider_->output_surface()->worker_context_provider());
66 write_lock->InitSkSurface(use_distance_field_text, 67 write_lock->InitSkSurface(use_distance_field_text,
67 raster_source->CanUseLCDText(), 68 raster_source->CanUseLCDText(),
68 msaa_sample_count_); 69 msaa_sample_count_);
69 70
70 SkSurface* sk_surface = write_lock->sk_surface(); 71 SkSurface* sk_surface = write_lock->sk_surface();
71 72
72 // Allocating an SkSurface will fail after a lost context. Pretend we 73 // Allocating an SkSurface will fail after a lost context. Pretend we
73 // rasterized, as the contents of the resource don't matter anymore. 74 // rasterized, as the contents of the resource don't matter anymore.
74 if (!sk_surface) 75 if (!sk_surface)
75 return; 76 return;
76 77
77 SkMultiPictureDraw multi_picture_draw; 78 SkMultiPictureDraw multi_picture_draw;
78 multi_picture_draw.add(sk_surface->getCanvas(), picture.get()); 79 multi_picture_draw.add(sk_surface->getCanvas(), picture.get());
79 multi_picture_draw.draw(msaa_sample_count_ > 0); 80 multi_picture_draw.draw(msaa_sample_count_ > 0);
80 write_lock->ReleaseSkSurface(); 81 write_lock->ReleaseSkSurface();
81 } 82 }
82 } 83 }
83 84
84 } // namespace cc 85 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/display_list_raster_source.cc ('k') | cc/resources/picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698