| OLD | NEW | 
|---|
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 59     } | 59     } | 
| 60     return true; | 60     return true; | 
| 61 } | 61 } | 
| 62 | 62 | 
| 63 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons
     t { | 63 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons
     t { | 
| 64     if (getInput(0)) { | 64     if (getInput(0)) { | 
| 65         getInput(0)->computeFastBounds(src, dst); | 65         getInput(0)->computeFastBounds(src, dst); | 
| 66     } else { | 66     } else { | 
| 67         *dst = src; | 67         *dst = src; | 
| 68     } | 68     } | 
| 69 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |  | 
| 70     SkRect copy = *dst; |  | 
| 71 #endif |  | 
| 72     dst->offset(fOffset.fX, fOffset.fY); | 69     dst->offset(fOffset.fX, fOffset.fY); | 
| 73 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |  | 
| 74     dst->join(copy); |  | 
| 75 #endif |  | 
| 76 } | 70 } | 
| 77 | 71 | 
| 78 void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&
      ctm, | 72 void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&
      ctm, | 
| 79                                              SkIRect* dst, MapDirection directio
     n) const { | 73                                              SkIRect* dst, MapDirection directio
     n) const { | 
| 80     SkVector vec; | 74     SkVector vec; | 
| 81     ctm.mapVectors(&vec, &fOffset, 1); | 75     ctm.mapVectors(&vec, &fOffset, 1); | 
| 82     if (kReverse_MapDirection == direction) { | 76     if (kReverse_MapDirection == direction) { | 
| 83         vec.negate(); | 77         vec.negate(); | 
| 84     } | 78     } | 
| 85 | 79 | 
| 86     *dst = src; | 80     *dst = src; | 
| 87     dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY)); | 81     dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY)); | 
| 88 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |  | 
| 89     dst->join(src); |  | 
| 90 #endif |  | 
| 91 } | 82 } | 
| 92 | 83 | 
| 93 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { | 84 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { | 
| 94     SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 85     SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 
| 95     SkPoint offset; | 86     SkPoint offset; | 
| 96     buffer.readPoint(&offset); | 87     buffer.readPoint(&offset); | 
| 97     return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect()
     ); | 88     return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect()
     ); | 
| 98 } | 89 } | 
| 99 | 90 | 
| 100 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { | 91 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 112 void SkOffsetImageFilter::toString(SkString* str) const { | 103 void SkOffsetImageFilter::toString(SkString* str) const { | 
| 113     str->appendf("SkOffsetImageFilter: ("); | 104     str->appendf("SkOffsetImageFilter: ("); | 
| 114     str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); | 105     str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); | 
| 115     str->append("input: ("); | 106     str->append("input: ("); | 
| 116     if (this->getInput(0)) { | 107     if (this->getInput(0)) { | 
| 117         this->getInput(0)->toString(str); | 108         this->getInput(0)->toString(str); | 
| 118     } | 109     } | 
| 119     str->append("))"); | 110     str->append("))"); | 
| 120 } | 111 } | 
| 121 #endif | 112 #endif | 
| OLD | NEW | 
|---|