| 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 "gm.h" | 8 #include "gm.h" |
| 9 #include "SkPath.h" | 9 #include "SkPath.h" |
| 10 #include "SkRegion.h" | 10 #include "SkRegion.h" |
| 11 #include "SkShader.h" | 11 #include "SkShader.h" |
| 12 #include "SkUtils.h" | 12 #include "SkUtils.h" |
| 13 #include "SkColorPriv.h" | 13 #include "SkColorPriv.h" |
| 14 #include "SkColorFilter.h" | 14 #include "SkColorFilter.h" |
| 15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
| 16 #include "SkBlurMask.h" |
| 16 | 17 |
| 17 // effects | 18 // effects |
| 18 #include "SkGradientShader.h" | 19 #include "SkGradientShader.h" |
| 19 #include "SkUnitMappers.h" | 20 #include "SkUnitMappers.h" |
| 20 #include "SkBlurDrawLooper.h" | 21 #include "SkBlurDrawLooper.h" |
| 21 | 22 |
| 22 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { | 23 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { |
| 23 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); | 24 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); |
| 24 bm->eraseColor(SK_ColorTRANSPARENT); | 25 bm->eraseColor(SK_ColorTRANSPARENT); |
| 25 | 26 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 paint->setShader(shader)->unref(); | 49 paint->setShader(shader)->unref(); |
| 49 paint->setFilterLevel(filter_level); | 50 paint->setFilterLevel(filter_level); |
| 50 } | 51 } |
| 51 | 52 |
| 52 static const SkColorType gColorTypes[] = { | 53 static const SkColorType gColorTypes[] = { |
| 53 kN32_SkColorType, | 54 kN32_SkColorType, |
| 54 kRGB_565_SkColorType, | 55 kRGB_565_SkColorType, |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 class ScaledTilingGM : public skiagm::GM { | 58 class ScaledTilingGM : public skiagm::GM { |
| 58 SkBlurDrawLooper fLooper; | 59 SkAutoTUnref<SkBlurDrawLooper> fLooper; |
| 59 public: | 60 public: |
| 60 ScaledTilingGM(bool powerOfTwoSize) | 61 ScaledTilingGM(bool powerOfTwoSize) |
| 61 : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88
000000) | 62 : fLooper(SkBlurDrawLooper::Create(0x88000000, |
| 63 SkBlurMask::ConvertRadiusToSigma(
SkIntToScalar(1)), |
| 64 SkIntToScalar(2), SkIntToScalar(2
))) |
| 62 , fPowerOfTwoSize(powerOfTwoSize) { | 65 , fPowerOfTwoSize(powerOfTwoSize) { |
| 63 } | 66 } |
| 64 | 67 |
| 65 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; | 68 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; |
| 66 | 69 |
| 67 protected: | 70 protected: |
| 68 | 71 |
| 69 enum { | 72 enum { |
| 70 kPOTSize = 4, | 73 kPOTSize = 4, |
| 71 kNPOTSize = 3, | 74 kNPOTSize = 3, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 113 |
| 111 SkScalar y = SkIntToScalar(24); | 114 SkScalar y = SkIntToScalar(24); |
| 112 SkScalar x = SkIntToScalar(10)/scale; | 115 SkScalar x = SkIntToScalar(10)/scale; |
| 113 | 116 |
| 114 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { | 117 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { |
| 115 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { | 118 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { |
| 116 SkPaint p; | 119 SkPaint p; |
| 117 SkString str; | 120 SkString str; |
| 118 p.setAntiAlias(true); | 121 p.setAntiAlias(true); |
| 119 p.setDither(true); | 122 p.setDither(true); |
| 120 p.setLooper(&fLooper); | 123 p.setLooper(fLooper); |
| 121 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); | 124 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); |
| 122 | 125 |
| 123 p.setTextAlign(SkPaint::kCenter_Align); | 126 p.setTextAlign(SkPaint::kCenter_Align); |
| 124 canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2
), y, p); | 127 canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2
), y, p); |
| 125 | 128 |
| 126 x += r.width() * 4 / 3; | 129 x += r.width() * 4 / 3; |
| 127 } | 130 } |
| 128 } | 131 } |
| 129 | 132 |
| 130 y = SkIntToScalar(40) / scale; | 133 y = SkIntToScalar(40) / scale; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 150 canvas->drawRect(r, paint); | 153 canvas->drawRect(r, paint); |
| 151 canvas->restore(); | 154 canvas->restore(); |
| 152 | 155 |
| 153 x += r.width() * 4 / 3; | 156 x += r.width() * 4 / 3; |
| 154 } | 157 } |
| 155 } | 158 } |
| 156 { | 159 { |
| 157 SkPaint p; | 160 SkPaint p; |
| 158 SkString str; | 161 SkString str; |
| 159 p.setAntiAlias(true); | 162 p.setAntiAlias(true); |
| 160 p.setLooper(&fLooper); | 163 p.setLooper(fLooper); |
| 161 str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]); | 164 str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]); |
| 162 canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y
+ r.height() * 2 / 3), p); | 165 canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y
+ r.height() * 2 / 3), p); |
| 163 } | 166 } |
| 164 | 167 |
| 165 y += r.height() * 4 / 3; | 168 y += r.height() * 4 / 3; |
| 166 } | 169 } |
| 167 } | 170 } |
| 168 } | 171 } |
| 169 | 172 |
| 170 private: | 173 private: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 private: | 275 private: |
| 273 typedef skiagm::GM INHERITED; | 276 typedef skiagm::GM INHERITED; |
| 274 }; | 277 }; |
| 275 | 278 |
| 276 ////////////////////////////////////////////////////////////////////////////// | 279 ////////////////////////////////////////////////////////////////////////////// |
| 277 | 280 |
| 278 DEF_GM( return new ScaledTilingGM(true); ) | 281 DEF_GM( return new ScaledTilingGM(true); ) |
| 279 DEF_GM( return new ScaledTilingGM(false); ) | 282 DEF_GM( return new ScaledTilingGM(false); ) |
| 280 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) | 283 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) |
| 281 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) | 284 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) |
| OLD | NEW |