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 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 SkPoint3 spotTarget(SkIntToScalar(40), SkIntToScalar(40), 0); | 78 SkPoint3 spotTarget(SkIntToScalar(40), SkIntToScalar(40), 0); |
79 SkScalar spotExponent = SK_Scalar1; | 79 SkScalar spotExponent = SK_Scalar1; |
80 SkScalar cutoffAngle = SkIntToScalar(15); | 80 SkScalar cutoffAngle = SkIntToScalar(15); |
81 SkScalar kd = SkIntToScalar(2); | 81 SkScalar kd = SkIntToScalar(2); |
82 SkScalar ks = SkIntToScalar(1); | 82 SkScalar ks = SkIntToScalar(1); |
83 SkScalar shininess = SkIntToScalar(8); | 83 SkScalar shininess = SkIntToScalar(8); |
84 SkScalar surfaceScale = SkIntToScalar(1); | 84 SkScalar surfaceScale = SkIntToScalar(1); |
85 SkColor white(0xFFFFFFFF); | 85 SkColor white(0xFFFFFFFF); |
86 SkPaint paint; | 86 SkPaint paint; |
87 | 87 |
| 88 #ifdef SK_CROP_RECT_IS_INT |
88 SkIRect cropRect = SkIRect::MakeXYWH(20, 10, 60, 65); | 89 SkIRect cropRect = SkIRect::MakeXYWH(20, 10, 60, 65); |
| 90 #else |
| 91 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); |
| 92 #endif |
89 | 93 |
90 int y = 0; | 94 int y = 0; |
91 for (int i = 0; i < 2; i++) { | 95 for (int i = 0; i < 2; i++) { |
92 const SkIRect* cr = (i == 0) ? NULL : &cropRect; | 96 const SkImageFilter::CropRect* cr = (i == 0) ? NULL : &cropRect; |
93 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po
intLocation, white, surfaceScale, kd, NULL, cr))->unref(); | 97 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po
intLocation, white, surfaceScale, kd, NULL, cr))->unref(); |
94 drawClippedBitmap(canvas, paint, 0, y); | 98 drawClippedBitmap(canvas, paint, 0, y); |
95 | 99 |
96 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(
distantDirection, white, surfaceScale, kd, NULL, cr))->unref(); | 100 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(
distantDirection, white, surfaceScale, kd, NULL, cr))->unref(); |
97 drawClippedBitmap(canvas, paint, 110, y); | 101 drawClippedBitmap(canvas, paint, 110, y); |
98 | 102 |
99 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spo
tLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, kd, NULL,
cr))->unref(); | 103 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spo
tLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, kd, NULL,
cr))->unref(); |
100 drawClippedBitmap(canvas, paint, 220, y); | 104 drawClippedBitmap(canvas, paint, 220, y); |
101 | 105 |
102 y += 110; | 106 y += 110; |
(...skipping 16 matching lines...) Expand all Loading... |
119 SkBitmap fBitmap; | 123 SkBitmap fBitmap; |
120 bool fInitialized; | 124 bool fInitialized; |
121 }; | 125 }; |
122 | 126 |
123 ////////////////////////////////////////////////////////////////////////////// | 127 ////////////////////////////////////////////////////////////////////////////// |
124 | 128 |
125 static GM* MyFactory(void*) { return new ImageLightingGM; } | 129 static GM* MyFactory(void*) { return new ImageLightingGM; } |
126 static GMRegistry reg(MyFactory); | 130 static GMRegistry reg(MyFactory); |
127 | 131 |
128 } | 132 } |
OLD | NEW |