| 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" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 SkScalar cutoffAngle = SkIntToScalar(15); | 86 SkScalar cutoffAngle = SkIntToScalar(15); |
| 87 SkScalar kd = SkIntToScalar(2); | 87 SkScalar kd = SkIntToScalar(2); |
| 88 SkScalar ks = SkIntToScalar(1); | 88 SkScalar ks = SkIntToScalar(1); |
| 89 SkScalar shininess = SkIntToScalar(8); | 89 SkScalar shininess = SkIntToScalar(8); |
| 90 SkScalar surfaceScale = SkIntToScalar(1); | 90 SkScalar surfaceScale = SkIntToScalar(1); |
| 91 SkColor white(0xFFFFFFFF); | 91 SkColor white(0xFFFFFFFF); |
| 92 SkPaint paint; | 92 SkPaint paint; |
| 93 | 93 |
| 94 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); | 94 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); |
| 95 SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100
)); | 95 SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100
)); |
| 96 SkAutoTUnref<SkImageFilter> noopCropped(SkOffsetImageFilter::Create(0, 0
, NULL, &cropRect)); | 96 SkAutoTUnref<SkImageFilter> noopCropped(SkOffsetImageFilter::Create(0, 0
, nullptr, &cropRect)); |
| 97 | 97 |
| 98 int y = 0; | 98 int y = 0; |
| 99 for (int i = 0; i < 3; i++) { | 99 for (int i = 0; i < 3; i++) { |
| 100 const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2)
? &fullSizeCropRect : NULL; | 100 const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2)
? &fullSizeCropRect : nullptr; |
| 101 SkImageFilter* input = (i == 2) ? noopCropped.get() : NULL; | 101 SkImageFilter* input = (i == 2) ? noopCropped.get() : nullptr; |
| 102 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po
intLocation, | 102 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po
intLocation, |
| 103 wh
ite, | 103 wh
ite, |
| 104 su
rfaceScale, | 104 su
rfaceScale, |
| 105 kd
, | 105 kd
, |
| 106 in
put, | 106 in
put, |
| 107 cr
))->unref(); | 107 cr
))->unref(); |
| 108 drawClippedBitmap(canvas, paint, 0, y); | 108 drawClippedBitmap(canvas, paint, 0, y); |
| 109 | 109 |
| 110 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(
distantDirection, | 110 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(
distantDirection, |
| 111
white, | 111
white, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 private: | 165 private: |
| 166 typedef GM INHERITED; | 166 typedef GM INHERITED; |
| 167 SkBitmap fBitmap; | 167 SkBitmap fBitmap; |
| 168 bool fInitialized; | 168 bool fInitialized; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 ////////////////////////////////////////////////////////////////////////////// | 171 ////////////////////////////////////////////////////////////////////////////// |
| 172 | 172 |
| 173 DEF_GM(return new ImageLightingGM;) | 173 DEF_GM(return new ImageLightingGM;) |
| 174 } | 174 } |
| OLD | NEW |