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

Side by Side Diff: src/core/SkPictureShader.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/SkPicture.cpp ('k') | src/effects/SkPictureImageFilter.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 2014 Google Inc. 2 * Copyright 2014 Google Inc.
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 "SkPictureShader.h" 8 #include "SkPictureShader.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 SkShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx, TileMo de tmy, 118 SkShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx, TileMo de tmy,
119 const SkMatrix* localMatrix, const SkRe ct* tile) { 119 const SkMatrix* localMatrix, const SkRe ct* tile) {
120 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) { 120 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
121 return SkShader::CreateEmptyShader(); 121 return SkShader::CreateEmptyShader();
122 } 122 }
123 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile)); 123 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile));
124 } 124 }
125 125
126 // TODO: rename SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS to SK_DISALLOW_CROS SPROCESS_PICTURES
127
128 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) { 126 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
129 SkMatrix lm; 127 SkMatrix lm;
130 buffer.readMatrix(&lm); 128 buffer.readMatrix(&lm);
131 TileMode mx = (TileMode)buffer.read32(); 129 TileMode mx = (TileMode)buffer.read32();
132 TileMode my = (TileMode)buffer.read32(); 130 TileMode my = (TileMode)buffer.read32();
133 SkRect tile; 131 SkRect tile;
134 buffer.readRect(&tile); 132 buffer.readRect(&tile);
135 133
136 SkAutoTUnref<SkPicture> picture; 134 SkAutoTUnref<SkPicture> picture;
137 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS 135
138 if (buffer.isCrossProcess()) { 136 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
139 if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Versio n)) { 137 if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Versio n)) {
140 // Older code blindly serialized pictures. We don't trust them. 138 // Older code blindly serialized pictures. We don't trust them.
141 buffer.validate(false); 139 buffer.validate(false);
142 return NULL; 140 return NULL;
143 } 141 }
144 // Newer code won't serialize pictures in disallow-cross-process-picture mode. 142 // Newer code won't serialize pictures in disallow-cross-process-picture mode.
145 // Assert that they didn't serialize anything except a false here. 143 // Assert that they didn't serialize anything except a false here.
146 buffer.validate(!buffer.readBool()); 144 buffer.validate(!buffer.readBool());
147 } else 145 } else {
148 #endif
149 {
150 // Old code always serialized the picture. New code writes a 'true' fir st if it did. 146 // Old code always serialized the picture. New code writes a 'true' fir st if it did.
151 if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Versio n) || 147 if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Versio n) ||
152 buffer.readBool()) { 148 buffer.readBool()) {
153 picture.reset(SkPicture::CreateFromBuffer(buffer)); 149 picture.reset(SkPicture::CreateFromBuffer(buffer));
154 } 150 }
155 } 151 }
156 return SkPictureShader::Create(picture, mx, my, &lm, &tile); 152 return SkPictureShader::Create(picture, mx, my, &lm, &tile);
157 } 153 }
158 154
159 void SkPictureShader::flatten(SkWriteBuffer& buffer) const { 155 void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
160 buffer.writeMatrix(this->getLocalMatrix()); 156 buffer.writeMatrix(this->getLocalMatrix());
161 buffer.write32(fTmx); 157 buffer.write32(fTmx);
162 buffer.write32(fTmy); 158 buffer.write32(fTmy);
163 buffer.writeRect(fTile); 159 buffer.writeRect(fTile);
164 160
165 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
166 // The deserialization code won't trust that our serialized picture is safe to deserialize. 161 // The deserialization code won't trust that our serialized picture is safe to deserialize.
167 // So write a 'false' telling it that we're not serializing a picture. 162 // So write a 'false' telling it that we're not serializing a picture.
168 if (buffer.isCrossProcess()) { 163 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable d()) {
169 buffer.writeBool(false); 164 buffer.writeBool(false);
170 } else 165 } else {
171 #endif
172 {
173 buffer.writeBool(true); 166 buffer.writeBool(true);
174 fPicture->flatten(buffer); 167 fPicture->flatten(buffer);
175 } 168 }
176 } 169 }
177 170
178 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri x* localM, 171 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri x* localM,
179 const int maxTextureSize) const { 172 const int maxTextureSize) const {
180 SkASSERT(fPicture && !fPicture->cullRect().isEmpty()); 173 SkASSERT(fPicture && !fPicture->cullRect().isEmpty());
181 174
182 SkMatrix m; 175 SkMatrix m;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp); 348 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp);
356 } 349 }
357 #else 350 #else
358 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&, 351 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&,
359 const SkMatrix*, GrColor*, 352 const SkMatrix*, GrColor*,
360 GrFragmentProcessor**) const { 353 GrFragmentProcessor**) const {
361 SkDEBUGFAIL("Should not call in GPU-less build"); 354 SkDEBUGFAIL("Should not call in GPU-less build");
362 return false; 355 return false;
363 } 356 }
364 #endif 357 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698