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

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

Issue 1823573003: Change signatures of filter bounds methods to return a rect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Hide legacy API behind #ifdef; switch callers to new API Created 4 years, 9 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
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 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 SkIntToScalar(srcOffset.fY - bounds.fTop)); 58 SkIntToScalar(srcOffset.fY - bounds.fTop));
59 59
60 input->draw(canvas, vec.x(), vec.y(), &paint); 60 input->draw(canvas, vec.x(), vec.y(), &paint);
61 61
62 offset->fX = bounds.fLeft; 62 offset->fX = bounds.fLeft;
63 offset->fY = bounds.fTop; 63 offset->fY = bounds.fTop;
64 return surf->makeImageSnapshot().release(); 64 return surf->makeImageSnapshot().release();
65 } 65 }
66 } 66 }
67 67
68 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t { 68 SkRect SkOffsetImageFilter::computeFastBounds(const SkRect& src) const {
69 if (getInput(0)) { 69 SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src ) : src;
70 getInput(0)->computeFastBounds(src, dst); 70 bounds.offset(fOffset.fX, fOffset.fY);
71 } else { 71 return bounds;
72 *dst = src;
73 }
74 dst->offset(fOffset.fX, fOffset.fY);
75 } 72 }
76 73
77 void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, 74 SkIRect SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatr ix& ctm,
78 SkIRect* dst, MapDirection directio n) const { 75 MapDirection direction) const {
79 SkVector vec; 76 SkVector vec;
80 ctm.mapVectors(&vec, &fOffset, 1); 77 ctm.mapVectors(&vec, &fOffset, 1);
81 if (kReverse_MapDirection == direction) { 78 if (kReverse_MapDirection == direction) {
82 vec.negate(); 79 vec.negate();
83 } 80 }
84 81
85 *dst = src; 82 return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
86 dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
87 } 83 }
88 84
89 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { 85 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
90 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
91 SkPoint offset; 87 SkPoint offset;
92 buffer.readPoint(&offset); 88 buffer.readPoint(&offset);
93 return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect() ); 89 return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect() );
94 } 90 }
95 91
96 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { 92 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
(...skipping 11 matching lines...) Expand all
108 void SkOffsetImageFilter::toString(SkString* str) const { 104 void SkOffsetImageFilter::toString(SkString* str) const {
109 str->appendf("SkOffsetImageFilter: ("); 105 str->appendf("SkOffsetImageFilter: (");
110 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); 106 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY);
111 str->append("input: ("); 107 str->append("input: (");
112 if (this->getInput(0)) { 108 if (this->getInput(0)) {
113 this->getInput(0)->toString(str); 109 this->getInput(0)->toString(str);
114 } 110 }
115 str->append("))"); 111 str->append("))");
116 } 112 }
117 #endif 113 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698