xref: /aosp_15_r20/external/skia/src/encode/SkEncoder.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2023 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "include/encode/SkEncoder.h"
9 
10 #include "include/private/base/SkAssert.h"
11 
encodeRows(int numRows)12 bool SkEncoder::encodeRows(int numRows) {
13     SkASSERT(numRows > 0 && fCurrRow < fSrc.height());
14     if (numRows <= 0 || fCurrRow >= fSrc.height()) {
15         return false;
16     }
17 
18     if (fCurrRow + numRows > fSrc.height()) {
19         numRows = fSrc.height() - fCurrRow;
20     }
21 
22     if (!this->onEncodeRows(numRows)) {
23         // If we fail, short circuit any future calls.
24         fCurrRow = fSrc.height();
25         return false;
26     }
27 
28     return true;
29 }
30