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

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: Update to ToT 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 SkRect copy = *dst;
74 dst->offset(fOffset.fX, fOffset.fY); 73 dst->offset(fOffset.fX, fOffset.fY);
75 dst->join(copy);
76 } 74 }
77 75
78 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm , 76 void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
79 SkIRect* dst) const { 77 SkIRect* dst, MapDirection directio n) const {
80 SkVector vec; 78 SkVector vec;
81 ctm.mapVectors(&vec, &fOffset, 1); 79 ctm.mapVectors(&vec, &fOffset, 1);
80 if (kReverse_MapDirection == direction) {
81 vec.negate();
82 }
82 83
83 SkIRect bounds = src; 84 *dst = src;
84 bounds.offset(-SkScalarCeilToInt(vec.fX), -SkScalarCeilToInt(vec.fY)); 85 dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
85 bounds.join(src);
86 if (getInput(0)) {
87 return getInput(0)->filterBounds(bounds, ctm, dst);
88 }
89 *dst = bounds;
90 return true;
91 } 86 }
92 87
93 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { 88 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
94 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 89 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
95 SkPoint offset; 90 SkPoint offset;
96 buffer.readPoint(&offset); 91 buffer.readPoint(&offset);
97 return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect() ); 92 return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect() );
98 } 93 }
99 94
100 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { 95 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
(...skipping 11 matching lines...) Expand all
112 void SkOffsetImageFilter::toString(SkString* str) const { 107 void SkOffsetImageFilter::toString(SkString* str) const {
113 str->appendf("SkOffsetImageFilter: ("); 108 str->appendf("SkOffsetImageFilter: (");
114 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); 109 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY);
115 str->append("input: ("); 110 str->append("input: (");
116 if (this->getInput(0)) { 111 if (this->getInput(0)) {
117 this->getInput(0)->toString(str); 112 this->getInput(0)->toString(str);
118 } 113 }
119 str->append("))"); 114 str->append("))");
120 } 115 }
121 #endif 116 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698