| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
| 10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 virtual void onDraw(SkCanvas* canvas) { | 38 virtual void onDraw(SkCanvas* canvas) { |
| 39 SkPaint paint; | 39 SkPaint paint; |
| 40 paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref
(); | 40 paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref
(); |
| 41 canvas->saveLayer(NULL, &paint); | 41 canvas->saveLayer(NULL, &paint); |
| 42 const char* str = "The quick brown fox jumped over the lazy dog."; | 42 const char* str = "The quick brown fox jumped over the lazy dog."; |
| 43 | 43 |
| 44 SkRandom rand; | 44 SkRandom rand; |
| 45 SkPaint textPaint; | 45 SkPaint textPaint; |
| 46 textPaint.setAntiAlias(true); | 46 textPaint.setAntiAlias(true); |
| 47 sk_tool_utils::set_portable_typeface(&textPaint); |
| 47 for (int i = 0; i < 25; ++i) { | 48 for (int i = 0; i < 25; ++i) { |
| 48 int x = rand.nextULessThan(WIDTH); | 49 int x = rand.nextULessThan(WIDTH); |
| 49 int y = rand.nextULessThan(HEIGHT); | 50 int y = rand.nextULessThan(HEIGHT); |
| 50 textPaint.setColor(rand.nextBits(24) | 0xFF000000); | 51 textPaint.setColor(rand.nextBits(24) | 0xFF000000); |
| 51 textPaint.setTextSize(rand.nextRangeScalar(0, 300)); | 52 textPaint.setTextSize(rand.nextRangeScalar(0, 300)); |
| 52 canvas->drawText(str, strlen(str), SkIntToScalar(x), | 53 canvas->drawText(str, strlen(str), SkIntToScalar(x), |
| 53 SkIntToScalar(y), textPaint); | 54 SkIntToScalar(y), textPaint); |
| 54 } | 55 } |
| 55 canvas->restore(); | 56 canvas->restore(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 SkScalar fSigmaX; | 60 SkScalar fSigmaX; |
| 60 SkScalar fSigmaY; | 61 SkScalar fSigmaY; |
| 61 SkString fName; | 62 SkString fName; |
| 62 | 63 |
| 63 typedef GM INHERITED; | 64 typedef GM INHERITED; |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 ////////////////////////////////////////////////////////////////////////////// | 67 ////////////////////////////////////////////////////////////////////////////// |
| 67 | 68 |
| 68 static GM* MyFactory1(void*) { return new ImageBlurGM(24.0f, 0.0f, ""); } | 69 static GM* MyFactory1(void*) { return new ImageBlurGM(24.0f, 0.0f, ""); } |
| 69 static GMRegistry reg1(MyFactory1); | 70 static GMRegistry reg1(MyFactory1); |
| 70 | 71 |
| 71 static GM* MyFactory2(void*) { return new ImageBlurGM(80.0f, 80.0f, "_large"); } | 72 static GM* MyFactory2(void*) { return new ImageBlurGM(80.0f, 80.0f, "_large"); } |
| 72 static GMRegistry reg2(MyFactory2); | 73 static GMRegistry reg2(MyFactory2); |
| 73 | 74 |
| 74 } | 75 } |
| OLD | NEW |