| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| 11 #include "SkPath.h" | 11 #include "SkPath.h" |
| 12 | 12 |
| 13 static void make_bm(SkBitmap* bm, int width, int height, SkColor colors[2]) { | 13 static void make_bm(SkBitmap* bm, int width, int height, SkColor colors[2]) { |
| 14 bm->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 14 bm->allocN32Pixels(width, height); |
| 15 bm->allocPixels(); | |
| 16 SkCanvas canvas(*bm); | 15 SkCanvas canvas(*bm); |
| 17 SkPoint center = {SkIntToScalar(width)/2, SkIntToScalar(height)/2}; | 16 SkPoint center = {SkIntToScalar(width)/2, SkIntToScalar(height)/2}; |
| 18 SkScalar radius = 40; | 17 SkScalar radius = 40; |
| 19 SkShader* shader = SkGradientShader::CreateRadial(center, radius, colors, NU
LL, 2, | 18 SkShader* shader = SkGradientShader::CreateRadial(center, radius, colors, NU
LL, 2, |
| 20 SkShader::kMirror_TileMode
); | 19 SkShader::kMirror_TileMode
); |
| 21 SkPaint paint; | 20 SkPaint paint; |
| 22 paint.setShader(shader)->unref(); | 21 paint.setShader(shader)->unref(); |
| 23 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 22 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 24 canvas.drawPaint(paint); | 23 canvas.drawPaint(paint); |
| 25 bm->setImmutable(); | 24 bm->setImmutable(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 typedef skiagm::GM INHERITED; | 117 typedef skiagm::GM INHERITED; |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 ////////////////////////////////////////////////////////////////////////////// | 120 ////////////////////////////////////////////////////////////////////////////// |
| 122 | 121 |
| 123 // This GM allocates more memory than Android devices are capable of fulfilling. | 122 // This GM allocates more memory than Android devices are capable of fulfilling. |
| 124 #ifndef SK_BUILD_FOR_ANDROID | 123 #ifndef SK_BUILD_FOR_ANDROID |
| 125 static skiagm::GM* MyFactory(void*) { return new VeryLargeBitmapGM; } | 124 static skiagm::GM* MyFactory(void*) { return new VeryLargeBitmapGM; } |
| 126 static skiagm::GMRegistry reg(MyFactory); | 125 static skiagm::GMRegistry reg(MyFactory); |
| 127 #endif | 126 #endif |
| OLD | NEW |