| 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, 0 }, { 0, s } }; | 21 static const SkPoint kPts1[] = { { s, 0 }, { 0, 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[] = {0x40FF00FF, 0xF0FFFF00, 0x4000FFFF }; | 23 static const SkColor kColors0[] = {0x40FF00FF, 0xF0FFFF00, 0x4000FFFF }; |
| 24 static const SkColor kColors1[] = {0xF0FF00FF, 0x80FFFF00, 0xF000FFFF }; | 24 static const SkColor kColors1[] = {0xF0FF00FF, 0x80FFFF00, 0xF000FFFF }; |
| 25 | 25 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 localMatrices.top().fLabel = "Scale"; | 85 localMatrices.top().fLabel = "Scale"; |
| 86 localMatrices.append()->fMatrix.setRotate(45.f); | 86 localMatrices.append()->fMatrix.setRotate(45.f); |
| 87 localMatrices.top().fLabel = "Rotate"; | 87 localMatrices.top().fLabel = "Rotate"; |
| 88 localMatrices.append()->fMatrix.reset(); | 88 localMatrices.append()->fMatrix.reset(); |
| 89 localMatrices.top().fMatrix.setPerspX(-0.007f); | 89 localMatrices.top().fMatrix.setPerspX(-0.007f); |
| 90 localMatrices.top().fMatrix.setPerspY(+0.008f); | 90 localMatrices.top().fMatrix.setPerspY(+0.008f); |
| 91 localMatrices.top().fLabel = "Persp"; | 91 localMatrices.top().fLabel = "Persp"; |
| 92 | 92 |
| 93 static SkBitmap bmp; | 93 static SkBitmap bmp; |
| 94 if (bmp.isNull()) { | 94 if (bmp.isNull()) { |
| 95 makebm(&bmp, SkBitmap::kARGB_8888_Config, kPointSize / 2, kPointSize
/ 2); | 95 makebm(&bmp, kPointSize / 2, kPointSize / 2); |
| 96 } | 96 } |
| 97 | 97 |
| 98 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp, | 98 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp, |
| 99 SkShader::kMi
rror_TileMode, | 99 SkShader::kMi
rror_TileMode, |
| 100 SkShader::kRe
peat_TileMode)); | 100 SkShader::kRe
peat_TileMode)); |
| 101 SkPaint fillPaint; | 101 SkPaint fillPaint; |
| 102 fillPaint.setAntiAlias(true); | 102 fillPaint.setAntiAlias(true); |
| 103 fillPaint.setTextSize(SkIntToScalar(kPointSize)); | 103 fillPaint.setTextSize(SkIntToScalar(kPointSize)); |
| 104 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); | 104 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 105 fillPaint.setShader(shader); | 105 fillPaint.setShader(shader); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 typedef GM INHERITED; | 212 typedef GM INHERITED; |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 /////////////////////////////////////////////////////////////////////////////// | 215 /////////////////////////////////////////////////////////////////////////////// |
| 216 | 216 |
| 217 #ifndef SK_BUILD_FOR_ANDROID | 217 #ifndef SK_BUILD_FOR_ANDROID |
| 218 static GM* MyFactory(void*) { return new ShaderText2GM; } | 218 static GM* MyFactory(void*) { return new ShaderText2GM; } |
| 219 static GMRegistry reg(MyFactory); | 219 static GMRegistry reg(MyFactory); |
| 220 #endif | 220 #endif |
| 221 } | 221 } |
| OLD | NEW |