Add subspan() to SkSpan

Change-Id: I1ac2ec8cf22a96c50261ca3863edeb0ed3c24dd6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287579
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2020-05-04 14:05:22 -04:00 committed by Skia Commit-Bot
parent 96d31defe3
commit d16e322f02

View File

@ -50,6 +50,12 @@ public:
if (postfixLen == 0) { return SkSpan{}; }
return SkSpan{fPtr + (this->size() - postfixLen), postfixLen};
}
constexpr SkSpan<T> subspan(size_t offset, size_t count) const {
SkASSERT(offset <= this->size());
SkASSERT(count <= this->size - offset);
if (count == 0) { return SkSpan{}; }
return SkSpan{fPtr + offset, count};
}
private:
T* fPtr;