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

Side by Side Diff: samplecode/SampleFilterFuzz.cpp

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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 | « samplecode/SampleApp.cpp ('k') | samplecode/SampleUnpremul.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 "SkAlphaThresholdFilter.h" 8 #include "SkAlphaThresholdFilter.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 static SkColorType rand_colortype() { 147 static SkColorType rand_colortype() {
148 return (SkColorType)R(kLastEnum_SkColorType + 1); 148 return (SkColorType)R(kLastEnum_SkColorType + 1);
149 } 149 }
150 150
151 static void rand_bitmap_for_canvas(SkBitmap* bitmap) { 151 static void rand_bitmap_for_canvas(SkBitmap* bitmap) {
152 SkImageInfo info; 152 SkImageInfo info;
153 do { 153 do {
154 info = SkImageInfo::Make(kBitmapSize, kBitmapSize, rand_colortype(), 154 info = SkImageInfo::Make(kBitmapSize, kBitmapSize, rand_colortype(),
155 kPremul_SkAlphaType); 155 kPremul_SkAlphaType);
156 } while (!valid_for_raster_canvas(info) || !bitmap->allocPixels(info)); 156 } while (!valid_for_raster_canvas(info) || !bitmap->tryAllocPixels(info));
157 } 157 }
158 158
159 static void make_g_bitmap(SkBitmap& bitmap) { 159 static void make_g_bitmap(SkBitmap& bitmap) {
160 rand_bitmap_for_canvas(&bitmap); 160 rand_bitmap_for_canvas(&bitmap);
161 161
162 SkCanvas canvas(bitmap); 162 SkCanvas canvas(bitmap);
163 canvas.clear(0x00000000); 163 canvas.clear(0x00000000);
164 SkPaint paint; 164 SkPaint paint;
165 paint.setAntiAlias(true); 165 paint.setAntiAlias(true);
166 paint.setColor(0xFF884422); 166 paint.setColor(0xFF884422);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } 475 }
476 476
477 private: 477 private:
478 typedef SkView INHERITED; 478 typedef SkView INHERITED;
479 }; 479 };
480 480
481 ////////////////////////////////////////////////////////////////////////////// 481 //////////////////////////////////////////////////////////////////////////////
482 482
483 static SkView* MyFactory() { return new ImageFilterFuzzView; } 483 static SkView* MyFactory() { return new ImageFilterFuzzView; }
484 static SkViewRegister reg(MyFactory); 484 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | samplecode/SampleUnpremul.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698