OLD | NEW |
---|---|
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 "SkRect.h" | 10 #include "SkRect.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 REPORTER_ASSERT(reporter, srcPremul.getGenerationID() == dst .getGenerationID()); | 303 REPORTER_ASSERT(reporter, srcPremul.getGenerationID() == dst .getGenerationID()); |
304 } else { | 304 } else { |
305 REPORTER_ASSERT(reporter, srcPremul.getGenerationID() != dst .getGenerationID()); | 305 REPORTER_ASSERT(reporter, srcPremul.getGenerationID() != dst .getGenerationID()); |
306 } | 306 } |
307 // test extractSubset | 307 // test extractSubset |
308 { | 308 { |
309 SkBitmap bitmap(srcOpaque); | 309 SkBitmap bitmap(srcOpaque); |
310 SkBitmap subset; | 310 SkBitmap subset; |
311 SkIRect r; | 311 SkIRect r; |
312 r.set(1, 1, 2, 2); | 312 r.set(1, 1, 2, 2); |
313 <<<<<<< HEAD | |
scroggo
2013/10/18 19:32:40
Needs merge.
| |
314 ======= | |
315 bitmap.setAlphaType(kOpaque_SkAlphaType); | |
316 >>>>>>> store SkAlphaType inside SkBitmap, on road to support unpremul | |
313 bitmap.setIsVolatile(true); | 317 bitmap.setIsVolatile(true); |
314 if (bitmap.extractSubset(&subset, r)) { | 318 if (bitmap.extractSubset(&subset, r)) { |
315 REPORTER_ASSERT(reporter, subset.width() == 1); | 319 REPORTER_ASSERT(reporter, subset.width() == 1); |
316 REPORTER_ASSERT(reporter, subset.height() == 1); | 320 REPORTER_ASSERT(reporter, subset.height() == 1); |
317 REPORTER_ASSERT(reporter, | 321 REPORTER_ASSERT(reporter, |
318 subset.isOpaque() == bitmap.isOpaque()); | 322 subset.isOpaque() == bitmap.isOpaque()); |
319 REPORTER_ASSERT(reporter, | 323 REPORTER_ASSERT(reporter, |
320 subset.isVolatile() == true); | 324 subset.isVolatile() == true); |
321 | 325 |
322 SkBitmap copy; | 326 SkBitmap copy; |
323 REPORTER_ASSERT(reporter, | 327 REPORTER_ASSERT(reporter, |
324 subset.copyTo(©, subset.config())); | 328 subset.copyTo(©, subset.config())); |
325 REPORTER_ASSERT(reporter, copy.width() == 1); | 329 REPORTER_ASSERT(reporter, copy.width() == 1); |
326 REPORTER_ASSERT(reporter, copy.height() == 1); | 330 REPORTER_ASSERT(reporter, copy.height() == 1); |
327 REPORTER_ASSERT(reporter, copy.rowBytes() <= 4); | 331 REPORTER_ASSERT(reporter, copy.rowBytes() <= 4); |
328 | 332 |
329 SkAutoLockPixels alp0(subset); | 333 SkAutoLockPixels alp0(subset); |
330 SkAutoLockPixels alp1(copy); | 334 SkAutoLockPixels alp1(copy); |
331 // they should both have, or both not-have, a colortable | 335 // they should both have, or both not-have, a colortable |
332 bool hasCT = subset.getColorTable() != NULL; | 336 bool hasCT = subset.getColorTable() != NULL; |
333 REPORTER_ASSERT(reporter, | 337 REPORTER_ASSERT(reporter, |
334 (copy.getColorTable() != NULL) == hasCT); | 338 (copy.getColorTable() != NULL) == hasCT); |
335 } | 339 } |
340 <<<<<<< HEAD | |
336 | 341 |
337 bitmap = srcPremul; | 342 bitmap = srcPremul; |
343 ======= | |
344 bitmap.setAlphaType(kPremul_SkAlphaType); | |
345 >>>>>>> store SkAlphaType inside SkBitmap, on road to support unpremul | |
338 bitmap.setIsVolatile(false); | 346 bitmap.setIsVolatile(false); |
339 if (bitmap.extractSubset(&subset, r)) { | 347 if (bitmap.extractSubset(&subset, r)) { |
340 REPORTER_ASSERT(reporter, | 348 REPORTER_ASSERT(reporter, |
341 subset.isOpaque() == bitmap.isOpaque()); | 349 subset.isOpaque() == bitmap.isOpaque()); |
342 REPORTER_ASSERT(reporter, | 350 REPORTER_ASSERT(reporter, |
343 subset.isVolatile() == false); | 351 subset.isVolatile() == false); |
344 } | 352 } |
345 } | 353 } |
346 } else { | 354 } else { |
347 // dst should be unchanged from its initial state | 355 // dst should be unchanged from its initial state |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 false); | 603 false); |
596 | 604 |
597 #endif | 605 #endif |
598 } | 606 } |
599 } // for (size_t copyCase ... | 607 } // for (size_t copyCase ... |
600 } | 608 } |
601 } | 609 } |
602 | 610 |
603 #include "TestClassDef.h" | 611 #include "TestClassDef.h" |
604 DEFINE_TESTCLASS("BitmapCopy", TestBitmapCopyClass, TestBitmapCopy) | 612 DEFINE_TESTCLASS("BitmapCopy", TestBitmapCopyClass, TestBitmapCopy) |
OLD | NEW |