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

Side by Side Diff: tests/DrawBitmapRectTest.cpp

Issue 1138263002: 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/SkNinePatch.cpp ('k') | tests/MatrixTest.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 mat.setTranslate(0, tooMuchSubpixel); 117 mat.setTranslate(0, tooMuchSubpixel);
118 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); 118 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
119 119
120 const SkScalar tinySubPixel = 100.02f; 120 const SkScalar tinySubPixel = 100.02f;
121 mat.setTranslate(tinySubPixel, 0); 121 mat.setTranslate(tinySubPixel, 0);
122 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); 122 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
123 mat.setTranslate(0, tinySubPixel); 123 mat.setTranslate(0, tinySubPixel);
124 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); 124 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
125 125
126 const SkScalar twoThirds = SK_Scalar1 * 2 / 3; 126 const SkScalar twoThirds = SK_Scalar1 * 2 / 3;
127 const SkScalar bigScale = (size.width() + twoThirds) / size.width(); 127 const SkScalar bigScale = SkScalarDiv(size.width() + twoThirds, size.width() );
128 mat.setScale(bigScale, bigScale); 128 mat.setScale(bigScale, bigScale);
129 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false)); 129 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false));
130 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); 130 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
131 131
132 const SkScalar oneThird = SK_Scalar1 / 3; 132 const SkScalar oneThird = SK_Scalar1 / 3;
133 const SkScalar smallScale = (size.width() + oneThird) / size.width(); 133 const SkScalar smallScale = SkScalarDiv(size.width() + oneThird, size.width( ));
134 mat.setScale(smallScale, smallScale); 134 mat.setScale(smallScale, smallScale);
135 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); 135 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false));
136 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); 136 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
137 137
138 const SkScalar oneFortyth = SK_Scalar1 / 40; 138 const SkScalar oneFortyth = SK_Scalar1 / 40;
139 const SkScalar tinyScale = (size.width() + oneFortyth) / size.width(); 139 const SkScalar tinyScale = SkScalarDiv(size.width() + oneFortyth, size.width ());
140 mat.setScale(tinyScale, tinyScale); 140 mat.setScale(tinyScale, tinyScale);
141 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); 141 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false));
142 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); 142 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
143 } 143 }
144 144
145 static void assert_ifDrawnTo(skiatest::Reporter* reporter, 145 static void assert_ifDrawnTo(skiatest::Reporter* reporter,
146 const SkBitmap& bm, bool shouldBeDrawn) { 146 const SkBitmap& bm, bool shouldBeDrawn) {
147 for (int y = 0; y < bm.height(); ++y) { 147 for (int y = 0; y < bm.height(); ++y) {
148 for (int x = 0; x < bm.width(); ++x) { 148 for (int x = 0; x < bm.width(); ++x) {
149 if (shouldBeDrawn) { 149 if (shouldBeDrawn) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 // ensure that we draw nothing if srcR does not intersect the bitmap 304 // ensure that we draw nothing if srcR does not intersect the bitmap
305 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); 305 REPORTER_ASSERT(reporter, check_for_all_zeros(dst));
306 306
307 test_nan_antihair(); 307 test_nan_antihair();
308 test_giantrepeat_crbug118018(reporter); 308 test_giantrepeat_crbug118018(reporter);
309 309
310 test_treatAsSprite(reporter); 310 test_treatAsSprite(reporter);
311 test_faulty_pixelref(reporter); 311 test_faulty_pixelref(reporter);
312 } 312 }
OLDNEW
« no previous file with comments | « src/utils/SkNinePatch.cpp ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698