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

Side by Side Diff: src/effects/SkOffsetImageFilter.cpp

Issue 23011012: Implement correct clipping for image filters. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add morphology to the list of ignored tests Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | no next file » | 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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkOffsetImageFilter.h" 8 #include "SkOffsetImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 return true; 66 return true;
67 } 67 }
68 68
69 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t { 69 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t {
70 if (getInput(0)) { 70 if (getInput(0)) {
71 getInput(0)->computeFastBounds(src, dst); 71 getInput(0)->computeFastBounds(src, dst);
72 } else { 72 } else {
73 *dst = src; 73 *dst = src;
74 } 74 }
75 SkRect copy = *dst;
75 dst->offset(fOffset.fX, fOffset.fY); 76 dst->offset(fOffset.fX, fOffset.fY);
77 dst->join(copy);
76 } 78 }
77 79
78 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm , 80 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm ,
79 SkIRect* dst) { 81 SkIRect* dst) const {
80 SkVector vec; 82 SkVector vec;
81 ctm.mapVectors(&vec, &fOffset, 1); 83 ctm.mapVectors(&vec, &fOffset, 1);
82 84
83 *dst = src; 85 *dst = src;
84 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY)); 86 dst->offset(-SkScalarCeilToInt(vec.fX), -SkScalarCeilToInt(vec.fY));
87 dst->join(src);
85 return true; 88 return true;
86 } 89 }
87 90
88 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { 91 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
89 this->INHERITED::flatten(buffer); 92 this->INHERITED::flatten(buffer);
90 buffer.writePoint(fOffset); 93 buffer.writePoint(fOffset);
91 } 94 }
92 95
93 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter * input, 96 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter * input,
94 const CropRect* cropRect) : INHERITED(i nput, cropRect) { 97 const CropRect* cropRect) : INHERITED(i nput, cropRect) {
95 fOffset.set(dx, dy); 98 fOffset.set(dx, dy);
96 } 99 }
97 100
98 SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer) 101 SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer)
99 : INHERITED(1, buffer) { 102 : INHERITED(1, buffer) {
100 buffer.readPoint(&fOffset); 103 buffer.readPoint(&fOffset);
101 buffer.validate(SkScalarIsFinite(fOffset.fX) && 104 buffer.validate(SkScalarIsFinite(fOffset.fX) &&
102 SkScalarIsFinite(fOffset.fY)); 105 SkScalarIsFinite(fOffset.fY));
103 } 106 }
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698