| 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 clipRect.intersect(cropRectFloat); | 85 if (clipRect.intersect(cropRectFloat)) { |
| 86 canvas->drawRect(clipRect, strokePaint); | 86 canvas->drawRect(clipRect, strokePaint); |
| 87 } |
| 87 } | 88 } |
| 88 | 89 |
| 89 virtual void onDraw(SkCanvas* canvas) { | 90 virtual void onDraw(SkCanvas* canvas) { |
| 90 if (!fInitialized) { | 91 if (!fInitialized) { |
| 91 make_bitmap(); | 92 make_bitmap(); |
| 92 make_checkerboard(); | 93 make_checkerboard(); |
| 93 fInitialized = true; | 94 fInitialized = true; |
| 94 } | 95 } |
| 95 canvas->clear(0x00000000); | 96 canvas->clear(0x00000000); |
| 96 SkPaint paint; | 97 SkPaint paint; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 124 SkBitmap fBitmap, fCheckerboard; | 125 SkBitmap fBitmap, fCheckerboard; |
| 125 bool fInitialized; | 126 bool fInitialized; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 ////////////////////////////////////////////////////////////////////////////// | 129 ////////////////////////////////////////////////////////////////////////////// |
| 129 | 130 |
| 130 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } | 131 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } |
| 131 static GMRegistry reg(MyFactory); | 132 static GMRegistry reg(MyFactory); |
| 132 | 133 |
| 133 } | 134 } |
| OLD | NEW |