OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkImageSource.h" | 10 #include "SkImageSource.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 SkRect dstRect; | 32 SkRect dstRect; |
33 canvas->getTotalMatrix().mapRect(&dstRect, rect); | 33 canvas->getTotalMatrix().mapRect(&dstRect, rect); |
34 canvas->save(); | 34 canvas->save(); |
35 SkScalar deviceScaleX = deviceSize.width() / dstRect.width(); | 35 SkScalar deviceScaleX = deviceSize.width() / dstRect.width(); |
36 SkScalar deviceScaleY = deviceSize.height() / dstRect.height(); | 36 SkScalar deviceScaleY = deviceSize.height() / dstRect.height(); |
37 canvas->translate(rect.x(), rect.y()); | 37 canvas->translate(rect.x(), rect.y()); |
38 canvas->scale(deviceScaleX, deviceScaleY); | 38 canvas->scale(deviceScaleX, deviceScaleY); |
39 canvas->translate(-rect.x(), -rect.y()); | 39 canvas->translate(-rect.x(), -rect.y()); |
40 SkMatrix matrix; | 40 SkMatrix matrix; |
41 matrix.setScale(SkScalarInvert(deviceScaleX), SkScalarInvert(deviceScale
Y)); | 41 matrix.setScale(SkScalarInvert(deviceScaleX), SkScalarInvert(deviceScale
Y)); |
42 sk_sp<SkImageFilter> filter(SkImageFilter::CreateMatrixFilter(matrix, | 42 sk_sp<SkImageFilter> filter(SkImageFilter::MakeMatrixFilter(matrix, |
43 filterQual
ity, | 43 filterQualit
y, |
44 input.get(
))); | 44 std::move(in
put))); |
45 SkPaint filteredPaint; | 45 SkPaint filteredPaint; |
46 filteredPaint.setImageFilter(std::move(filter)); | 46 filteredPaint.setImageFilter(std::move(filter)); |
47 canvas->saveLayer(&rect, &filteredPaint); | 47 canvas->saveLayer(&rect, &filteredPaint); |
48 SkPaint paint; | 48 SkPaint paint; |
49 paint.setColor(0xFF00FF00); | 49 paint.setColor(0xFF00FF00); |
50 SkRect ovalRect = rect; | 50 SkRect ovalRect = rect; |
51 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4)); | 51 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4)); |
52 canvas->drawOval(ovalRect, paint); | 52 canvas->drawOval(ovalRect, paint); |
53 canvas->restore(); // for saveLayer | 53 canvas->restore(); // for saveLayer |
54 canvas->restore(); | 54 canvas->restore(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 private: | 117 private: |
118 typedef GM INHERITED; | 118 typedef GM INHERITED; |
119 }; | 119 }; |
120 | 120 |
121 ////////////////////////////////////////////////////////////////////////////// | 121 ////////////////////////////////////////////////////////////////////////////// |
122 | 122 |
123 DEF_GM(return new ResizeGM; ) | 123 DEF_GM(return new ResizeGM; ) |
124 | 124 |
125 } | 125 } |
OLD | NEW |