SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input) { if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { return NULL; } return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input)); }
SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input) { if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { return nullptr; } return new SkTileImageFilter(srcRect, dstRect, input); }
bool SkImageFilter::Common::unflatten(SkReadBuffer& buffer, int expectedCount) { const int count = buffer.readInt(); if (!buffer.validate(count >= 0)) { return false; } if (!buffer.validate(expectedCount < 0 || count == expectedCount)) { return false; } this->allocInputs(count); for (int i = 0; i < count; i++) { if (buffer.readBool()) { fInputs[i] = buffer.readImageFilter(); } if (!buffer.isValid()) { return false; } } SkRect rect; buffer.readRect(&rect); if (!buffer.isValid() || !buffer.validate(SkIsValidRect(rect))) { return false; } uint32_t flags = buffer.readUInt(); fCropRect = CropRect(rect, flags); if (buffer.isVersionLT(SkReadBuffer::kImageFilterNoUniqueID_Version)) { (void) buffer.readUInt(); } return buffer.isValid(); }
SkImageFilter::SkImageFilter(int inputCount, SkFlattenableReadBuffer& buffer) { fInputCount = buffer.readInt(); if (buffer.validate((fInputCount >= 0) && ((inputCount < 0) || (fInputCount == inputCount)))) { fInputs = new SkImageFilter*[fInputCount]; for (int i = 0; i < fInputCount; i++) { if (buffer.readBool()) { fInputs[i] = buffer.readImageFilter(); } else { fInputs[i] = NULL; } if (!buffer.isValid()) { fInputCount = i; // Do not use fInputs past that point in the destructor break; } } SkRect rect; buffer.readRect(&rect); if (buffer.isValid() && buffer.validate(SkIsValidRect(rect))) { uint32_t flags = buffer.readUInt(); fCropRect = CropRect(rect, flags); } } else { fInputCount = 0; fInputs = NULL; } }
bool SkImageFilter::Common::unflatten(SkReadBuffer& buffer, int expectedCount) { int count = buffer.readInt(); if (expectedCount < 0) { // means the caller doesn't care how many expectedCount = count; } if (!buffer.validate((count == expectedCount) && (count >= 0))) { return false; } this->allocInputs(count); for (int i = 0; i < count; i++) { if (buffer.readBool()) { fInputs[i] = buffer.readImageFilter(); } if (!buffer.isValid()) { return false; } } SkRect rect; buffer.readRect(&rect); if (!buffer.isValid() || !buffer.validate(SkIsValidRect(rect))) { return false; } uint32_t flags = buffer.readUInt(); fCropRect = CropRect(rect, flags); return buffer.isValid(); }
SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input) { if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { return nullptr; } if (srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height()) { SkRect ir = dstRect; if (!ir.intersect(srcRect)) { return SkSafeRef(input); } CropRect cropRect(ir); return SkOffsetImageFilter::Create(dstRect.x() - srcRect.x(), dstRect.y() - srcRect.y(), input, &cropRect); } return new SkTileImageFilter(srcRect, dstRect, input); }
sk_sp<SkImageFilter> SkTileImageFilter::Make(const SkRect& srcRect, const SkRect& dstRect, sk_sp<SkImageFilter> input) { if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { return nullptr; } if (srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height()) { SkRect ir = dstRect; if (!ir.intersect(srcRect)) { return input; } CropRect cropRect(ir); return SkOffsetImageFilter::Make(dstRect.x() - srcRect.x(), dstRect.y() - srcRect.y(), std::move(input), &cropRect); } return sk_sp<SkImageFilter>(new SkTileImageFilter(srcRect, dstRect, std::move(input))); }
SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar inset, SkImageFilter* input) { if (!SkScalarIsFinite(inset) || !SkIsValidRect(srcRect)) { return NULL; } // Negative numbers in src rect are not supported if (srcRect.fLeft < 0 || srcRect.fTop < 0) { return NULL; } return SkNEW_ARGS(SkMagnifierImageFilter, (srcRect, inset, input)); }
sk_sp<SkImageFilter> SkMagnifierImageFilter::Make(const SkRect& srcRect, SkScalar inset, sk_sp<SkImageFilter> input) { if (!SkScalarIsFinite(inset) || !SkIsValidRect(srcRect)) { return nullptr; } // Negative numbers in src rect are not supported if (srcRect.fLeft < 0 || srcRect.fTop < 0) { return nullptr; } return sk_sp<SkImageFilter>(new SkMagnifierImageFilter(srcRect, inset, std::move(input))); }