| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 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 "SkTileImageFilter.h" | 8 #include "SkTileImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 &shaderMatrix)); | 74 &shaderMatrix)); |
| 75 paint.setShader(shader); | 75 paint.setShader(shader); |
| 76 canvas.translate(-dstRect.fLeft, -dstRect.fTop); | 76 canvas.translate(-dstRect.fLeft, -dstRect.fTop); |
| 77 canvas.drawRect(dstRect, paint); | 77 canvas.drawRect(dstRect, paint); |
| 78 *dst = device->accessBitmap(false); | 78 *dst = device->accessBitmap(false); |
| 79 offset->fX = dstIRect.fLeft; | 79 offset->fX = dstIRect.fLeft; |
| 80 offset->fY = dstIRect.fTop; | 80 offset->fY = dstIRect.fTop; |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void SkTileImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& c
tm, |
| 85 SkIRect* dst, MapDirection direction)
const { |
| 86 SkRect rect = kReverse_MapDirection == direction ? fSrcRect : fDstRect; |
| 87 ctm.mapRect(&rect); |
| 88 rect.roundOut(dst); |
| 89 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |
| 90 dst->join(src); |
| 91 #endif |
| 92 } |
| 93 |
| 84 bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, | 94 bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, |
| 85 SkIRect* dst) const { | 95 SkIRect* dst) const { |
| 86 SkRect srcRect; | 96 this->onFilterNodeBounds(src, ctm, dst, kReverse_MapDirection); |
| 87 ctm.mapRect(&srcRect, fSrcRect); | |
| 88 SkIRect srcIRect; | |
| 89 srcRect.roundOut(&srcIRect); | |
| 90 srcIRect.join(src); | |
| 91 *dst = srcIRect; | |
| 92 return true; | 97 return true; |
| 93 } | 98 } |
| 94 | 99 |
| 95 void SkTileImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const
{ | 100 void SkTileImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const
{ |
| 101 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |
| 96 // This is a workaround for skia:3194. | 102 // This is a workaround for skia:3194. |
| 97 *dst = src; | 103 *dst = src; |
| 98 dst->join(fDstRect); | 104 dst->join(fDstRect); |
| 105 #else |
| 106 *dst = fDstRect; |
| 107 #endif |
| 99 } | 108 } |
| 100 | 109 |
| 101 SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { | 110 SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 102 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 111 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 103 SkRect src, dst; | 112 SkRect src, dst; |
| 104 buffer.readRect(&src); | 113 buffer.readRect(&src); |
| 105 buffer.readRect(&dst); | 114 buffer.readRect(&dst); |
| 106 return Create(src, dst, common.getInput(0)); | 115 return Create(src, dst, common.getInput(0)); |
| 107 } | 116 } |
| 108 | 117 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 120 str->appendf(" dst: %.2f %.2f %.2f %.2f", | 129 str->appendf(" dst: %.2f %.2f %.2f %.2f", |
| 121 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 130 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
| 122 if (this->getInput(0)) { | 131 if (this->getInput(0)) { |
| 123 str->appendf("input: ("); | 132 str->appendf("input: ("); |
| 124 this->getInput(0)->toString(str); | 133 this->getInput(0)->toString(str); |
| 125 str->appendf(")"); | 134 str->appendf(")"); |
| 126 } | 135 } |
| 127 str->append(")"); | 136 str->append(")"); |
| 128 } | 137 } |
| 129 #endif | 138 #endif |
| OLD | NEW |