| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| 11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 | 13 |
| 14 namespace skiagm { | 14 namespace skiagm { |
| 15 | 15 |
| 16 static void draw_bm(SkBitmap* bm) { | 16 static void draw_bm(SkBitmap* bm) { |
| 17 SkPaint bluePaint; | 17 SkPaint bluePaint; |
| 18 bluePaint.setColor(SK_ColorBLUE); | 18 bluePaint.setColor(SK_ColorBLUE); |
| 19 | 19 |
| 20 bm->setConfig(SkBitmap::kARGB_8888_Config, 20, 20); | 20 bm->allocN32Pixels(20, 20); |
| 21 bm->allocPixels(); | |
| 22 bm->eraseColor(SK_ColorRED); | 21 bm->eraseColor(SK_ColorRED); |
| 23 | 22 |
| 24 SkCanvas canvas(*bm); | 23 SkCanvas canvas(*bm); |
| 25 canvas.drawCircle(10, 10, 5, bluePaint); | 24 canvas.drawCircle(10, 10, 5, bluePaint); |
| 26 } | 25 } |
| 27 | 26 |
| 28 static void draw_mask(SkBitmap* bm) { | 27 static void draw_mask(SkBitmap* bm) { |
| 29 SkPaint circlePaint; | 28 SkPaint circlePaint; |
| 30 circlePaint.setColor(SK_ColorBLACK); | 29 circlePaint.setColor(SK_ColorBLACK); |
| 31 | 30 |
| 32 bm->setConfig(SkBitmap::kA8_Config, 20, 20); | 31 bm->allocConfigPixels(SkBitmap::kA8_Config, 20, 20); |
| 33 bm->allocPixels(); | |
| 34 bm->eraseColor(SK_ColorTRANSPARENT); | 32 bm->eraseColor(SK_ColorTRANSPARENT); |
| 35 | 33 |
| 36 SkCanvas canvas(*bm); | 34 SkCanvas canvas(*bm); |
| 37 canvas.drawCircle(10, 10, 10, circlePaint); | 35 canvas.drawCircle(10, 10, 10, circlePaint); |
| 38 } | 36 } |
| 39 | 37 |
| 40 class BitmapShaderGM : public GM { | 38 class BitmapShaderGM : public GM { |
| 41 public: | 39 public: |
| 42 | 40 |
| 43 BitmapShaderGM() { | 41 BitmapShaderGM() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 92 |
| 95 typedef GM INHERITED; | 93 typedef GM INHERITED; |
| 96 }; | 94 }; |
| 97 | 95 |
| 98 ////////////////////////////////////////////////////////////////////////////// | 96 ////////////////////////////////////////////////////////////////////////////// |
| 99 | 97 |
| 100 static GM* MyFactory(void*) { return new BitmapShaderGM; } | 98 static GM* MyFactory(void*) { return new BitmapShaderGM; } |
| 101 static GMRegistry reg(MyFactory); | 99 static GMRegistry reg(MyFactory); |
| 102 | 100 |
| 103 } | 101 } |
| OLD | NEW |