diff options
Diffstat (limited to 'gfx/skia/skia/src/encode/SkEncoder.cpp')
-rw-r--r-- | gfx/skia/skia/src/encode/SkEncoder.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/encode/SkEncoder.cpp b/gfx/skia/skia/src/encode/SkEncoder.cpp new file mode 100644 index 0000000000..a2d6f05b46 --- /dev/null +++ b/gfx/skia/skia/src/encode/SkEncoder.cpp @@ -0,0 +1,29 @@ +/* + * Copyright 2023 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "include/encode/SkEncoder.h" + +#include "include/private/base/SkAssert.h" + +bool SkEncoder::encodeRows(int numRows) { + SkASSERT(numRows > 0 && fCurrRow < fSrc.height()); + if (numRows <= 0 || fCurrRow >= fSrc.height()) { + return false; + } + + if (fCurrRow + numRows > fSrc.height()) { + numRows = fSrc.height() - fCurrRow; + } + + if (!this->onEncodeRows(numRows)) { + // If we fail, short circuit any future calls. + fCurrRow = fSrc.height(); + return false; + } + + return true; +} |