| 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" |
| 11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
| 12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
| 13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
| 14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "SkShader.h" | 16 #include "SkShader.h" |
| 17 #include "SkValidationUtils.h" | 17 #include "SkValidationUtils.h" |
| 18 | 18 |
| 19 SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect
& dstRect, |
| 20 SkImageFilter* input) { |
| 21 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { |
| 22 return NULL; |
| 23 } |
| 24 return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input)); |
| 25 } |
| 26 |
| 19 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, | 27 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
| 20 const Context& ctx, | 28 const Context& ctx, |
| 21 SkBitmap* dst, SkIPoint* offset) const { | 29 SkBitmap* dst, SkIPoint* offset) const { |
| 22 SkBitmap source = src; | 30 SkBitmap source = src; |
| 23 SkImageFilter* input = getInput(0); | 31 SkImageFilter* input = getInput(0); |
| 24 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 32 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 25 if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) { | 33 if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) { |
| 26 return false; | 34 return false; |
| 27 } | 35 } |
| 28 | 36 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 SkIRect* dst) const { | 87 SkIRect* dst) const { |
| 80 SkRect srcRect; | 88 SkRect srcRect; |
| 81 ctm.mapRect(&srcRect, fSrcRect); | 89 ctm.mapRect(&srcRect, fSrcRect); |
| 82 SkIRect srcIRect; | 90 SkIRect srcIRect; |
| 83 srcRect.roundOut(&srcIRect); | 91 srcRect.roundOut(&srcIRect); |
| 84 srcIRect.join(src); | 92 srcIRect.join(src); |
| 85 *dst = srcIRect; | 93 *dst = srcIRect; |
| 86 return true; | 94 return true; |
| 87 } | 95 } |
| 88 | 96 |
| 97 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 89 SkTileImageFilter::SkTileImageFilter(SkReadBuffer& buffer) | 98 SkTileImageFilter::SkTileImageFilter(SkReadBuffer& buffer) |
| 90 : INHERITED(1, buffer) { | 99 : INHERITED(1, buffer) { |
| 91 buffer.readRect(&fSrcRect); | 100 buffer.readRect(&fSrcRect); |
| 92 buffer.readRect(&fDstRect); | 101 buffer.readRect(&fDstRect); |
| 93 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect
(fDstRect)); | 102 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect
(fDstRect)); |
| 94 } | 103 } |
| 104 #endif |
| 105 |
| 106 SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 107 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 108 SkRect src, dst; |
| 109 buffer.readRect(&src); |
| 110 buffer.readRect(&dst); |
| 111 return Create(src, dst, common.getInput(0)); |
| 112 } |
| 95 | 113 |
| 96 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { | 114 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 97 this->INHERITED::flatten(buffer); | 115 this->INHERITED::flatten(buffer); |
| 98 buffer.writeRect(fSrcRect); | 116 buffer.writeRect(fSrcRect); |
| 99 buffer.writeRect(fDstRect); | 117 buffer.writeRect(fDstRect); |
| 100 } | 118 } |
| OLD | NEW |