| 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 "SkBicubicImageFilter.h" | 10 #include "SkBicubicImageFilter.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (!fInitialized) { | 50 if (!fInitialized) { |
| 51 make_checkerboard(4, 4); | 51 make_checkerboard(4, 4); |
| 52 fInitialized = true; | 52 fInitialized = true; |
| 53 } | 53 } |
| 54 SkScalar sk32 = SkIntToScalar(32); | 54 SkScalar sk32 = SkIntToScalar(32); |
| 55 canvas->clear(0x00000000); | 55 canvas->clear(0x00000000); |
| 56 SkPaint bilinearPaint, bicubicPaint; | 56 SkPaint bilinearPaint, bicubicPaint; |
| 57 SkSize scale = SkSize::Make(sk32, sk32); | 57 SkSize scale = SkSize::Make(sk32, sk32); |
| 58 canvas->save(); | 58 canvas->save(); |
| 59 canvas->scale(sk32, sk32); | 59 canvas->scale(sk32, sk32); |
| 60 bilinearPaint.setFilterBitmap(true); | 60 bilinearPaint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 61 canvas->drawBitmap(fCheckerboard, 0, 0, &bilinearPaint); | 61 canvas->drawBitmap(fCheckerboard, 0, 0, &bilinearPaint); |
| 62 canvas->restore(); | 62 canvas->restore(); |
| 63 SkAutoTUnref<SkImageFilter> bicubic(SkBicubicImageFilter::CreateMitchell
(scale)); | 63 SkAutoTUnref<SkImageFilter> bicubic(SkBicubicImageFilter::CreateMitchell
(scale)); |
| 64 bicubicPaint.setImageFilter(bicubic); | 64 bicubicPaint.setImageFilter(bicubic); |
| 65 SkRect srcBounds; | 65 SkRect srcBounds; |
| 66 fCheckerboard.getBounds(&srcBounds); | 66 fCheckerboard.getBounds(&srcBounds); |
| 67 canvas->translate(SkIntToScalar(140), 0); | 67 canvas->translate(SkIntToScalar(140), 0); |
| 68 canvas->saveLayer(&srcBounds, &bicubicPaint); | 68 canvas->saveLayer(&srcBounds, &bicubicPaint); |
| 69 canvas->drawBitmap(fCheckerboard, 0, 0); | 69 canvas->drawBitmap(fCheckerboard, 0, 0); |
| 70 canvas->restore(); | 70 canvas->restore(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 typedef GM INHERITED; | 74 typedef GM INHERITED; |
| 75 SkBitmap fCheckerboard; | 75 SkBitmap fCheckerboard; |
| 76 bool fInitialized; | 76 bool fInitialized; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 ////////////////////////////////////////////////////////////////////////////// | 79 ////////////////////////////////////////////////////////////////////////////// |
| 80 | 80 |
| 81 static GM* MyFactory(void*) { return new BicubicGM; } | 81 static GM* MyFactory(void*) { return new BicubicGM; } |
| 82 static GMRegistry reg(MyFactory); | 82 static GMRegistry reg(MyFactory); |
| 83 | 83 |
| 84 } | 84 } |
| OLD | NEW |