OLD | NEW |
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 "SkPath.h" | 8 #include "SkPath.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkRegion.h" | 10 #include "SkRegion.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 test_proc(reporter, contains_proc); | 260 test_proc(reporter, contains_proc); |
261 test_proc(reporter, intersects_proc); | 261 test_proc(reporter, intersects_proc); |
262 test_empties(reporter); | 262 test_empties(reporter); |
263 test_fromchrome(reporter); | 263 test_fromchrome(reporter); |
264 } | 264 } |
265 | 265 |
266 // Test that writeToMemory reports the same number of bytes whether there was a | 266 // Test that writeToMemory reports the same number of bytes whether there was a |
267 // buffer to write to or not. | 267 // buffer to write to or not. |
268 static void test_write(const SkRegion& region, skiatest::Reporter* r) { | 268 static void test_write(const SkRegion& region, skiatest::Reporter* r) { |
269 const size_t bytesNeeded = region.writeToMemory(NULL); | 269 const size_t bytesNeeded = region.writeToMemory(nullptr); |
270 SkAutoMalloc storage(bytesNeeded); | 270 SkAutoMalloc storage(bytesNeeded); |
271 const size_t bytesWritten = region.writeToMemory(storage.get()); | 271 const size_t bytesWritten = region.writeToMemory(storage.get()); |
272 REPORTER_ASSERT(r, bytesWritten == bytesNeeded); | 272 REPORTER_ASSERT(r, bytesWritten == bytesNeeded); |
273 } | 273 } |
274 | 274 |
275 DEF_TEST(Region_writeToMemory, r) { | 275 DEF_TEST(Region_writeToMemory, r) { |
276 // Test an empty region. | 276 // Test an empty region. |
277 SkRegion region; | 277 SkRegion region; |
278 REPORTER_ASSERT(r, region.isEmpty()); | 278 REPORTER_ASSERT(r, region.isEmpty()); |
279 test_write(region, r); | 279 test_write(region, r); |
280 | 280 |
281 // Test a rectangular region | 281 // Test a rectangular region |
282 bool nonEmpty = region.setRect(0, 0, 50, 50); | 282 bool nonEmpty = region.setRect(0, 0, 50, 50); |
283 REPORTER_ASSERT(r, nonEmpty); | 283 REPORTER_ASSERT(r, nonEmpty); |
284 REPORTER_ASSERT(r, region.isRect()); | 284 REPORTER_ASSERT(r, region.isRect()); |
285 test_write(region, r); | 285 test_write(region, r); |
286 | 286 |
287 // Test a complex region | 287 // Test a complex region |
288 nonEmpty = region.op(50, 50, 100, 100, SkRegion::kUnion_Op); | 288 nonEmpty = region.op(50, 50, 100, 100, SkRegion::kUnion_Op); |
289 REPORTER_ASSERT(r, nonEmpty); | 289 REPORTER_ASSERT(r, nonEmpty); |
290 REPORTER_ASSERT(r, region.isComplex()); | 290 REPORTER_ASSERT(r, region.isComplex()); |
291 test_write(region, r); | 291 test_write(region, r); |
292 } | 292 } |
OLD | NEW |