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 "SkLightingImageFilter.h" | 9 #include "SkLightingImageFilter.h" |
10 #include "SkOffsetImageFilter.h" | 10 #include "SkOffsetImageFilter.h" |
| 11 #include "SkPoint3.h" |
11 | 12 |
12 #define WIDTH 330 | 13 #define WIDTH 330 |
13 #define HEIGHT 660 | 14 #define HEIGHT 660 |
14 | 15 |
15 namespace skiagm { | 16 namespace skiagm { |
16 | 17 |
17 class ImageLightingGM : public GM { | 18 class ImageLightingGM : public GM { |
18 public: | 19 public: |
19 ImageLightingGM() : fInitialized(false) { | 20 ImageLightingGM() : fInitialized(false) { |
20 this->setBGColor(0xFF000000); | 21 this->setBGColor(0xFF000000); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 checkPaint.setColor(0xFF202020); | 63 checkPaint.setColor(0xFF202020); |
63 for (int y = 0; y < HEIGHT; y += 16) { | 64 for (int y = 0; y < HEIGHT; y += 16) { |
64 for (int x = 0; x < WIDTH; x += 16) { | 65 for (int x = 0; x < WIDTH; x += 16) { |
65 canvas->save(); | 66 canvas->save(); |
66 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 67 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
67 canvas->drawRect(SkRect::MakeXYWH(8, 0, 8, 8), checkPaint); | 68 canvas->drawRect(SkRect::MakeXYWH(8, 0, 8, 8), checkPaint); |
68 canvas->drawRect(SkRect::MakeXYWH(0, 8, 8, 8), checkPaint); | 69 canvas->drawRect(SkRect::MakeXYWH(0, 8, 8, 8), checkPaint); |
69 canvas->restore(); | 70 canvas->restore(); |
70 } | 71 } |
71 } | 72 } |
72 SkPoint3 pointLocation(0, 0, SkIntToScalar(10)); | 73 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); |
73 SkScalar azimuthRad = SkDegreesToRadians(SkIntToScalar(225)); | 74 SkScalar azimuthRad = SkDegreesToRadians(SkIntToScalar(225)); |
74 SkScalar elevationRad = SkDegreesToRadians(SkIntToScalar(5)); | 75 SkScalar elevationRad = SkDegreesToRadians(SkIntToScalar(5)); |
75 SkPoint3 distantDirection(SkScalarMul(SkScalarCos(azimuthRad), SkScalarC
os(elevationRad)), | 76 SkPoint3 distantDirection = SkPoint3::Make(SkScalarMul(SkScalarCos(azimu
thRad), |
76 SkScalarMul(SkScalarSin(azimuthRad), SkScalarC
os(elevationRad)), | 77 SkScalarCos(eleva
tionRad)), |
77 SkScalarSin(elevationRad)); | 78 SkScalarMul(SkScalarSin(azimu
thRad), |
78 SkPoint3 spotLocation(SkIntToScalar(-10), SkIntToScalar(-10), SkIntToSca
lar(20)); | 79 SkScalarCos(eleva
tionRad)), |
79 SkPoint3 spotTarget(SkIntToScalar(40), SkIntToScalar(40), 0); | 80 SkScalarSin(elevationRad)); |
| 81 SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10), |
| 82 SkIntToScalar(-10), |
| 83 SkIntToScalar(20)); |
| 84 SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40
), 0); |
80 SkScalar spotExponent = SK_Scalar1; | 85 SkScalar spotExponent = SK_Scalar1; |
81 SkScalar cutoffAngle = SkIntToScalar(15); | 86 SkScalar cutoffAngle = SkIntToScalar(15); |
82 SkScalar kd = SkIntToScalar(2); | 87 SkScalar kd = SkIntToScalar(2); |
83 SkScalar ks = SkIntToScalar(1); | 88 SkScalar ks = SkIntToScalar(1); |
84 SkScalar shininess = SkIntToScalar(8); | 89 SkScalar shininess = SkIntToScalar(8); |
85 SkScalar surfaceScale = SkIntToScalar(1); | 90 SkScalar surfaceScale = SkIntToScalar(1); |
86 SkColor white(0xFFFFFFFF); | 91 SkColor white(0xFFFFFFFF); |
87 SkPaint paint; | 92 SkPaint paint; |
88 | 93 |
89 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); | 94 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 SkBitmap fBitmap; | 167 SkBitmap fBitmap; |
163 bool fInitialized; | 168 bool fInitialized; |
164 }; | 169 }; |
165 | 170 |
166 ////////////////////////////////////////////////////////////////////////////// | 171 ////////////////////////////////////////////////////////////////////////////// |
167 | 172 |
168 static GM* MyFactory(void*) { return new ImageLightingGM; } | 173 static GM* MyFactory(void*) { return new ImageLightingGM; } |
169 static GMRegistry reg(MyFactory); | 174 static GMRegistry reg(MyFactory); |
170 | 175 |
171 } | 176 } |
OLD | NEW |