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

Side by Side Diff: src/utils/SkNinePatch.cpp

Issue 1135693003: Revert of Revert of stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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/utils/SkInterpolator.cpp ('k') | tests/DrawBitmapRectTest.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkNinePatch.h" 10 #include "SkNinePatch.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 if (numXStretch > 0) { 155 if (numXStretch > 0) {
156 int stretchSize = 0; 156 int stretchSize = 0;
157 for (int i = 1; i < numXDivs; i += 2) { 157 for (int i = 1; i < numXDivs; i += 2) {
158 stretchSize += xDivs[i] - xDivs[i-1]; 158 stretchSize += xDivs[i] - xDivs[i-1];
159 } 159 }
160 const SkScalar fixed = SkIntToScalar(bitmap.width() - stretchSize); 160 const SkScalar fixed = SkIntToScalar(bitmap.width() - stretchSize);
161 if (bounds.width() >= fixed) 161 if (bounds.width() >= fixed)
162 stretchX = (bounds.width() - fixed) / stretchSize; 162 stretchX = (bounds.width() - fixed) / stretchSize;
163 else // reuse stretchX, but keep it negative as a signal 163 else // reuse stretchX, but keep it negative as a signal
164 stretchX = SkScalarDiv(-bounds.width(), fixed); 164 stretchX = -bounds.width() / fixed;
165 } 165 }
166 166
167 if (numYStretch > 0) { 167 if (numYStretch > 0) {
168 int stretchSize = 0; 168 int stretchSize = 0;
169 for (int i = 1; i < numYDivs; i += 2) { 169 for (int i = 1; i < numYDivs; i += 2) {
170 stretchSize += yDivs[i] - yDivs[i-1]; 170 stretchSize += yDivs[i] - yDivs[i-1];
171 } 171 }
172 const SkScalar fixed = SkIntToScalar(bitmap.height() - stretchSize); 172 const SkScalar fixed = SkIntToScalar(bitmap.height() - stretchSize);
173 if (bounds.height() >= fixed) 173 if (bounds.height() >= fixed)
174 stretchY = (bounds.height() - fixed) / stretchSize; 174 stretchY = (bounds.height() - fixed) / stretchSize;
175 else // reuse stretchX, but keep it negative as a signal 175 else // reuse stretchX, but keep it negative as a signal
176 stretchY = SkScalarDiv(-bounds.height(), fixed); 176 stretchY = -bounds.height() / fixed;
177 } 177 }
178 178
179 #if 0 179 #if 0
180 SkDebugf("---- drawasamesh [%d %d] -> [%g %g] <%d %d> (%g %g)\n", 180 SkDebugf("---- drawasamesh [%d %d] -> [%g %g] <%d %d> (%g %g)\n",
181 bitmap.width(), bitmap.height(), 181 bitmap.width(), bitmap.height(),
182 SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()), 182 SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()),
183 numXDivs + 1, numYDivs + 1, 183 numXDivs + 1, numYDivs + 1,
184 SkScalarToFloat(stretchX), SkScalarToFloat(stretchY)); 184 SkScalarToFloat(stretchX), SkScalarToFloat(stretchY));
185 #endif 185 #endif
186 186
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 (margins.fTop + margins.fBottom); 326 (margins.fTop + margins.fBottom);
327 yDivs[1] = yDivs[0]; 327 yDivs[1] = yDivs[0];
328 } 328 }
329 329
330 SkNinePatch::DrawMesh(canvas, bounds, bitmap, 330 SkNinePatch::DrawMesh(canvas, bounds, bitmap,
331 xDivs, 2, yDivs, 2, paint); 331 xDivs, 2, yDivs, 2, paint);
332 } else { 332 } else {
333 drawNineViaRects(canvas, bounds, bitmap, margins, paint); 333 drawNineViaRects(canvas, bounds, bitmap, margins, paint);
334 } 334 }
335 } 335 }
OLDNEW
« no previous file with comments | « src/utils/SkInterpolator.cpp ('k') | tests/DrawBitmapRectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698