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: tests/DrawBitmapRectTest.cpp

Issue 85463005: remove SkFloatToScalar macro (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add flag to expose SkFloatToScalar to chromium Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « tests/ClipperTest.cpp ('k') | tests/DrawTextTest.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 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "Test.h" 8 #include "Test.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_ Mask); 113 rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_ Mask);
114 for (int j = 0; j < 1000; ++j) { 114 for (int j = 0; j < 1000; ++j) {
115 rand_size(&size, rand); 115 rand_size(&size, rand);
116 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, 0)); 116 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, 0));
117 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); 117 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
118 } 118 }
119 } 119 }
120 120
121 size.set(500, 600); 121 size.set(500, 600);
122 122
123 const SkScalar tooMuchSubpixel = SkFloatToScalar(100.1f); 123 const SkScalar tooMuchSubpixel = 100.1f;
124 mat.setTranslate(tooMuchSubpixel, 0); 124 mat.setTranslate(tooMuchSubpixel, 0);
125 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); 125 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
126 mat.setTranslate(0, tooMuchSubpixel); 126 mat.setTranslate(0, tooMuchSubpixel);
127 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); 127 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
128 128
129 const SkScalar tinySubPixel = SkFloatToScalar(100.02f); 129 const SkScalar tinySubPixel = 100.02f;
130 mat.setTranslate(tinySubPixel, 0); 130 mat.setTranslate(tinySubPixel, 0);
131 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); 131 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
132 mat.setTranslate(0, tinySubPixel); 132 mat.setTranslate(0, tinySubPixel);
133 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); 133 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
134 134
135 const SkScalar twoThirds = SK_Scalar1 * 2 / 3; 135 const SkScalar twoThirds = SK_Scalar1 * 2 / 3;
136 const SkScalar bigScale = SkScalarDiv(size.width() + twoThirds, size.width() ); 136 const SkScalar bigScale = SkScalarDiv(size.width() + twoThirds, size.width() );
137 mat.setScale(bigScale, bigScale); 137 mat.setScale(bigScale, bigScale);
138 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false)); 138 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false));
139 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); 139 REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 static void test_wacky_bitmapshader(skiatest::Reporter* reporter, 174 static void test_wacky_bitmapshader(skiatest::Reporter* reporter,
175 int width, int height, bool shouldBeDrawn) { 175 int width, int height, bool shouldBeDrawn) {
176 SkBitmap dev; 176 SkBitmap dev;
177 dev.setConfig(SkBitmap::kARGB_8888_Config, 0x56F, 0x4f6); 177 dev.setConfig(SkBitmap::kARGB_8888_Config, 0x56F, 0x4f6);
178 dev.allocPixels(); 178 dev.allocPixels();
179 dev.eraseColor(SK_ColorTRANSPARENT); // necessary, so we know if we draw to it 179 dev.eraseColor(SK_ColorTRANSPARENT); // necessary, so we know if we draw to it
180 180
181 SkMatrix matrix; 181 SkMatrix matrix;
182 182
183 SkCanvas c(dev); 183 SkCanvas c(dev);
184 matrix.setAll(SkFloatToScalar(-119.34097f), 184 matrix.setAll(-119.34097f,
185 SkFloatToScalar(-43.436558f), 185 -43.436558f,
186 SkFloatToScalar(93489.945f), 186 93489.945f,
187 SkFloatToScalar(43.436558f), 187 43.436558f,
188 SkFloatToScalar(-119.34097f), 188 -119.34097f,
189 SkFloatToScalar(123.98426f), 189 123.98426f,
190 0, 0, SK_Scalar1); 190 0, 0, SK_Scalar1);
191 c.concat(matrix); 191 c.concat(matrix);
192 192
193 SkBitmap bm; 193 SkBitmap bm;
194 bm.setConfig(SkBitmap::kARGB_8888_Config, width, height); 194 bm.setConfig(SkBitmap::kARGB_8888_Config, width, height);
195 bm.allocPixels(); 195 bm.allocPixels();
196 bm.eraseColor(SK_ColorRED); 196 bm.eraseColor(SK_ColorRED);
197 197
198 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, 198 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
199 SkShader::kRepeat_TileMode); 199 SkShader::kRepeat_TileMode);
200 matrix.setAll(SkFloatToScalar(0.0078740157f), 200 matrix.setAll(0.0078740157f,
201 0, 201 0,
202 SkIntToScalar(249), 202 SkIntToScalar(249),
203 0, 203 0,
204 SkFloatToScalar(0.0078740157f), 204 0.0078740157f,
205 SkIntToScalar(239), 205 SkIntToScalar(239),
206 0, 0, SK_Scalar1); 206 0, 0, SK_Scalar1);
207 s->setLocalMatrix(matrix); 207 s->setLocalMatrix(matrix);
208 208
209 SkPaint paint; 209 SkPaint paint;
210 paint.setShader(s)->unref(); 210 paint.setShader(s)->unref();
211 211
212 SkRect r = SkRect::MakeXYWH(681, 239, 695, 253); 212 SkRect r = SkRect::MakeXYWH(681, 239, 695, 253);
213 c.drawRect(r, paint); 213 c.drawRect(r, paint);
214 214
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 test_nan_antihair(); 321 test_nan_antihair();
322 test_giantrepeat_crbug118018(reporter); 322 test_giantrepeat_crbug118018(reporter);
323 323
324 test_treatAsSprite(reporter); 324 test_treatAsSprite(reporter);
325 test_faulty_pixelref(reporter); 325 test_faulty_pixelref(reporter);
326 } 326 }
327 327
328 #include "TestClassDef.h" 328 #include "TestClassDef.h"
329 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) 329 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect)
OLDNEW
« no previous file with comments | « tests/ClipperTest.cpp ('k') | tests/DrawTextTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698