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

Side by Side Diff: samplecode/SampleFilterFuzz.cpp

Issue 1719993002: fix misc asserts and checks found by fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: hide the creation of the typeface as well Created 4 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
« no previous file with comments | « include/effects/SkDashPathEffect.h ('k') | src/effects/Sk1DPathEffect.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 "Sk1DPathEffect.h" 8 #include "Sk1DPathEffect.h"
9 #include "Sk2DPathEffect.h" 9 #include "Sk2DPathEffect.h"
10 #include "SkAlphaThresholdFilter.h" 10 #include "SkAlphaThresholdFilter.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 static SkFilterQuality make_filter_quality() { 198 static SkFilterQuality make_filter_quality() {
199 return static_cast<SkFilterQuality>(R(kHigh_SkFilterQuality+1)); 199 return static_cast<SkFilterQuality>(R(kHigh_SkFilterQuality+1));
200 } 200 }
201 201
202 static SkTypeface::Style make_typeface_style() { 202 static SkTypeface::Style make_typeface_style() {
203 return static_cast<SkTypeface::Style>(R(SkTypeface::kBoldItalic+1)); 203 return static_cast<SkTypeface::Style>(R(SkTypeface::kBoldItalic+1));
204 } 204 }
205 205
206 static SkPath1DPathEffect::Style make_path_1d_path_effect_style() { 206 static SkPath1DPathEffect::Style make_path_1d_path_effect_style() {
207 return static_cast<SkPath1DPathEffect::Style>(R(SkPath1DPathEffect::kStyleCo unt)); 207 return static_cast<SkPath1DPathEffect::Style>(R((int)SkPath1DPathEffect::kLa stEnum_Style + 1));
208 } 208 }
209 209
210 static SkColor make_color() { 210 static SkColor make_color() {
211 return (R(2) == 1) ? 0xFFC0F0A0 : 0xFF000090; 211 return (R(2) == 1) ? 0xFFC0F0A0 : 0xFF000090;
212 } 212 }
213 213
214 static SkDropShadowImageFilter::ShadowMode make_shadow_mode() { 214 static SkDropShadowImageFilter::ShadowMode make_shadow_mode() {
215 return (R(2) == 1) ? SkDropShadowImageFilter::kDrawShadowAndForeground_Shado wMode : 215 return (R(2) == 1) ? SkDropShadowImageFilter::kDrawShadowAndForeground_Shado wMode :
216 SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode; 216 SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode;
217 } 217 }
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 paint.setStyle(make_paint_style()); 520 paint.setStyle(make_paint_style());
521 paint.setColor(make_color()); 521 paint.setColor(make_color());
522 paint.setStrokeWidth(make_scalar()); 522 paint.setStrokeWidth(make_scalar());
523 paint.setStrokeMiter(make_scalar()); 523 paint.setStrokeMiter(make_scalar());
524 paint.setStrokeCap(make_paint_cap()); 524 paint.setStrokeCap(make_paint_cap());
525 paint.setStrokeJoin(make_paint_join()); 525 paint.setStrokeJoin(make_paint_join());
526 paint.setColorFilter(make_color_filter()); 526 paint.setColorFilter(make_color_filter());
527 paint.setXfermodeMode(make_xfermode()); 527 paint.setXfermodeMode(make_xfermode());
528 paint.setPathEffect(make_path_effect()); 528 paint.setPathEffect(make_path_effect());
529 paint.setMaskFilter(make_mask_filter()); 529 paint.setMaskFilter(make_mask_filter());
530 SkAutoTUnref<SkTypeface> typeface( 530
531 SkTypeface::CreateFromName(make_font_name().c_str(), make_typeface_style ())); 531 if (false) {
532 paint.setTypeface(typeface); 532 // our validating buffer does not support typefaces yet, so skip this fo r now
533 SkAutoTUnref<SkTypeface> typeface(
534 SkTypeface::CreateFromName(make_font_name().c_str(), make_ typeface_style()));
535 paint.setTypeface(typeface);
536 }
537
533 SkLayerRasterizer::Builder rasterizerBuilder; 538 SkLayerRasterizer::Builder rasterizerBuilder;
534 SkPaint paintForRasterizer; 539 SkPaint paintForRasterizer;
535 if (R(2) == 1) { 540 if (R(2) == 1) {
536 paintForRasterizer = make_paint(); 541 paintForRasterizer = make_paint();
537 } 542 }
538 rasterizerBuilder.addLayer(paintForRasterizer); 543 rasterizerBuilder.addLayer(paintForRasterizer);
539 SkAutoTUnref<SkRasterizer> rasterizer(rasterizerBuilder.detachRasterizer()); 544 SkAutoTUnref<SkRasterizer> rasterizer(rasterizerBuilder.detachRasterizer());
540 paint.setRasterizer(rasterizer); 545 paint.setRasterizer(rasterizer);
541 paint.setImageFilter(make_image_filter()); 546 paint.setImageFilter(make_image_filter());
542 SkAutoDataUnref data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool ())); 547 SkAutoDataUnref data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool ()));
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 821 }
817 822
818 private: 823 private:
819 typedef SkView INHERITED; 824 typedef SkView INHERITED;
820 }; 825 };
821 826
822 ////////////////////////////////////////////////////////////////////////////// 827 //////////////////////////////////////////////////////////////////////////////
823 828
824 static SkView* MyFactory() { return new ImageFilterFuzzView; } 829 static SkView* MyFactory() { return new ImageFilterFuzzView; }
825 static SkViewRegister reg(MyFactory); 830 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/effects/SkDashPathEffect.h ('k') | src/effects/Sk1DPathEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698