Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: gm/offsetimagefilter.cpp

Issue 833943002: It is dangerous to ignore SkRect::intersect's return value (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/gmmain.cpp ('k') | include/core/SkRect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « gm/gmmain.cpp ('k') | include/core/SkRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698