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

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

Issue 1183853003: skia: Add runtime option to disable picture IO security precautions (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rename stuff Created 5 years, 6 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') | tests/ImageFilterTest.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 21 matching lines...) Expand all
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 SkAutoTUnref<SkPicture> picture;
40 SkRect cropRect; 40 SkRect cropRect;
41 41
42 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS 42 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
43 if (buffer.isCrossProcess()) {
44 buffer.validate(!buffer.readBool()); 43 buffer.validate(!buffer.readBool());
45 } else 44 } else {
46 #endif
47 {
48 if (buffer.readBool()) { 45 if (buffer.readBool()) {
49 picture.reset(SkPicture::CreateFromBuffer(buffer)); 46 picture.reset(SkPicture::CreateFromBuffer(buffer));
50 } 47 }
51 } 48 }
52 buffer.readRect(&cropRect); 49 buffer.readRect(&cropRect);
53 PictureResolution pictureResolution; 50 PictureResolution pictureResolution;
54 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) { 51 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) {
55 pictureResolution = kDeviceSpace_PictureResolution; 52 pictureResolution = kDeviceSpace_PictureResolution;
56 } else { 53 } else {
57 pictureResolution = (PictureResolution)buffer.readInt(); 54 pictureResolution = (PictureResolution)buffer.readInt();
58 } 55 }
59 56
60 if (kLocalSpace_PictureResolution == pictureResolution) { 57 if (kLocalSpace_PictureResolution == pictureResolution) {
61 //filterLevel is only serialized if pictureResolution is LocalSpace 58 //filterLevel is only serialized if pictureResolution is LocalSpace
62 SkFilterQuality filterQuality; 59 SkFilterQuality filterQuality;
63 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) { 60 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) {
64 filterQuality = kLow_SkFilterQuality; 61 filterQuality = kLow_SkFilterQuality;
65 } else { 62 } else {
66 filterQuality = (SkFilterQuality)buffer.readInt(); 63 filterQuality = (SkFilterQuality)buffer.readInt();
67 } 64 }
68 return CreateForLocalSpace(picture, cropRect, filterQuality); 65 return CreateForLocalSpace(picture, cropRect, filterQuality);
69 } 66 }
70 return Create(picture, cropRect); 67 return Create(picture, cropRect);
71 } 68 }
72 69
73 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { 70 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
74 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS 71 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
75 if (buffer.isCrossProcess()) {
76 buffer.writeBool(false); 72 buffer.writeBool(false);
77 } else 73 } else {
78 #endif
79 {
80 bool hasPicture = (fPicture != NULL); 74 bool hasPicture = (fPicture != NULL);
81 buffer.writeBool(hasPicture); 75 buffer.writeBool(hasPicture);
82 if (hasPicture) { 76 if (hasPicture) {
83 fPicture->flatten(buffer); 77 fPicture->flatten(buffer);
84 } 78 }
85 } 79 }
86 buffer.writeRect(fCropRect); 80 buffer.writeRect(fCropRect);
87 buffer.writeInt(fPictureResolution); 81 buffer.writeInt(fPictureResolution);
88 if (kLocalSpace_PictureResolution == fPictureResolution) { 82 if (kLocalSpace_PictureResolution == fPictureResolution) {
89 buffer.writeInt(fFilterQuality); 83 buffer.writeInt(fFilterQuality);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 str->appendf("crop: (%f,%f,%f,%f) ", 174 str->appendf("crop: (%f,%f,%f,%f) ",
181 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom); 175 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom);
182 if (fPicture) { 176 if (fPicture) {
183 str->appendf("picture: (%f,%f,%f,%f)", 177 str->appendf("picture: (%f,%f,%f,%f)",
184 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, 178 fPicture->cullRect().fLeft, fPicture->cullRect().fTop,
185 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); 179 fPicture->cullRect().fRight, fPicture->cullRect().fBottom);
186 } 180 }
187 str->append(")"); 181 str->append(")");
188 } 182 }
189 #endif 183 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698