| 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 "SkColor.h" | 9 #include "SkColor.h" |
| 10 #include "SkMatrixConvolutionImageFilter.h" | 10 #include "SkMatrixConvolutionImageFilter.h" |
| 11 #include "SkGradientShader.h" | 11 #include "SkGradientShader.h" |
| 12 | 12 |
| 13 namespace skiagm { | 13 namespace skiagm { |
| 14 | 14 |
| 15 class MatrixConvolutionGM : public GM { | 15 class MatrixConvolutionGM : public GM { |
| 16 public: | 16 public: |
| 17 MatrixConvolutionGM() : fInitialized(false) { | 17 MatrixConvolutionGM() : fInitialized(false) { |
| 18 this->setBGColor(0x00000000); | 18 this->setBGColor(0x00000000); |
| 19 } | 19 } |
| 20 | 20 |
| 21 protected: | 21 protected: |
| 22 virtual SkString onShortName() { | 22 virtual SkString onShortName() { |
| 23 return SkString("matrixconvolution"); | 23 return SkString("matrixconvolution"); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void make_bitmap() { | 26 void make_bitmap() { |
| 27 fBitmap.allocN32Pixels(80, 80); | 27 fBitmap.allocN32Pixels(80, 80); |
| 28 SkBitmapDevice device(fBitmap); | 28 SkCanvas canvas(fBitmap); |
| 29 SkCanvas canvas(&device); | |
| 30 canvas.clear(0x00000000); | 29 canvas.clear(0x00000000); |
| 31 SkPaint paint; | 30 SkPaint paint; |
| 32 paint.setAntiAlias(true); | 31 paint.setAntiAlias(true); |
| 33 paint.setColor(0xFFFFFFFF); | 32 paint.setColor(0xFFFFFFFF); |
| 34 paint.setTextSize(SkIntToScalar(180)); | 33 paint.setTextSize(SkIntToScalar(180)); |
| 35 SkPoint pts[2] = { SkPoint::Make(0, 0), | 34 SkPoint pts[2] = { SkPoint::Make(0, 0), |
| 36 SkPoint::Make(0, SkIntToScalar(80)) }; | 35 SkPoint::Make(0, SkIntToScalar(80)) }; |
| 37 SkColor colors[2] = { 0xFFFFFFFF, 0x40404040 }; | 36 SkColor colors[2] = { 0xFFFFFFFF, 0x40404040 }; |
| 38 SkScalar pos[2] = { 0, SkIntToScalar(80) }; | 37 SkScalar pos[2] = { 0, SkIntToScalar(80) }; |
| 39 paint.setShader(SkGradientShader::CreateLinear( | 38 paint.setShader(SkGradientShader::CreateLinear( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 SkBitmap fBitmap; | 106 SkBitmap fBitmap; |
| 108 bool fInitialized; | 107 bool fInitialized; |
| 109 }; | 108 }; |
| 110 | 109 |
| 111 ////////////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////////////// |
| 112 | 111 |
| 113 static GM* MyFactory(void*) { return new MatrixConvolutionGM; } | 112 static GM* MyFactory(void*) { return new MatrixConvolutionGM; } |
| 114 static GMRegistry reg(MyFactory); | 113 static GMRegistry reg(MyFactory); |
| 115 | 114 |
| 116 } | 115 } |
| OLD | NEW |