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 #ifndef Gr1DKernelEffect_DEFINED | 8 #ifndef Gr1DKernelEffect_DEFINED |
9 #define Gr1DKernelEffect_DEFINED | 9 #define Gr1DKernelEffect_DEFINED |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 */ | 21 */ |
22 | 22 |
23 class Gr1DKernelEffect : public GrSingleTextureEffect { | 23 class Gr1DKernelEffect : public GrSingleTextureEffect { |
24 | 24 |
25 public: | 25 public: |
26 enum Direction { | 26 enum Direction { |
27 kX_Direction, | 27 kX_Direction, |
28 kY_Direction, | 28 kY_Direction, |
29 }; | 29 }; |
30 | 30 |
| 31 // Constructor using default nearest-neighbor sampling for the input texture |
| 32 // filter mode. |
31 Gr1DKernelEffect(GrTexture* texture, | 33 Gr1DKernelEffect(GrTexture* texture, |
32 Direction direction, | 34 Direction direction, |
33 int radius) | 35 int radius) |
34 : INHERITED(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture)
) | 36 : INHERITED(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture)
) |
35 , fDirection(direction) | 37 , fDirection(direction) |
36 , fRadius(radius) {} | 38 , fRadius(radius) {} |
37 | 39 |
| 40 Gr1DKernelEffect(GrTexture* texture, |
| 41 Direction direction, |
| 42 int radius, |
| 43 GrTextureParams::FilterMode filterMode) |
| 44 : INHERITED(texture, |
| 45 GrCoordTransform::MakeDivByTextureWHMatrix(texture), |
| 46 filterMode) |
| 47 , fDirection(direction) |
| 48 , fRadius(radius) {} |
| 49 |
38 virtual ~Gr1DKernelEffect() {}; | 50 virtual ~Gr1DKernelEffect() {}; |
39 | 51 |
40 static int WidthFromRadius(int radius) { return 2 * radius + 1; } | 52 static int WidthFromRadius(int radius) { return 2 * radius + 1; } |
41 | 53 |
42 int radius() const { return fRadius; } | 54 int radius() const { return fRadius; } |
43 int width() const { return WidthFromRadius(fRadius); } | 55 int width() const { return WidthFromRadius(fRadius); } |
44 Direction direction() const { return fDirection; } | 56 Direction direction() const { return fDirection; } |
45 | 57 |
46 SkString dumpInfo() const override { | 58 SkString dumpInfo() const override { |
47 SkString str; | 59 SkString str; |
48 str.appendf("Direction: %s, Radius: %d ", kX_Direction == fDirection ? "
X" : "Y", fRadius); | 60 str.appendf("Direction: %s, Radius: %d ", kX_Direction == fDirection ? "
X" : "Y", fRadius); |
49 str.append(INHERITED::dumpInfo()); | 61 str.append(INHERITED::dumpInfo()); |
50 return str; | 62 return str; |
51 } | 63 } |
52 | 64 |
53 private: | 65 private: |
54 | 66 |
55 Direction fDirection; | 67 Direction fDirection; |
56 int fRadius; | 68 int fRadius; |
57 | 69 |
58 typedef GrSingleTextureEffect INHERITED; | 70 typedef GrSingleTextureEffect INHERITED; |
59 }; | 71 }; |
60 | 72 |
61 #endif | 73 #endif |
OLD | NEW |