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 #include "gm.h" | 7 #include "gm.h" |
8 #include "SkGradientShader.h" | 8 #include "SkGradientShader.h" |
9 | 9 |
10 namespace skiagm { | 10 namespace skiagm { |
(...skipping 16 matching lines...) Expand all Loading... |
27 class ShaderBoundsGM : public GM { | 27 class ShaderBoundsGM : public GM { |
28 public: | 28 public: |
29 typedef SkShader* (*ShaderGenFunc)(SkScalar width, SkScalar height, | 29 typedef SkShader* (*ShaderGenFunc)(SkScalar width, SkScalar height, |
30 bool alternate, const SkMatrix& localMatr
ix); | 30 bool alternate, const SkMatrix& localMatr
ix); |
31 ShaderBoundsGM(ShaderGenFunc maker, const SkString& name) | 31 ShaderBoundsGM(ShaderGenFunc maker, const SkString& name) |
32 : fShaderMaker(maker), | 32 : fShaderMaker(maker), |
33 fName(name) { | 33 fName(name) { |
34 } | 34 } |
35 | 35 |
36 protected: | 36 protected: |
37 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 37 uint32_t onGetFlags() const SK_OVERRIDE { |
38 return kSkipTiled_Flag; | 38 return kSkipTiled_Flag; |
39 } | 39 } |
40 | 40 |
41 SkString onShortName() SK_OVERRIDE { | 41 SkString onShortName() SK_OVERRIDE { |
42 return fName; | 42 return fName; |
43 } | 43 } |
44 | 44 |
45 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(320, 240); } | 45 SkISize onISize() SK_OVERRIDE { return SkISize::Make(320, 240); } |
46 | 46 |
47 virtual SkMatrix onGetInitialTransform() const SK_OVERRIDE { | 47 SkMatrix onGetInitialTransform() const SK_OVERRIDE { |
48 SkMatrix result; | 48 SkMatrix result; |
49 SkScalar scale = 0.8f; | 49 SkScalar scale = 0.8f; |
50 result.setScale(scale, scale); | 50 result.setScale(scale, scale); |
51 result.postTranslate(SkIntToScalar(7), SkIntToScalar(23)); | 51 result.postTranslate(SkIntToScalar(7), SkIntToScalar(23)); |
52 return result; | 52 return result; |
53 } | 53 } |
54 | 54 |
55 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 55 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
56 // The PDF device has already clipped to the content area, but we | 56 // The PDF device has already clipped to the content area, but we |
57 // do it again here so that the raster and pdf results are consistent. | 57 // do it again here so that the raster and pdf results are consistent. |
58 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(320), | 58 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(320), |
59 SkIntToScalar(240))); | 59 SkIntToScalar(240))); |
60 | 60 |
61 SkMatrix canvasScale; | 61 SkMatrix canvasScale; |
62 SkScalar scale = 0.7f; | 62 SkScalar scale = 0.7f; |
63 canvasScale.setScale(scale, scale); | 63 canvasScale.setScale(scale, scale); |
64 canvas->concat(canvasScale); | 64 canvas->concat(canvasScale); |
65 | 65 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 }; | 101 }; |
102 | 102 |
103 /////////////////////////////////////////////////////////////////////////////// | 103 /////////////////////////////////////////////////////////////////////////////// |
104 | 104 |
105 static GM* MyFactory(void*) { | 105 static GM* MyFactory(void*) { |
106 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); | 106 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); |
107 } | 107 } |
108 static GMRegistry reg(MyFactory); | 108 static GMRegistry reg(MyFactory); |
109 | 109 |
110 } | 110 } |
OLD | NEW |