| 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 "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
| 10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
| 11 #include "SkColor.h" | 11 #include "SkColor.h" |
| 12 #include "SkMatrixImageFilter.h" | |
| 13 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
| 14 | 13 |
| 15 namespace skiagm { | 14 namespace skiagm { |
| 16 | 15 |
| 17 class ResizeGM : public GM { | 16 class ResizeGM : public GM { |
| 18 public: | 17 public: |
| 19 ResizeGM() { | 18 ResizeGM() { |
| 20 this->setBGColor(0x00000000); | 19 this->setBGColor(0x00000000); |
| 21 } | 20 } |
| 22 | 21 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 canvas->save(); | 34 canvas->save(); |
| 36 SkScalar deviceScaleX = SkScalarDiv(deviceSize.width(), dstRect.width())
; | 35 SkScalar deviceScaleX = SkScalarDiv(deviceSize.width(), dstRect.width())
; |
| 37 SkScalar deviceScaleY = SkScalarDiv(deviceSize.height(), dstRect.height(
)); | 36 SkScalar deviceScaleY = SkScalarDiv(deviceSize.height(), dstRect.height(
)); |
| 38 canvas->translate(rect.x(), rect.y()); | 37 canvas->translate(rect.x(), rect.y()); |
| 39 canvas->scale(deviceScaleX, deviceScaleY); | 38 canvas->scale(deviceScaleX, deviceScaleY); |
| 40 canvas->translate(-rect.x(), -rect.y()); | 39 canvas->translate(-rect.x(), -rect.y()); |
| 41 SkMatrix matrix; | 40 SkMatrix matrix; |
| 42 matrix.setScale(SkScalarInvert(deviceScaleX), | 41 matrix.setScale(SkScalarInvert(deviceScaleX), |
| 43 SkScalarInvert(deviceScaleY)); | 42 SkScalarInvert(deviceScaleY)); |
| 44 SkAutoTUnref<SkImageFilter> imageFilter( | 43 SkAutoTUnref<SkImageFilter> imageFilter( |
| 45 SkMatrixImageFilter::Create(matrix, filterQuality, input)); | 44 SkImageFilter::CreateMatrixFilter(matrix, filterQuality, input)); |
| 46 SkPaint filteredPaint; | 45 SkPaint filteredPaint; |
| 47 filteredPaint.setImageFilter(imageFilter.get()); | 46 filteredPaint.setImageFilter(imageFilter.get()); |
| 48 canvas->saveLayer(&rect, &filteredPaint); | 47 canvas->saveLayer(&rect, &filteredPaint); |
| 49 SkPaint paint; | 48 SkPaint paint; |
| 50 paint.setColor(0xFF00FF00); | 49 paint.setColor(0xFF00FF00); |
| 51 SkRect ovalRect = rect; | 50 SkRect ovalRect = rect; |
| 52 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4)); | 51 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4)); |
| 53 canvas->drawOval(ovalRect, paint); | 52 canvas->drawOval(ovalRect, paint); |
| 54 canvas->restore(); // for saveLayer | 53 canvas->restore(); // for saveLayer |
| 55 canvas->restore(); | 54 canvas->restore(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 private: | 113 private: |
| 115 typedef GM INHERITED; | 114 typedef GM INHERITED; |
| 116 }; | 115 }; |
| 117 | 116 |
| 118 ////////////////////////////////////////////////////////////////////////////// | 117 ////////////////////////////////////////////////////////////////////////////// |
| 119 | 118 |
| 120 static GM* MyFactory(void*) { return new ResizeGM; } | 119 static GM* MyFactory(void*) { return new ResizeGM; } |
| 121 static GMRegistry reg(MyFactory); | 120 static GMRegistry reg(MyFactory); |
| 122 | 121 |
| 123 } | 122 } |
| OLD | NEW |