| 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 "SkOffsetImageFilter.h" | 9 #include "SkOffsetImageFilter.h" |
| 10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 SkPaint strokePaint; | 75 SkPaint strokePaint; |
| 76 strokePaint.setStyle(SkPaint::kStroke_Style); | 76 strokePaint.setStyle(SkPaint::kStroke_Style); |
| 77 strokePaint.setColor(SK_ColorRED); | 77 strokePaint.setColor(SK_ColorRED); |
| 78 | 78 |
| 79 // Draw a boundary rect around the intersection of the clip rect | 79 // Draw a boundary rect around the intersection of the clip rect |
| 80 // and crop rect. | 80 // and crop rect. |
| 81 SkMatrix scaleMatrix; | 81 SkMatrix scaleMatrix; |
| 82 scaleMatrix.setScale(scale, scale); | 82 scaleMatrix.setScale(scale, scale); |
| 83 SkRect cropRectFloat; | 83 SkRect cropRectFloat; |
| 84 scaleMatrix.mapRect(&cropRectFloat, SkRect::Make(cropRect)); | 84 scaleMatrix.mapRect(&cropRectFloat, SkRect::Make(cropRect)); |
| 85 if (clipRect.intersect(cropRectFloat)) { | 85 clipRect.intersect(cropRectFloat); |
| 86 canvas->drawRect(clipRect, strokePaint); | 86 canvas->drawRect(clipRect, strokePaint); |
| 87 } | |
| 88 } | 87 } |
| 89 | 88 |
| 90 virtual void onDraw(SkCanvas* canvas) { | 89 virtual void onDraw(SkCanvas* canvas) { |
| 91 if (!fInitialized) { | 90 if (!fInitialized) { |
| 92 make_bitmap(); | 91 make_bitmap(); |
| 93 make_checkerboard(); | 92 make_checkerboard(); |
| 94 fInitialized = true; | 93 fInitialized = true; |
| 95 } | 94 } |
| 96 canvas->clear(0x00000000); | 95 canvas->clear(0x00000000); |
| 97 SkPaint paint; | 96 SkPaint paint; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 125 SkBitmap fBitmap, fCheckerboard; | 124 SkBitmap fBitmap, fCheckerboard; |
| 126 bool fInitialized; | 125 bool fInitialized; |
| 127 }; | 126 }; |
| 128 | 127 |
| 129 ////////////////////////////////////////////////////////////////////////////// | 128 ////////////////////////////////////////////////////////////////////////////// |
| 130 | 129 |
| 131 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } | 130 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } |
| 132 static GMRegistry reg(MyFactory); | 131 static GMRegistry reg(MyFactory); |
| 133 | 132 |
| 134 } | 133 } |
| OLD | NEW |