| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 paint->setShader(shader)->unref(); | 48 paint->setShader(shader)->unref(); |
| 49 paint->setFilterLevel(filter_level); | 49 paint->setFilterLevel(filter_level); |
| 50 } | 50 } |
| 51 | 51 |
| 52 static const SkColorType gColorTypes[] = { | 52 static const SkColorType gColorTypes[] = { |
| 53 kPMColor_SkColorType, | 53 kPMColor_SkColorType, |
| 54 kRGB_565_SkColorType, | 54 kRGB_565_SkColorType, |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class ScaledTilingGM : public skiagm::GM { | 57 class ScaledTilingGM : public skiagm::GM { |
| 58 SkBlurDrawLooper fLooper; | 58 SkAutoTUnref<SkBlurDrawLooper> fLooper; |
| 59 public: | 59 public: |
| 60 ScaledTilingGM(bool powerOfTwoSize) | 60 ScaledTilingGM(bool powerOfTwoSize) |
| 61 : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88
000000) | 61 : fLooper(SkBlurDrawLooper::Create(SkIntToScalar(1), SkIntToScalar(2
), |
| 62 SkIntToScalar(2), 0x88000000)) |
| 62 , fPowerOfTwoSize(powerOfTwoSize) { | 63 , fPowerOfTwoSize(powerOfTwoSize) { |
| 63 } | 64 } |
| 64 | 65 |
| 65 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; | 66 SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; |
| 66 | 67 |
| 67 protected: | 68 protected: |
| 68 | 69 |
| 69 enum { | 70 enum { |
| 70 kPOTSize = 4, | 71 kPOTSize = 4, |
| 71 kNPOTSize = 3, | 72 kNPOTSize = 3, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 111 |
| 111 SkScalar y = SkIntToScalar(24); | 112 SkScalar y = SkIntToScalar(24); |
| 112 SkScalar x = SkIntToScalar(10)/scale; | 113 SkScalar x = SkIntToScalar(10)/scale; |
| 113 | 114 |
| 114 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { | 115 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { |
| 115 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { | 116 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { |
| 116 SkPaint p; | 117 SkPaint p; |
| 117 SkString str; | 118 SkString str; |
| 118 p.setAntiAlias(true); | 119 p.setAntiAlias(true); |
| 119 p.setDither(true); | 120 p.setDither(true); |
| 120 p.setLooper(&fLooper); | 121 p.setLooper(fLooper); |
| 121 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); | 122 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); |
| 122 | 123 |
| 123 p.setTextAlign(SkPaint::kCenter_Align); | 124 p.setTextAlign(SkPaint::kCenter_Align); |
| 124 canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2
), y, p); | 125 canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2
), y, p); |
| 125 | 126 |
| 126 x += r.width() * 4 / 3; | 127 x += r.width() * 4 / 3; |
| 127 } | 128 } |
| 128 } | 129 } |
| 129 | 130 |
| 130 y = SkIntToScalar(40) / scale; | 131 y = SkIntToScalar(40) / scale; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 150 canvas->drawRect(r, paint); | 151 canvas->drawRect(r, paint); |
| 151 canvas->restore(); | 152 canvas->restore(); |
| 152 | 153 |
| 153 x += r.width() * 4 / 3; | 154 x += r.width() * 4 / 3; |
| 154 } | 155 } |
| 155 } | 156 } |
| 156 { | 157 { |
| 157 SkPaint p; | 158 SkPaint p; |
| 158 SkString str; | 159 SkString str; |
| 159 p.setAntiAlias(true); | 160 p.setAntiAlias(true); |
| 160 p.setLooper(&fLooper); | 161 p.setLooper(fLooper); |
| 161 str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]); | 162 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); | 163 canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y
+ r.height() * 2 / 3), p); |
| 163 } | 164 } |
| 164 | 165 |
| 165 y += r.height() * 4 / 3; | 166 y += r.height() * 4 / 3; |
| 166 } | 167 } |
| 167 } | 168 } |
| 168 } | 169 } |
| 169 | 170 |
| 170 private: | 171 private: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 private: | 273 private: |
| 273 typedef skiagm::GM INHERITED; | 274 typedef skiagm::GM INHERITED; |
| 274 }; | 275 }; |
| 275 | 276 |
| 276 ////////////////////////////////////////////////////////////////////////////// | 277 ////////////////////////////////////////////////////////////////////////////// |
| 277 | 278 |
| 278 DEF_GM( return new ScaledTilingGM(true); ) | 279 DEF_GM( return new ScaledTilingGM(true); ) |
| 279 DEF_GM( return new ScaledTilingGM(false); ) | 280 DEF_GM( return new ScaledTilingGM(false); ) |
| 280 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) | 281 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) |
| 281 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) | 282 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) |
| OLD | NEW |