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

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

Issue 1308703007: Fix filter primitive bounds computations. (Closed) Base URL: https://skia.googlesource.com/skia.git@saveLayer-bounds-not-transformed
Patch Set: Fix comment style; remove useless param names Created 5 years 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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 return true; 64 return true;
65 } 65 }
66 66
67 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t { 67 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t {
68 if (getInput(0)) { 68 if (getInput(0)) {
69 getInput(0)->computeFastBounds(src, dst); 69 getInput(0)->computeFastBounds(src, dst);
70 } else { 70 } else {
71 *dst = src; 71 *dst = src;
72 } 72 }
73 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
73 SkRect copy = *dst; 74 SkRect copy = *dst;
75 #endif
74 dst->offset(fOffset.fX, fOffset.fY); 76 dst->offset(fOffset.fX, fOffset.fY);
77 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
75 dst->join(copy); 78 dst->join(copy);
79 #endif
76 } 80 }
77 81
78 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm , 82 void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
79 SkIRect* dst) const { 83 SkIRect* dst, MapDirection directio n) const {
80 SkVector vec; 84 SkVector vec;
81 ctm.mapVectors(&vec, &fOffset, 1); 85 ctm.mapVectors(&vec, &fOffset, 1);
86 if (kReverse_MapDirection == direction) {
87 vec.negate();
88 }
82 89
83 SkIRect bounds = src; 90 *dst = src;
84 bounds.offset(-SkScalarCeilToInt(vec.fX), -SkScalarCeilToInt(vec.fY)); 91 dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
85 bounds.join(src); 92 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
86 if (getInput(0)) { 93 dst->join(src);
87 return getInput(0)->filterBounds(bounds, ctm, dst); 94 #endif
88 }
89 *dst = bounds;
90 return true;
91 } 95 }
92 96
93 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { 97 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
94 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 98 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
95 SkPoint offset; 99 SkPoint offset;
96 buffer.readPoint(&offset); 100 buffer.readPoint(&offset);
97 return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect() ); 101 return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect() );
98 } 102 }
99 103
100 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { 104 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
(...skipping 11 matching lines...) Expand all
112 void SkOffsetImageFilter::toString(SkString* str) const { 116 void SkOffsetImageFilter::toString(SkString* str) const {
113 str->appendf("SkOffsetImageFilter: ("); 117 str->appendf("SkOffsetImageFilter: (");
114 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); 118 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY);
115 str->append("input: ("); 119 str->append("input: (");
116 if (this->getInput(0)) { 120 if (this->getInput(0)) {
117 this->getInput(0)->toString(str); 121 this->getInput(0)->toString(str);
118 } 122 }
119 str->append("))"); 123 str->append("))");
120 } 124 }
121 #endif 125 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698