| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkColor.h" | 9 #include "SkColor.h" |
| 10 #include "SkBicubicImageFilter.h" | 10 #include "SkBicubicImageFilter.h" |
| 11 | 11 |
| 12 namespace skiagm { | 12 namespace skiagm { |
| 13 | 13 |
| 14 class BicubicGM : public GM { | 14 class BicubicGM : public GM { |
| 15 public: | 15 public: |
| 16 BicubicGM() : fInitialized(false) { | 16 BicubicGM() : fInitialized(false) { |
| 17 this->setBGColor(0x00000000); | 17 this->setBGColor(0x00000000); |
| 18 } | 18 } |
| 19 | 19 |
| 20 protected: | 20 protected: |
| 21 virtual SkString onShortName() { | 21 virtual SkString onShortName() { |
| 22 return SkString("bicubicfilter"); | 22 return SkString("bicubicfilter"); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void make_checkerboard(int width, int height) { | 25 void make_checkerboard(int width, int height) { |
| 26 SkASSERT(width % 2 == 0); | 26 SkASSERT(width % 2 == 0); |
| 27 SkASSERT(height % 2 == 0); | 27 SkASSERT(height % 2 == 0); |
| 28 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 28 fCheckerboard.allocN32Pixels(width, height); |
| 29 fCheckerboard.allocPixels(); | |
| 30 SkAutoLockPixels lock(fCheckerboard); | |
| 31 for (int y = 0; y < height; y += 2) { | 29 for (int y = 0; y < height; y += 2) { |
| 32 SkPMColor* s = fCheckerboard.getAddr32(0, y); | 30 SkPMColor* s = fCheckerboard.getAddr32(0, y); |
| 33 for (int x = 0; x < width; x += 2) { | 31 for (int x = 0; x < width; x += 2) { |
| 34 *s++ = 0xFFFFFFFF; | 32 *s++ = 0xFFFFFFFF; |
| 35 *s++ = 0xFF000000; | 33 *s++ = 0xFF000000; |
| 36 } | 34 } |
| 37 s = fCheckerboard.getAddr32(0, y + 1); | 35 s = fCheckerboard.getAddr32(0, y + 1); |
| 38 for (int x = 0; x < width; x += 2) { | 36 for (int x = 0; x < width; x += 2) { |
| 39 *s++ = 0xFF000000; | 37 *s++ = 0xFF000000; |
| 40 *s++ = 0xFFFFFFFF; | 38 *s++ = 0xFFFFFFFF; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 SkBitmap fCheckerboard; | 73 SkBitmap fCheckerboard; |
| 76 bool fInitialized; | 74 bool fInitialized; |
| 77 }; | 75 }; |
| 78 | 76 |
| 79 ////////////////////////////////////////////////////////////////////////////// | 77 ////////////////////////////////////////////////////////////////////////////// |
| 80 | 78 |
| 81 static GM* MyFactory(void*) { return new BicubicGM; } | 79 static GM* MyFactory(void*) { return new BicubicGM; } |
| 82 static GMRegistry reg(MyFactory); | 80 static GMRegistry reg(MyFactory); |
| 83 | 81 |
| 84 } | 82 } |
| OLD | NEW |