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 "SkResizeImageFilter.h" | 10 #include "SkResizeImageFilter.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 SkPaint::FilterLevel filterLevel) { | 28 SkPaint::FilterLevel filterLevel) { |
29 SkRect dstRect; | 29 SkRect dstRect; |
30 canvas->getTotalMatrix().mapRect(&dstRect, rect); | 30 canvas->getTotalMatrix().mapRect(&dstRect, rect); |
31 canvas->save(); | 31 canvas->save(); |
32 SkScalar deviceScaleX = SkScalarDiv(deviceSize.width(), dstRect.width())
; | 32 SkScalar deviceScaleX = SkScalarDiv(deviceSize.width(), dstRect.width())
; |
33 SkScalar deviceScaleY = SkScalarDiv(deviceSize.height(), dstRect.height(
)); | 33 SkScalar deviceScaleY = SkScalarDiv(deviceSize.height(), dstRect.height(
)); |
34 canvas->translate(rect.x(), rect.y()); | 34 canvas->translate(rect.x(), rect.y()); |
35 canvas->scale(deviceScaleX, deviceScaleY); | 35 canvas->scale(deviceScaleX, deviceScaleY); |
36 canvas->translate(-rect.x(), -rect.y()); | 36 canvas->translate(-rect.x(), -rect.y()); |
37 SkAutoTUnref<SkImageFilter> imageFilter( | 37 SkAutoTUnref<SkImageFilter> imageFilter( |
38 new SkResizeImageFilter(SkScalarInvert(deviceScaleX), | 38 SkResizeImageFilter::Create(SkScalarInvert(deviceScaleX), |
39 SkScalarInvert(deviceScaleY), | 39 SkScalarInvert(deviceScaleY), |
40 filterLevel)); | 40 filterLevel)); |
41 SkPaint filteredPaint; | 41 SkPaint filteredPaint; |
42 filteredPaint.setImageFilter(imageFilter.get()); | 42 filteredPaint.setImageFilter(imageFilter.get()); |
43 canvas->saveLayer(&rect, &filteredPaint); | 43 canvas->saveLayer(&rect, &filteredPaint); |
44 SkPaint paint; | 44 SkPaint paint; |
45 paint.setColor(0xFF00FF00); | 45 paint.setColor(0xFF00FF00); |
46 SkRect ovalRect = rect; | 46 SkRect ovalRect = rect; |
47 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4)); | 47 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4)); |
48 canvas->drawOval(ovalRect, paint); | 48 canvas->drawOval(ovalRect, paint); |
49 canvas->restore(); // for saveLayer | 49 canvas->restore(); // for saveLayer |
50 canvas->restore(); | 50 canvas->restore(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 private: | 87 private: |
88 typedef GM INHERITED; | 88 typedef GM INHERITED; |
89 }; | 89 }; |
90 | 90 |
91 ////////////////////////////////////////////////////////////////////////////// | 91 ////////////////////////////////////////////////////////////////////////////// |
92 | 92 |
93 static GM* MyFactory(void*) { return new ResizeGM; } | 93 static GM* MyFactory(void*) { return new ResizeGM; } |
94 static GMRegistry reg(MyFactory); | 94 static GMRegistry reg(MyFactory); |
95 | 95 |
96 } | 96 } |
OLD | NEW |