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 "SkImageSource.h" | 9 #include "SkImageSource.h" |
10 #include "SkMagnifierImageFilter.h" | 10 #include "SkMagnifierImageFilter.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 DEF_SIMPLE_GM_BG(imagemagnifier_cropped, canvas, WIDTH_HEIGHT, WIDTH_HEIGHT, SK_
ColorBLACK) { | 65 DEF_SIMPLE_GM_BG(imagemagnifier_cropped, canvas, WIDTH_HEIGHT, WIDTH_HEIGHT, SK_
ColorBLACK) { |
66 | 66 |
67 sk_sp<SkImage> image(make_img()); | 67 sk_sp<SkImage> image(make_img()); |
68 | 68 |
69 sk_sp<SkImageFilter> imageSource(SkImageSource::Make(std::move(image))); | 69 sk_sp<SkImageFilter> imageSource(SkImageSource::Make(std::move(image))); |
70 | 70 |
71 SkRect srcRect = SkRect::MakeWH(SkIntToScalar(WIDTH_HEIGHT-32), | 71 SkRect srcRect = SkRect::MakeWH(SkIntToScalar(WIDTH_HEIGHT-32), |
72 SkIntToScalar(WIDTH_HEIGHT-32)); | 72 SkIntToScalar(WIDTH_HEIGHT-32)); |
73 srcRect.inset(64.0f, 64.0f); | 73 srcRect.inset(64.0f, 64.0f); |
74 | 74 |
75 static const SkScalar kInset = 64.0f; | 75 constexpr SkScalar kInset = 64.0f; |
76 | 76 |
77 // Crop out a 16 pixel ring around the result | 77 // Crop out a 16 pixel ring around the result |
78 const SkRect rect = SkRect::MakeXYWH(16, 16, WIDTH_HEIGHT-32, WIDTH_HEIGHT-3
2); | 78 const SkRect rect = SkRect::MakeXYWH(16, 16, WIDTH_HEIGHT-32, WIDTH_HEIGHT-3
2); |
79 SkImageFilter::CropRect cropRect(rect); | 79 SkImageFilter::CropRect cropRect(rect); |
80 | 80 |
81 SkPaint filterPaint; | 81 SkPaint filterPaint; |
82 filterPaint.setImageFilter(SkMagnifierImageFilter::Make(srcRect, kInset, | 82 filterPaint.setImageFilter(SkMagnifierImageFilter::Make(srcRect, kInset, |
83 std::move(imageSourc
e), | 83 std::move(imageSourc
e), |
84 &cropRect)); | 84 &cropRect)); |
85 | 85 |
86 canvas->saveLayer(nullptr, &filterPaint); | 86 canvas->saveLayer(nullptr, &filterPaint); |
87 canvas->restore(); | 87 canvas->restore(); |
88 } | 88 } |
OLD | NEW |