| 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 #include "gm.h" | 7 #include "gm.h" |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
| 10 #include "SkUnitMappers.h" | 10 #include "SkUnitMappers.h" |
| 11 | 11 |
| 12 namespace skiagm { | 12 namespace skiagm { |
| 13 | 13 |
| 14 static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { | 14 static void makebm(SkBitmap* bm, int w, int h) { |
| 15 bm->allocConfigPixels(config, w, h); | 15 bm->allocN32Pixels(w, h); |
| 16 bm->eraseColor(SK_ColorTRANSPARENT); | 16 bm->eraseColor(SK_ColorTRANSPARENT); |
| 17 | 17 |
| 18 SkCanvas canvas(*bm); | 18 SkCanvas canvas(*bm); |
| 19 SkScalar s = SkIntToScalar(SkMin32(w, h)); | 19 SkScalar s = SkIntToScalar(SkMin32(w, h)); |
| 20 static const SkPoint kPts0[] = { { 0, 0 }, { s, s } }; | 20 static const SkPoint kPts0[] = { { 0, 0 }, { s, s } }; |
| 21 static const SkPoint kPts1[] = { { s/2, 0 }, { s/2, s } }; | 21 static const SkPoint kPts1[] = { { s/2, 0 }, { s/2, s } }; |
| 22 static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; | 22 static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; |
| 23 static const SkColor kColors0[] = {0x80F00080, 0xF0F08000, 0x800080F0 }; | 23 static const SkColor kColors0[] = {0x80F00080, 0xF0F08000, 0x800080F0 }; |
| 24 static const SkColor kColors1[] = {0xF08000F0, 0x8080F000, 0xF000F080 }; | 24 static const SkColor kColors1[] = {0xF08000F0, 0x8080F000, 0xF000F080 }; |
| 25 | 25 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 SkISize onISize() { return make_isize(800, 1000); } | 62 SkISize onISize() { return make_isize(800, 1000); } |
| 63 | 63 |
| 64 virtual void onDraw(SkCanvas* canvas) { | 64 virtual void onDraw(SkCanvas* canvas) { |
| 65 static const char kText[] = "B"; | 65 static const char kText[] = "B"; |
| 66 static const int kTextLen = SK_ARRAY_COUNT(kText) - 1; | 66 static const int kTextLen = SK_ARRAY_COUNT(kText) - 1; |
| 67 static const int kPointSize = 300; | 67 static const int kPointSize = 300; |
| 68 | 68 |
| 69 static SkBitmap bmp; | 69 static SkBitmap bmp; |
| 70 if (bmp.isNull()) { | 70 if (bmp.isNull()) { |
| 71 makebm(&bmp, SkBitmap::kARGB_8888_Config, kPointSize / 4, kPointSize
/ 4); | 71 makebm(&bmp, kPointSize / 4, kPointSize / 4); |
| 72 } | 72 } |
| 73 | 73 |
| 74 SkPaint bmpPaint; | 74 SkPaint bmpPaint; |
| 75 bmpPaint.setAntiAlias(true); | 75 bmpPaint.setAntiAlias(true); |
| 76 bmpPaint.setFilterLevel(SkPaint::kLow_FilterLevel); | 76 bmpPaint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 77 bmpPaint.setAlpha(0x80); | 77 bmpPaint.setAlpha(0x80); |
| 78 canvas->drawBitmap(bmp, 5.f, 5.f, &bmpPaint); | 78 canvas->drawBitmap(bmp, 5.f, 5.f, &bmpPaint); |
| 79 | 79 |
| 80 SkPaint outlinePaint; | 80 SkPaint outlinePaint; |
| 81 outlinePaint.setAntiAlias(true); | 81 outlinePaint.setAntiAlias(true); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 typedef GM INHERITED; | 134 typedef GM INHERITED; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 /////////////////////////////////////////////////////////////////////////////// | 137 /////////////////////////////////////////////////////////////////////////////// |
| 138 | 138 |
| 139 #ifndef SK_BUILD_FOR_ANDROID | 139 #ifndef SK_BUILD_FOR_ANDROID |
| 140 static GM* MyFactory(void*) { return new ShaderText3GM; } | 140 static GM* MyFactory(void*) { return new ShaderText3GM; } |
| 141 static GMRegistry reg(MyFactory); | 141 static GMRegistry reg(MyFactory); |
| 142 #endif | 142 #endif |
| 143 } | 143 } |
| OLD | NEW |