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 | |
89 SkIRect cropRect = SkIRect::MakeXYWH(20, 10, 60, 65); | |
90 #else | |
91 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); | 88 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); |
92 #endif | |
93 | 89 |
94 int y = 0; | 90 int y = 0; |
95 for (int i = 0; i < 2; i++) { | 91 for (int i = 0; i < 2; i++) { |
96 const SkImageFilter::CropRect* cr = (i == 0) ? NULL : &cropRect; | 92 const SkImageFilter::CropRect* cr = (i == 0) ? NULL : &cropRect; |
97 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po
intLocation, white, surfaceScale, kd, NULL, cr))->unref(); | 93 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po
intLocation, white, surfaceScale, kd, NULL, cr))->unref(); |
98 drawClippedBitmap(canvas, paint, 0, y); | 94 drawClippedBitmap(canvas, paint, 0, y); |
99 | 95 |
100 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(
distantDirection, white, surfaceScale, kd, NULL, cr))->unref(); | 96 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(
distantDirection, white, surfaceScale, kd, NULL, cr))->unref(); |
101 drawClippedBitmap(canvas, paint, 110, y); | 97 drawClippedBitmap(canvas, paint, 110, y); |
102 | 98 |
(...skipping 20 matching lines...) Expand all Loading... |
123 SkBitmap fBitmap; | 119 SkBitmap fBitmap; |
124 bool fInitialized; | 120 bool fInitialized; |
125 }; | 121 }; |
126 | 122 |
127 ////////////////////////////////////////////////////////////////////////////// | 123 ////////////////////////////////////////////////////////////////////////////// |
128 | 124 |
129 static GM* MyFactory(void*) { return new ImageLightingGM; } | 125 static GM* MyFactory(void*) { return new ImageLightingGM; } |
130 static GMRegistry reg(MyFactory); | 126 static GMRegistry reg(MyFactory); |
131 | 127 |
132 } | 128 } |
OLD | NEW |