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

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

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/SkPixelXorXfermode.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 13 matching lines...) Expand all
24 SkPictureImageFilter::SkPictureImageFilter(sk_sp<SkPicture> picture, const SkRec t& cropRect, 24 SkPictureImageFilter::SkPictureImageFilter(sk_sp<SkPicture> picture, const SkRec t& cropRect,
25 PictureResolution pictureResolution, 25 PictureResolution pictureResolution,
26 SkFilterQuality filterQuality) 26 SkFilterQuality filterQuality)
27 : INHERITED(nullptr, 0, nullptr) 27 : INHERITED(nullptr, 0, nullptr)
28 , fPicture(std::move(picture)) 28 , fPicture(std::move(picture))
29 , fCropRect(cropRect) 29 , fCropRect(cropRect)
30 , fPictureResolution(pictureResolution) 30 , fPictureResolution(pictureResolution)
31 , fFilterQuality(filterQuality) { 31 , fFilterQuality(filterQuality) {
32 } 32 }
33 33
34 SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) { 34 sk_sp<SkFlattenable> SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
35 sk_sp<SkPicture> picture; 35 sk_sp<SkPicture> picture;
36 SkRect cropRect; 36 SkRect cropRect;
37 37
38 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) { 38 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
39 buffer.validate(!buffer.readBool()); 39 buffer.validate(!buffer.readBool());
40 } else { 40 } else {
41 if (buffer.readBool()) { 41 if (buffer.readBool()) {
42 picture = SkPicture::MakeFromBuffer(buffer); 42 picture = SkPicture::MakeFromBuffer(buffer);
43 } 43 }
44 } 44 }
45 buffer.readRect(&cropRect); 45 buffer.readRect(&cropRect);
46 PictureResolution pictureResolution; 46 PictureResolution pictureResolution;
47 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) { 47 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) {
48 pictureResolution = kDeviceSpace_PictureResolution; 48 pictureResolution = kDeviceSpace_PictureResolution;
49 } else { 49 } else {
50 pictureResolution = (PictureResolution)buffer.readInt(); 50 pictureResolution = (PictureResolution)buffer.readInt();
51 } 51 }
52 52
53 if (kLocalSpace_PictureResolution == pictureResolution) { 53 if (kLocalSpace_PictureResolution == pictureResolution) {
54 //filterLevel is only serialized if pictureResolution is LocalSpace 54 //filterLevel is only serialized if pictureResolution is LocalSpace
55 SkFilterQuality filterQuality; 55 SkFilterQuality filterQuality;
56 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) { 56 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) {
57 filterQuality = kLow_SkFilterQuality; 57 filterQuality = kLow_SkFilterQuality;
58 } else { 58 } else {
59 filterQuality = (SkFilterQuality)buffer.readInt(); 59 filterQuality = (SkFilterQuality)buffer.readInt();
60 } 60 }
61 return MakeForLocalSpace(picture, cropRect, filterQuality).release(); 61 return MakeForLocalSpace(picture, cropRect, filterQuality);
62 } 62 }
63 return Make(picture, cropRect).release(); 63 return Make(picture, cropRect);
64 } 64 }
65 65
66 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { 66 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
67 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) { 67 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
68 buffer.writeBool(false); 68 buffer.writeBool(false);
69 } else { 69 } else {
70 bool hasPicture = (fPicture != nullptr); 70 bool hasPicture = (fPicture != nullptr);
71 buffer.writeBool(hasPicture); 71 buffer.writeBool(hasPicture);
72 if (hasPicture) { 72 if (hasPicture) {
73 fPicture->flatten(buffer); 73 fPicture->flatten(buffer);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 str->appendf("crop: (%f,%f,%f,%f) ", 164 str->appendf("crop: (%f,%f,%f,%f) ",
165 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom); 165 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom);
166 if (fPicture) { 166 if (fPicture) {
167 str->appendf("picture: (%f,%f,%f,%f)", 167 str->appendf("picture: (%f,%f,%f,%f)",
168 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, 168 fPicture->cullRect().fLeft, fPicture->cullRect().fTop,
169 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); 169 fPicture->cullRect().fRight, fPicture->cullRect().fBottom);
170 } 170 }
171 str->append(")"); 171 str->append(")");
172 } 172 }
173 #endif 173 #endif
OLDNEW
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/SkPixelXorXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698