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

Side by Side Diff: src/effects/SkPictureImageFilter.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder 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 | « src/core/SkPictureShader.cpp ('k') | src/utils/SkLua.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The Android Open Source Project 2 * Copyright 2013 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPictureImageFilter.h" 8 #include "SkPictureImageFilter.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 18 matching lines...) Expand all
29 , fCropRect(cropRect) 29 , fCropRect(cropRect)
30 , fPictureResolution(pictureResolution) 30 , fPictureResolution(pictureResolution)
31 , fFilterQuality(filterQuality) { 31 , fFilterQuality(filterQuality) {
32 } 32 }
33 33
34 SkPictureImageFilter::~SkPictureImageFilter() { 34 SkPictureImageFilter::~SkPictureImageFilter() {
35 SkSafeUnref(fPicture); 35 SkSafeUnref(fPicture);
36 } 36 }
37 37
38 SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) { 38 SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
39 SkAutoTUnref<SkPicture> picture; 39 sk_sp<SkPicture> picture;
40 SkRect cropRect; 40 SkRect cropRect;
41 41
42 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) { 42 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
43 buffer.validate(!buffer.readBool()); 43 buffer.validate(!buffer.readBool());
44 } else { 44 } else {
45 if (buffer.readBool()) { 45 if (buffer.readBool()) {
46 picture.reset(SkPicture::CreateFromBuffer(buffer)); 46 picture = SkPicture::MakeFromBuffer(buffer);
47 } 47 }
48 } 48 }
49 buffer.readRect(&cropRect); 49 buffer.readRect(&cropRect);
50 PictureResolution pictureResolution; 50 PictureResolution pictureResolution;
51 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) { 51 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) {
52 pictureResolution = kDeviceSpace_PictureResolution; 52 pictureResolution = kDeviceSpace_PictureResolution;
53 } else { 53 } else {
54 pictureResolution = (PictureResolution)buffer.readInt(); 54 pictureResolution = (PictureResolution)buffer.readInt();
55 } 55 }
56 56
57 if (kLocalSpace_PictureResolution == pictureResolution) { 57 if (kLocalSpace_PictureResolution == pictureResolution) {
58 //filterLevel is only serialized if pictureResolution is LocalSpace 58 //filterLevel is only serialized if pictureResolution is LocalSpace
59 SkFilterQuality filterQuality; 59 SkFilterQuality filterQuality;
60 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) { 60 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) {
61 filterQuality = kLow_SkFilterQuality; 61 filterQuality = kLow_SkFilterQuality;
62 } else { 62 } else {
63 filterQuality = (SkFilterQuality)buffer.readInt(); 63 filterQuality = (SkFilterQuality)buffer.readInt();
64 } 64 }
65 return CreateForLocalSpace(picture, cropRect, filterQuality); 65 return CreateForLocalSpace(picture.get(), cropRect, filterQuality);
66 } 66 }
67 return Create(picture, cropRect); 67 return Create(picture.get(), cropRect);
68 } 68 }
69 69
70 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { 70 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
71 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) { 71 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
72 buffer.writeBool(false); 72 buffer.writeBool(false);
73 } else { 73 } else {
74 bool hasPicture = (fPicture != nullptr); 74 bool hasPicture = (fPicture != nullptr);
75 buffer.writeBool(hasPicture); 75 buffer.writeBool(hasPicture);
76 if (hasPicture) { 76 if (hasPicture) {
77 fPicture->flatten(buffer); 77 fPicture->flatten(buffer);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 str->appendf("crop: (%f,%f,%f,%f) ", 168 str->appendf("crop: (%f,%f,%f,%f) ",
169 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom); 169 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom);
170 if (fPicture) { 170 if (fPicture) {
171 str->appendf("picture: (%f,%f,%f,%f)", 171 str->appendf("picture: (%f,%f,%f,%f)",
172 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, 172 fPicture->cullRect().fLeft, fPicture->cullRect().fTop,
173 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); 173 fPicture->cullRect().fRight, fPicture->cullRect().fBottom);
174 } 174 }
175 str->append(")"); 175 str->append(")");
176 } 176 }
177 #endif 177 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/utils/SkLua.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698