| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkView.h" | 9 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
| 12 #include "SkPath.h" | 12 #include "SkPath.h" |
| 13 #include "SkRegion.h" | 13 #include "SkRegion.h" |
| 14 #include "SkShader.h" | 14 #include "SkShader.h" |
| 15 #include "SkUtils.h" | 15 #include "SkUtils.h" |
| 16 #include "SkColorPriv.h" | 16 #include "SkColorPriv.h" |
| 17 #include "SkColorFilter.h" | 17 #include "SkColorFilter.h" |
| 18 #include "SkPicture.h" | 18 #include "SkPicture.h" |
| 19 #include "SkTypeface.h" | 19 #include "SkTypeface.h" |
| 20 | 20 |
| 21 // effects | 21 // effects |
| 22 #include "SkGradientShader.h" | 22 #include "SkGradientShader.h" |
| 23 #include "SkUnitMappers.h" | 23 #include "SkUnitMappers.h" |
| 24 #include "SkBlurMask.h" |
| 24 #include "SkBlurDrawLooper.h" | 25 #include "SkBlurDrawLooper.h" |
| 25 | 26 |
| 26 static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { | 27 static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { |
| 27 bm->setConfig(config, w, h); | 28 bm->setConfig(config, w, h); |
| 28 bm->allocPixels(); | 29 bm->allocPixels(); |
| 29 bm->eraseColor(SK_ColorTRANSPARENT); | 30 bm->eraseColor(SK_ColorTRANSPARENT); |
| 30 | 31 |
| 31 SkCanvas canvas(*bm); | 32 SkCanvas canvas(*bm); |
| 32 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } }; | 33 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } }; |
| 33 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; | 34 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 59 SkBitmap::kRGB_565_Config, | 60 SkBitmap::kRGB_565_Config, |
| 60 }; | 61 }; |
| 61 static const int gWidth = 32; | 62 static const int gWidth = 32; |
| 62 static const int gHeight = 32; | 63 static const int gHeight = 32; |
| 63 | 64 |
| 64 class TilingView : public SampleView { | 65 class TilingView : public SampleView { |
| 65 SkPicture* fTextPicture; | 66 SkPicture* fTextPicture; |
| 66 SkBlurDrawLooper fLooper; | 67 SkBlurDrawLooper fLooper; |
| 67 public: | 68 public: |
| 68 TilingView() | 69 TilingView() |
| 69 : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), | 70 : fLooper(0x88000000, |
| 70 0x88000000) { | 71 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)), |
| 72 SkIntToScalar(2), SkIntToScalar(2)) { |
| 71 fTextPicture = new SkPicture(); | 73 fTextPicture = new SkPicture(); |
| 72 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { | 74 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { |
| 73 makebm(&fTexture[i], gConfigs[i], gWidth, gHeight); | 75 makebm(&fTexture[i], gConfigs[i], gWidth, gHeight); |
| 74 } | 76 } |
| 75 } | 77 } |
| 76 | 78 |
| 77 ~TilingView() { | 79 ~TilingView() { |
| 78 fTextPicture->unref(); | 80 fTextPicture->unref(); |
| 79 } | 81 } |
| 80 | 82 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 165 } |
| 164 | 166 |
| 165 private: | 167 private: |
| 166 typedef SampleView INHERITED; | 168 typedef SampleView INHERITED; |
| 167 }; | 169 }; |
| 168 | 170 |
| 169 ////////////////////////////////////////////////////////////////////////////// | 171 ////////////////////////////////////////////////////////////////////////////// |
| 170 | 172 |
| 171 static SkView* MyFactory() { return new TilingView; } | 173 static SkView* MyFactory() { return new TilingView; } |
| 172 static SkViewRegister reg(MyFactory); | 174 static SkViewRegister reg(MyFactory); |
| OLD | NEW |