Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: src/core/SkLatticeIter.cpp

Issue 2305433002: Add option to skip rects to drawImageLattice() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: numRectsToDraw() Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkLatticeIter.cpp
diff --git a/src/core/SkLatticeIter.cpp b/src/core/SkLatticeIter.cpp
index ba6ac97a5b4395807a22c482b05e95ccc985eb0c..91f9ae960fc56c718fb6837fc7d72384a14988d7 100644
--- a/src/core/SkLatticeIter.cpp
+++ b/src/core/SkLatticeIter.cpp
@@ -158,8 +158,18 @@ SkLatticeIter::SkLatticeIter(int srcWidth, int srcHeight, const SkCanvas::Lattic
dst.fTop, dst.fBottom, yIsScalable);
fCurrX = fCurrY = 0;
- fDone = false;
- fNumRects = (xCount + 1) * (yCount + 1);
+ fNumRectsInLattice = (xCount + 1) * (yCount + 1);
+ fNumRectsToDraw = fNumRectsInLattice;
+
+ if (lattice.fFlags && fNumRectsInLattice == lattice.fFlagCount) {
+ fFlags.push_back_n(lattice.fFlagCount, lattice.fFlags);
+
+ for (int i = 0; i < lattice.fFlagCount; i++) {
+ if (SkCanvas::Lattice::kSkip_Flags == fFlags[i]) {
+ fNumRectsToDraw--;
+ }
+ }
+ }
}
bool SkLatticeIter::Valid(int width, int height, const SkIRect& center) {
@@ -205,12 +215,13 @@ SkLatticeIter::SkLatticeIter(int w, int h, const SkIRect& c, const SkRect& dst)
}
fCurrX = fCurrY = 0;
- fDone = false;
- fNumRects = 9;
+ fNumRectsInLattice = 9;
+ fNumRectsToDraw = 9;
}
bool SkLatticeIter::next(SkRect* src, SkRect* dst) {
- if (fDone) {
+ int currRect = fCurrX + fCurrY * (fSrcX.count() - 1);
+ if (currRect == fNumRectsInLattice) {
return false;
}
@@ -219,15 +230,17 @@ bool SkLatticeIter::next(SkRect* src, SkRect* dst) {
SkASSERT(x >= 0 && x < fSrcX.count() - 1);
SkASSERT(y >= 0 && y < fSrcY.count() - 1);
- src->set(fSrcX[x], fSrcY[y], fSrcX[x + 1], fSrcY[y + 1]);
- dst->set(fDstX[x], fDstY[y], fDstX[x + 1], fDstY[y + 1]);
if (fSrcX.count() - 1 == ++fCurrX) {
fCurrX = 0;
fCurrY += 1;
- if (fCurrY >= fSrcY.count() - 1) {
- fDone = true;
- }
}
+
+ if (fFlags.count() > 0 && SkToBool(SkCanvas::Lattice::kSkip_Flags & fFlags[currRect])) {
+ return this->next(src, dst);
+ }
+
+ src->set(fSrcX[x], fSrcY[y], fSrcX[x + 1], fSrcY[y + 1]);
+ dst->set(fDstX[x], fDstY[y], fDstX[x + 1], fDstY[y + 1]);
return true;
}
« include/core/SkCanvas.h ('K') | « src/core/SkLatticeIter.h ('k') | src/core/SkLiteDL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698