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

Side by Side Diff: src/core/SkLatticeIter.cpp

Issue 2255963002: Batched implementation of drawLattice() for GPU (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Speculative reland Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/core/SkLatticeIter.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLatticeIter.h" 8 #include "SkLatticeIter.h"
9 #include "SkRect.h" 9 #include "SkRect.h"
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 set_points(fDstX.begin(), fSrcX.begin(), xDivs, xCount, xCountFixed, xCountS calable, 152 set_points(fDstX.begin(), fSrcX.begin(), xDivs, xCount, xCountFixed, xCountS calable,
153 dst.fLeft, dst.fRight, xIsScalable); 153 dst.fLeft, dst.fRight, xIsScalable);
154 154
155 fSrcY.reset(yCount + 2); 155 fSrcY.reset(yCount + 2);
156 fDstY.reset(yCount + 2); 156 fDstY.reset(yCount + 2);
157 set_points(fDstY.begin(), fSrcY.begin(), yDivs, yCount, yCountFixed, yCountS calable, 157 set_points(fDstY.begin(), fSrcY.begin(), yDivs, yCount, yCountFixed, yCountS calable,
158 dst.fTop, dst.fBottom, yIsScalable); 158 dst.fTop, dst.fBottom, yIsScalable);
159 159
160 fCurrX = fCurrY = 0; 160 fCurrX = fCurrY = 0;
161 fDone = false; 161 fDone = false;
162 fNumRects = (xCount + 1) * (yCount + 1);
162 } 163 }
163 164
164 bool SkLatticeIter::Valid(int width, int height, const SkIRect& center) { 165 bool SkLatticeIter::Valid(int width, int height, const SkIRect& center) {
165 return !center.isEmpty() && SkIRect::MakeWH(width, height).contains(center); 166 return !center.isEmpty() && SkIRect::MakeWH(width, height).contains(center);
166 } 167 }
167 168
168 SkLatticeIter::SkLatticeIter(int w, int h, const SkIRect& c, const SkRect& dst) { 169 SkLatticeIter::SkLatticeIter(int w, int h, const SkIRect& c, const SkRect& dst) {
169 SkASSERT(SkIRect::MakeWH(w, h).contains(c)); 170 SkASSERT(SkIRect::MakeWH(w, h).contains(c));
170 171
171 fSrcX.reset(4); 172 fSrcX.reset(4);
(...skipping 26 matching lines...) Expand all
198 fDstX[2] = fDstX[1]; 199 fDstX[2] = fDstX[1];
199 } 200 }
200 201
201 if (fDstY[1] > fDstY[2]) { 202 if (fDstY[1] > fDstY[2]) {
202 fDstY[1] = fDstY[0] + (fDstY[3] - fDstY[0]) * c.fTop / (h - c.height()); 203 fDstY[1] = fDstY[0] + (fDstY[3] - fDstY[0]) * c.fTop / (h - c.height());
203 fDstY[2] = fDstY[1]; 204 fDstY[2] = fDstY[1];
204 } 205 }
205 206
206 fCurrX = fCurrY = 0; 207 fCurrX = fCurrY = 0;
207 fDone = false; 208 fDone = false;
209 fNumRects = 9;
208 } 210 }
209 211
210 bool SkLatticeIter::next(SkRect* src, SkRect* dst) { 212 bool SkLatticeIter::next(SkRect* src, SkRect* dst) {
211 if (fDone) { 213 if (fDone) {
212 return false; 214 return false;
213 } 215 }
214 216
215 const int x = fCurrX; 217 const int x = fCurrX;
216 const int y = fCurrY; 218 const int y = fCurrY;
217 SkASSERT(x >= 0 && x < fSrcX.count() - 1); 219 SkASSERT(x >= 0 && x < fSrcX.count() - 1);
218 SkASSERT(y >= 0 && y < fSrcY.count() - 1); 220 SkASSERT(y >= 0 && y < fSrcY.count() - 1);
219 221
220 src->set(fSrcX[x], fSrcY[y], fSrcX[x + 1], fSrcY[y + 1]); 222 src->set(fSrcX[x], fSrcY[y], fSrcX[x + 1], fSrcY[y + 1]);
221 dst->set(fDstX[x], fDstY[y], fDstX[x + 1], fDstY[y + 1]); 223 dst->set(fDstX[x], fDstY[y], fDstX[x + 1], fDstY[y + 1]);
222 if (fSrcX.count() - 1 == ++fCurrX) { 224 if (fSrcX.count() - 1 == ++fCurrX) {
223 fCurrX = 0; 225 fCurrX = 0;
224 fCurrY += 1; 226 fCurrY += 1;
225 if (fCurrY >= fSrcY.count() - 1) { 227 if (fCurrY >= fSrcY.count() - 1) {
226 fDone = true; 228 fDone = true;
227 } 229 }
228 } 230 }
229 return true; 231 return true;
230 } 232 }
233
234 void SkLatticeIter::mapDstScaleTranslate(const SkMatrix& matrix) {
235 SkASSERT(matrix.isScaleTranslate());
236 SkScalar tx = matrix.getTranslateX();
237 SkScalar sx = matrix.getScaleX();
238 for (int i = 0; i < fDstX.count(); i++) {
239 fDstX[i] = fDstX[i] * sx + tx;
240 }
241
242 SkScalar ty = matrix.getTranslateY();
243 SkScalar sy = matrix.getScaleY();
244 for (int i = 0; i < fDstY.count(); i++) {
245 fDstY[i] = fDstY[i] * sy + ty;
246 }
247 }
OLDNEW
« no previous file with comments | « src/core/SkLatticeIter.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698