| 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, | 19 SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect
& dstRect, |
| 20 SkImageFilter* input, uint32_t uniq
ueID) { | 20 SkImageFilter* input) { |
| 21 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { | 21 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { |
| 22 return NULL; | 22 return NULL; |
| 23 } | 23 } |
| 24 return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input, uniqueID)); | 24 return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, | 27 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
| 28 const Context& ctx, | 28 const Context& ctx, |
| 29 SkBitmap* dst, SkIPoint* offset) const { | 29 SkBitmap* dst, SkIPoint* offset) const { |
| 30 SkBitmap source = src; | 30 SkBitmap source = src; |
| 31 SkImageFilter* input = getInput(0); | 31 SkImageFilter* input = getInput(0); |
| 32 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 32 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 33 if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) { | 33 if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) { |
| 34 return false; | 34 return false; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 srcIRect.join(src); | 91 srcIRect.join(src); |
| 92 *dst = srcIRect; | 92 *dst = srcIRect; |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { | 96 SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 97 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 97 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 98 SkRect src, dst; | 98 SkRect src, dst; |
| 99 buffer.readRect(&src); | 99 buffer.readRect(&src); |
| 100 buffer.readRect(&dst); | 100 buffer.readRect(&dst); |
| 101 return Create(src, dst, common.getInput(0), common.uniqueID()); | 101 return Create(src, dst, common.getInput(0)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { | 104 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 105 this->INHERITED::flatten(buffer); | 105 this->INHERITED::flatten(buffer); |
| 106 buffer.writeRect(fSrcRect); | 106 buffer.writeRect(fSrcRect); |
| 107 buffer.writeRect(fDstRect); | 107 buffer.writeRect(fDstRect); |
| 108 } | 108 } |
| 109 | 109 |
| 110 #ifndef SK_IGNORE_TO_STRING | 110 #ifndef SK_IGNORE_TO_STRING |
| 111 void SkTileImageFilter::toString(SkString* str) const { | 111 void SkTileImageFilter::toString(SkString* str) const { |
| 112 str->appendf("SkTileImageFilter: ("); | 112 str->appendf("SkTileImageFilter: ("); |
| 113 str->append(")"); | 113 str->append(")"); |
| 114 } | 114 } |
| 115 #endif | 115 #endif |
| OLD | NEW |