OLD | NEW |
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 Loading... |
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 Loading... |
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); |
OLD | NEW |