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

Side by Side Diff: samplecode/SampleFilterFuzz.cpp

Issue 153583007: Revert "Serialization of SkPictureImageFilter" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « include/effects/SkPictureImageFilter.h ('k') | src/core/SkPicture.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 Google Inc. 2 * Copyright 2013 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 #include "SampleCode.h" 7 #include "SampleCode.h"
8 #include "SkBicubicImageFilter.h" 8 #include "SkBicubicImageFilter.h"
9 #include "SkBitmapDevice.h" 9 #include "SkBitmapDevice.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 static SkBitmap bitmap[2]; 177 static SkBitmap bitmap[2];
178 static bool initialized = false; 178 static bool initialized = false;
179 if (!initialized) { 179 if (!initialized) {
180 make_g_bitmap(bitmap[0]); 180 make_g_bitmap(bitmap[0]);
181 make_checkerboard_bitmap(bitmap[1]); 181 make_checkerboard_bitmap(bitmap[1]);
182 initialized = true; 182 initialized = true;
183 } 183 }
184 return bitmap[R(2)]; 184 return bitmap[R(2)];
185 } 185 }
186 186
187 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION
188 static void drawSomething(SkCanvas* canvas) {
189 SkPaint paint;
190
191 canvas->save();
192 canvas->scale(0.5f, 0.5f);
193 canvas->drawBitmap(make_bitmap(), 0, 0, NULL);
194 canvas->restore();
195
196 const char beforeStr[] = "before circle";
197 const char afterStr[] = "after circle";
198
199 paint.setAntiAlias(true);
200
201 paint.setColor(SK_ColorRED);
202 canvas->drawData(beforeStr, sizeof(beforeStr));
203 canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2 ), SkIntToScalar(kBitmapSize/3), paint);
204 canvas->drawData(afterStr, sizeof(afterStr));
205 paint.setColor(SK_ColorBLACK);
206 paint.setTextSize(SkIntToScalar(kBitmapSize/3));
207 canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(k BitmapSize/4), paint);
208 }
209 #endif
210
211 static SkImageFilter* make_image_filter(bool canBeNull = true) { 187 static SkImageFilter* make_image_filter(bool canBeNull = true) {
212 SkImageFilter* filter = 0; 188 SkImageFilter* filter = 0;
213 189
214 // Add a 1 in 3 chance to get a NULL input 190 // Add a 1 in 3 chance to get a NULL input
215 if (canBeNull && (R(3) == 1)) { return filter; } 191 if (canBeNull && (R(3) == 1)) { return filter; }
216 192
217 enum { BICUBIC, MERGE, COLOR, BLUR, MAGNIFIER, XFERMODE, OFFSET, COMPOSE, 193 enum { BICUBIC, MERGE, COLOR, BLUR, MAGNIFIER, XFERMODE, OFFSET, COMPOSE,
218 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, 194 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW,
219 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, NUM_FILTERS }; 195 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, NUM_FILTERS };
220 196
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 break; 287 break;
312 case DISPLACE: 288 case DISPLACE:
313 filter = new SkDisplacementMapEffect(make_channel_selector_type(), 289 filter = new SkDisplacementMapEffect(make_channel_selector_type(),
314 make_channel_selector_type(), make_scalar(), 290 make_channel_selector_type(), make_scalar(),
315 make_image_filter(false), make_image_filter()); 291 make_image_filter(false), make_image_filter());
316 break; 292 break;
317 case TILE: 293 case TILE:
318 filter = new SkTileImageFilter(make_rect(), make_rect(), make_image_filt er(false)); 294 filter = new SkTileImageFilter(make_rect(), make_rect(), make_image_filt er(false));
319 break; 295 break;
320 case PICTURE: 296 case PICTURE:
321 { 297 filter = new SkPictureImageFilter(NULL, make_rect());
322 SkPicture* pict = NULL;
323 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION
324 pict = new SkPicture;
325 SkAutoUnref aur(pict);
326 drawSomething(pict->beginRecording(kBitmapSize, kBitmapSize));
327 pict->endRecording();
328 #endif
329 filter = new SkPictureImageFilter(pict, make_rect());
330 }
331 break; 298 break;
332 default: 299 default:
333 break; 300 break;
334 } 301 }
335 return (filter || canBeNull) ? filter : make_image_filter(canBeNull); 302 return (filter || canBeNull) ? filter : make_image_filter(canBeNull);
336 } 303 }
337 304
338 static SkImageFilter* make_serialized_image_filter() { 305 static SkImageFilter* make_serialized_image_filter() {
339 SkAutoTUnref<SkImageFilter> filter(make_image_filter(false)); 306 SkAutoTUnref<SkImageFilter> filter(make_image_filter(false));
340 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); 307 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 392 }
426 393
427 private: 394 private:
428 typedef SkView INHERITED; 395 typedef SkView INHERITED;
429 }; 396 };
430 397
431 ////////////////////////////////////////////////////////////////////////////// 398 //////////////////////////////////////////////////////////////////////////////
432 399
433 static SkView* MyFactory() { return new ImageFilterFuzzView; } 400 static SkView* MyFactory() { return new ImageFilterFuzzView; }
434 static SkViewRegister reg(MyFactory); 401 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/effects/SkPictureImageFilter.h ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698