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

Side by Side Diff: tests/BitmapCopyTest.cpp

Issue 17740003: remove kRLE_Index8_Config from SkBitmap (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/pdf/SkPDFImage.cpp ('k') | no next file » | 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 "SkRect.h" 10 #include "SkRect.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // simplify diagnostic output. 176 // simplify diagnostic output.
177 static const char* getSkConfigName(const SkBitmap& bm) { 177 static const char* getSkConfigName(const SkBitmap& bm) {
178 switch (bm.getConfig()) { 178 switch (bm.getConfig()) {
179 case SkBitmap::kNo_Config: return "SkBitmap::kNo_Config"; 179 case SkBitmap::kNo_Config: return "SkBitmap::kNo_Config";
180 case SkBitmap::kA1_Config: return "SkBitmap::kA1_Config"; 180 case SkBitmap::kA1_Config: return "SkBitmap::kA1_Config";
181 case SkBitmap::kA8_Config: return "SkBitmap::kA8_Config"; 181 case SkBitmap::kA8_Config: return "SkBitmap::kA8_Config";
182 case SkBitmap::kIndex8_Config: return "SkBitmap::kIndex8_Config"; 182 case SkBitmap::kIndex8_Config: return "SkBitmap::kIndex8_Config";
183 case SkBitmap::kRGB_565_Config: return "SkBitmap::kRGB_565_Config"; 183 case SkBitmap::kRGB_565_Config: return "SkBitmap::kRGB_565_Config";
184 case SkBitmap::kARGB_4444_Config: return "SkBitmap::kARGB_4444_Config"; 184 case SkBitmap::kARGB_4444_Config: return "SkBitmap::kARGB_4444_Config";
185 case SkBitmap::kARGB_8888_Config: return "SkBitmap::kARGB_8888_Config"; 185 case SkBitmap::kARGB_8888_Config: return "SkBitmap::kARGB_8888_Config";
186 case SkBitmap::kRLE_Index8_Config:
187 return "SkBitmap::kRLE_Index8_Config,";
188 default: return "Unknown SkBitmap configuration."; 186 default: return "Unknown SkBitmap configuration.";
189 } 187 }
190 } 188 }
191 189
192 // Helper struct to contain pixel locations, while avoiding need for STL. 190 // Helper struct to contain pixel locations, while avoiding need for STL.
193 struct Coordinates { 191 struct Coordinates {
194 192
195 const int length; 193 const int length;
196 SkIPoint* const data; 194 SkIPoint* const data;
197 195
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 238
241 static void TestBitmapCopy(skiatest::Reporter* reporter) { 239 static void TestBitmapCopy(skiatest::Reporter* reporter) {
242 static const Pair gPairs[] = { 240 static const Pair gPairs[] = {
243 { SkBitmap::kNo_Config, "00000000" }, 241 { SkBitmap::kNo_Config, "00000000" },
244 { SkBitmap::kA1_Config, "01000000" }, 242 { SkBitmap::kA1_Config, "01000000" },
245 { SkBitmap::kA8_Config, "00101010" }, 243 { SkBitmap::kA8_Config, "00101010" },
246 { SkBitmap::kIndex8_Config, "00111010" }, 244 { SkBitmap::kIndex8_Config, "00111010" },
247 { SkBitmap::kRGB_565_Config, "00101010" }, 245 { SkBitmap::kRGB_565_Config, "00101010" },
248 { SkBitmap::kARGB_4444_Config, "00101110" }, 246 { SkBitmap::kARGB_4444_Config, "00101110" },
249 { SkBitmap::kARGB_8888_Config, "00101010" }, 247 { SkBitmap::kARGB_8888_Config, "00101010" },
250 // TODO: create valid RLE bitmap to test with
251 // { SkBitmap::kRLE_Index8_Config, "00101111" }
252 }; 248 };
253 249
254 static const bool isExtracted[] = { 250 static const bool isExtracted[] = {
255 false, true 251 false, true
256 }; 252 };
257 253
258 const int W = 20; 254 const int W = 20;
259 const int H = 33; 255 const int H = 33;
260 256
261 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) { 257 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) {
262 for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) { 258 for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) {
263 SkBitmap src, dst; 259 SkBitmap src, dst;
264 SkColorTable* ct = NULL; 260 SkColorTable* ct = NULL;
265 261
266 src.setConfig(gPairs[i].fConfig, W, H); 262 src.setConfig(gPairs[i].fConfig, W, H);
267 if (SkBitmap::kIndex8_Config == src.config() || 263 if (SkBitmap::kIndex8_Config == src.config()) {
268 SkBitmap::kRLE_Index8_Config == src.config()) {
269 ct = init_ctable(); 264 ct = init_ctable();
270 } 265 }
271 src.allocPixels(ct); 266 src.allocPixels(ct);
272 SkSafeUnref(ct); 267 SkSafeUnref(ct);
273 268
274 init_src(src, ct); 269 init_src(src, ct);
275 bool success = src.copyTo(&dst, gPairs[j].fConfig); 270 bool success = src.copyTo(&dst, gPairs[j].fConfig);
276 bool expected = gPairs[i].fValid[j] != '0'; 271 bool expected = gPairs[i].fValid[j] != '0';
277 if (success != expected) { 272 if (success != expected) {
278 SkString str; 273 SkString str;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } // for (size_t j = ... 353 } // for (size_t j = ...
359 354
360 // Tests for getSafeSize(), getSafeSize64(), copyPixelsTo(), 355 // Tests for getSafeSize(), getSafeSize64(), copyPixelsTo(),
361 // copyPixelsFrom(). 356 // copyPixelsFrom().
362 // 357 //
363 for (size_t copyCase = 0; copyCase < SK_ARRAY_COUNT(isExtracted); 358 for (size_t copyCase = 0; copyCase < SK_ARRAY_COUNT(isExtracted);
364 ++copyCase) { 359 ++copyCase) {
365 // Test copying to/from external buffer. 360 // Test copying to/from external buffer.
366 // Note: the tests below have hard-coded values --- 361 // Note: the tests below have hard-coded values ---
367 // Please take care if modifying. 362 // Please take care if modifying.
368 if (gPairs[i].fConfig != SkBitmap::kRLE_Index8_Config) { 363
369 364 // Tests for getSafeSize64().
370 // Tests for getSafeSize64(). 365 // Test with a very large configuration without pixel buffer
371 // Test with a very large configuration without pixel buffer 366 // attached.
372 // attached. 367 SkBitmap tstSafeSize;
373 SkBitmap tstSafeSize; 368 tstSafeSize.setConfig(gPairs[i].fConfig, 100000000U,
374 tstSafeSize.setConfig(gPairs[i].fConfig, 100000000U, 369 100000000U);
375 100000000U); 370 Sk64 safeSize = tstSafeSize.getSafeSize64();
376 Sk64 safeSize = tstSafeSize.getSafeSize64(); 371 if (safeSize.isNeg()) {
377 if (safeSize.isNeg()) { 372 SkString str;
378 SkString str; 373 str.printf("getSafeSize64() negative: %s",
379 str.printf("getSafeSize64() negative: %s", 374 getSkConfigName(tstSafeSize));
380 getSkConfigName(tstSafeSize)); 375 reporter->reportFailed(str);
381 reporter->reportFailed(str); 376 }
382 } 377 bool sizeFail = false;
383 bool sizeFail = false; 378 // Compare against hand-computed values.
384 // Compare against hand-computed values. 379 switch (gPairs[i].fConfig) {
385 switch (gPairs[i].fConfig) { 380 case SkBitmap::kNo_Config:
386 case SkBitmap::kNo_Config: 381 break;
387 break; 382
388 383 case SkBitmap::kA1_Config:
389 case SkBitmap::kA1_Config: 384 if (safeSize.fHi != 0x470DE ||
390 if (safeSize.fHi != 0x470DE || 385 safeSize.fLo != 0x4DF82000)
391 safeSize.fLo != 0x4DF82000) 386 sizeFail = true;
392 sizeFail = true; 387 break;
393 break; 388
394 389 case SkBitmap::kA8_Config:
395 case SkBitmap::kA8_Config: 390 case SkBitmap::kIndex8_Config:
396 case SkBitmap::kIndex8_Config: 391 if (safeSize.fHi != 0x2386F2 ||
397 if (safeSize.fHi != 0x2386F2 || 392 safeSize.fLo != 0x6FC10000)
398 safeSize.fLo != 0x6FC10000) 393 sizeFail = true;
399 sizeFail = true; 394 break;
400 break; 395
401 396 case SkBitmap::kRGB_565_Config:
402 case SkBitmap::kRGB_565_Config: 397 case SkBitmap::kARGB_4444_Config:
403 case SkBitmap::kARGB_4444_Config: 398 if (safeSize.fHi != 0x470DE4 ||
404 if (safeSize.fHi != 0x470DE4 || 399 safeSize.fLo != 0xDF820000)
405 safeSize.fLo != 0xDF820000) 400 sizeFail = true;
406 sizeFail = true; 401 break;
407 break; 402
408 403 case SkBitmap::kARGB_8888_Config:
409 case SkBitmap::kARGB_8888_Config: 404 if (safeSize.fHi != 0x8E1BC9 ||
410 if (safeSize.fHi != 0x8E1BC9 || 405 safeSize.fLo != 0xBF040000)
411 safeSize.fLo != 0xBF040000) 406 sizeFail = true;
412 sizeFail = true; 407 break;
413 break; 408
414 409 default:
415 case SkBitmap::kRLE_Index8_Config: 410 break;
416 break; 411 }
417 412 if (sizeFail) {
418 default: 413 SkString str;
419 break; 414 str.printf("getSafeSize64() wrong size: %s",
420 } 415 getSkConfigName(tstSafeSize));
421 if (sizeFail) { 416 reporter->reportFailed(str);
422 SkString str; 417 }
423 str.printf("getSafeSize64() wrong size: %s", 418
424 getSkConfigName(tstSafeSize)); 419 size_t subW, subH;
425 reporter->reportFailed(str); 420 // Set sizes to be height = 2 to force the last row of the
426 } 421 // source to be used, thus verifying correct operation if
427 422 // the bitmap is an extracted subset.
428 size_t subW, subH; 423 if (gPairs[i].fConfig == SkBitmap::kA1_Config) {
429 // Set sizes to be height = 2 to force the last row of the 424 // If one-bit per pixel, use 9 pixels to force more than
430 // source to be used, thus verifying correct operation if 425 // one byte per row.
431 // the bitmap is an extracted subset. 426 subW = 9;
432 if (gPairs[i].fConfig == SkBitmap::kA1_Config) { 427 subH = 2;
433 // If one-bit per pixel, use 9 pixels to force more than 428 } else {
434 // one byte per row. 429 // All other configurations are at least one byte per pixel,
435 subW = 9; 430 // and different configs will test copying different numbers
436 subH = 2; 431 // of bytes.
437 } else { 432 subW = subH = 2;
438 // All other configurations are at least one byte per pixel, 433 }
439 // and different configs will test copying different numbers 434
440 // of bytes. 435 // Create bitmap to act as source for copies and subsets.
441 subW = subH = 2; 436 SkBitmap src, subset;
442 } 437 SkColorTable* ct = NULL;
443 438 if (isExtracted[copyCase]) { // A larger image to extract from.
444 // Create bitmap to act as source for copies and subsets. 439 src.setConfig(gPairs[i].fConfig, 2 * subW + 1, subH);
445 SkBitmap src, subset; 440 } else { // Tests expect a 2x2 bitmap, so make smaller.
446 SkColorTable* ct = NULL; 441 src.setConfig(gPairs[i].fConfig, subW, subH);
447 if (isExtracted[copyCase]) { // A larger image to extract from. 442 }
448 src.setConfig(gPairs[i].fConfig, 2 * subW + 1, subH); 443 if (SkBitmap::kIndex8_Config == src.config()) {
449 } else // Tests expect a 2x2 bitmap, so make smaller. 444 ct = init_ctable();
450 src.setConfig(gPairs[i].fConfig, subW, subH); 445 }
451 if (SkBitmap::kIndex8_Config == src.config() || 446
452 SkBitmap::kRLE_Index8_Config == src.config()) { 447 src.allocPixels(ct);
453 ct = init_ctable(); 448 SkSafeUnref(ct);
454 } 449
455 450 // Either copy src or extract into 'subset', which is used
456 src.allocPixels(ct); 451 // for subsequent calls to copyPixelsTo/From.
457 SkSafeUnref(ct); 452 bool srcReady = false;
458 453 if (isExtracted[copyCase]) {
459 // Either copy src or extract into 'subset', which is used 454 // The extractedSubset() test case allows us to test copy-
460 // for subsequent calls to copyPixelsTo/From. 455 // ing when src and dst mave possibly different strides.
461 bool srcReady = false; 456 SkIRect r;
462 if (isExtracted[copyCase]) { 457 if (gPairs[i].fConfig == SkBitmap::kA1_Config)
463 // The extractedSubset() test case allows us to test copy- 458 // This config seems to need byte-alignment of
464 // ing when src and dst mave possibly different strides. 459 // extracted subset bits.
465 SkIRect r; 460 r.set(0, 0, subW, subH);
466 if (gPairs[i].fConfig == SkBitmap::kA1_Config) 461 else
467 // This config seems to need byte-alignment of 462 r.set(1, 0, 1 + subW, subH); // 2x2 extracted bitmap
468 // extracted subset bits. 463
469 r.set(0, 0, subW, subH); 464 srcReady = src.extractSubset(&subset, r);
470 else 465 } else {
471 r.set(1, 0, 1 + subW, subH); // 2x2 extracted bitmap 466 srcReady = src.copyTo(&subset, src.getConfig());
472 467 }
473 srcReady = src.extractSubset(&subset, r); 468
474 } else { 469 // Not all configurations will generate a valid 'subset'.
475 srcReady = src.copyTo(&subset, src.getConfig()); 470 if (srcReady) {
476 } 471
477 472 // Allocate our target buffer 'buf' for all copies.
478 // Not all configurations will generate a valid 'subset'. 473 // To simplify verifying correctness of copies attach
479 if (srcReady) { 474 // buf to a SkBitmap, but copies are done using the
480 475 // raw buffer pointer.
481 // Allocate our target buffer 'buf' for all copies. 476 const uint32_t bufSize = subH *
482 // To simplify verifying correctness of copies attach 477 SkBitmap::ComputeRowBytes(src.getConfig(), subW) * 2;
483 // buf to a SkBitmap, but copies are done using the 478 SkAutoMalloc autoBuf (bufSize);
484 // raw buffer pointer. 479 uint8_t* buf = static_cast<uint8_t*>(autoBuf.get());
485 const uint32_t bufSize = subH * 480
486 SkBitmap::ComputeRowBytes(src.getConfig(), subW) * 2; 481 SkBitmap bufBm; // Attach buf to this bitmap.
487 SkAutoMalloc autoBuf (bufSize); 482 bool successExpected;
488 uint8_t* buf = static_cast<uint8_t*>(autoBuf.get()); 483
489 484 // Set up values for each pixel being copied.
490 SkBitmap bufBm; // Attach buf to this bitmap. 485 Coordinates coords(subW * subH);
491 bool successExpected; 486 for (size_t x = 0; x < subW; ++x)
492 487 for (size_t y = 0; y < subH; ++y)
493 // Set up values for each pixel being copied. 488 {
494 Coordinates coords(subW * subH); 489 int index = y * subW + x;
495 for (size_t x = 0; x < subW; ++x) 490 SkASSERT(index < coords.length);
496 for (size_t y = 0; y < subH; ++y) 491 coords[index]->fX = x;
497 { 492 coords[index]->fY = y;
498 int index = y * subW + x; 493 }
499 SkASSERT(index < coords.length); 494
500 coords[index]->fX = x; 495 writeCoordPixels(subset, coords);
501 coords[index]->fY = y; 496
502 } 497 // Test #1 ////////////////////////////////////////////
503 498
504 writeCoordPixels(subset, coords); 499 // Before/after comparisons easier if we attach buf
505 500 // to an appropriately configured SkBitmap.
506 // Test #1 //////////////////////////////////////////// 501 memset(buf, 0xFF, bufSize);
507 502 // Config with stride greater than src but that fits in buf.
508 // Before/after comparisons easier if we attach buf 503 bufBm.setConfig(gPairs[i].fConfig, subW, subH,
509 // to an appropriately configured SkBitmap. 504 SkBitmap::ComputeRowBytes(subset.getConfig(), subW)
510 memset(buf, 0xFF, bufSize); 505 * 2);
511 // Config with stride greater than src but that fits in buf. 506 bufBm.setPixels(buf);
512 bufBm.setConfig(gPairs[i].fConfig, subW, subH, 507 successExpected = false;
513 SkBitmap::ComputeRowBytes(subset.getConfig(), subW) 508 // Then attempt to copy with a stride that is too large
514 * 2); 509 // to fit in the buffer.
515 bufBm.setPixels(buf); 510 REPORTER_ASSERT(reporter,
516 successExpected = false; 511 subset.copyPixelsTo(buf, bufSize, bufBm.rowBytes() * 3)
517 // Then attempt to copy with a stride that is too large 512 == successExpected);
518 // to fit in the buffer. 513
519 REPORTER_ASSERT(reporter, 514 if (successExpected)
520 subset.copyPixelsTo(buf, bufSize, bufBm.rowBytes() * 3) 515 reportCopyVerification(subset, bufBm, coords,
516 "copyPixelsTo(buf, bufSize, 1.5*maxRowBytes)",
517 reporter);
518
519 // Test #2 ////////////////////////////////////////////
520 // This test should always succeed, but in the case
521 // of extracted bitmaps only because we handle the
522 // issue of getSafeSize(). Without getSafeSize()
523 // buffer overrun/read would occur.
524 memset(buf, 0xFF, bufSize);
525 bufBm.setConfig(gPairs[i].fConfig, subW, subH,
526 subset.rowBytes());
527 bufBm.setPixels(buf);
528 successExpected = subset.getSafeSize() <= bufSize;
529 REPORTER_ASSERT(reporter,
530 subset.copyPixelsTo(buf, bufSize) ==
531 successExpected);
532 if (successExpected)
533 reportCopyVerification(subset, bufBm, coords,
534 "copyPixelsTo(buf, bufSize)", reporter);
535
536 // Test #3 ////////////////////////////////////////////
537 // Copy with different stride between src and dst.
538 memset(buf, 0xFF, bufSize);
539 bufBm.setConfig(gPairs[i].fConfig, subW, subH,
540 subset.rowBytes()+1);
541 bufBm.setPixels(buf);
542 successExpected = true; // Should always work.
543 REPORTER_ASSERT(reporter,
544 subset.copyPixelsTo(buf, bufSize,
545 subset.rowBytes()+1) == successExpected);
546 if (successExpected)
547 reportCopyVerification(subset, bufBm, coords,
548 "copyPixelsTo(buf, bufSize, rowBytes+1)", reporter);
549
550 // Test #4 ////////////////////////////////////////////
551 // Test copy with stride too small.
552 memset(buf, 0xFF, bufSize);
553 bufBm.setConfig(gPairs[i].fConfig, subW, subH);
554 bufBm.setPixels(buf);
555 successExpected = false;
556 // Request copy with stride too small.
557 REPORTER_ASSERT(reporter,
558 subset.copyPixelsTo(buf, bufSize, bufBm.rowBytes()-1)
521 == successExpected); 559 == successExpected);
522 560 if (successExpected)
523 if (successExpected) 561 reportCopyVerification(subset, bufBm, coords,
524 reportCopyVerification(subset, bufBm, coords, 562 "copyPixelsTo(buf, bufSize, rowBytes()-1)", reporter);
525 "copyPixelsTo(buf, bufSize, 1.5*maxRowBytes)",
526 reporter);
527
528 // Test #2 ////////////////////////////////////////////
529 // This test should always succeed, but in the case
530 // of extracted bitmaps only because we handle the
531 // issue of getSafeSize(). Without getSafeSize()
532 // buffer overrun/read would occur.
533 memset(buf, 0xFF, bufSize);
534 bufBm.setConfig(gPairs[i].fConfig, subW, subH,
535 subset.rowBytes());
536 bufBm.setPixels(buf);
537 successExpected = subset.getSafeSize() <= bufSize;
538 REPORTER_ASSERT(reporter,
539 subset.copyPixelsTo(buf, bufSize) ==
540 successExpected);
541 if (successExpected)
542 reportCopyVerification(subset, bufBm, coords,
543 "copyPixelsTo(buf, bufSize)", reporter);
544
545 // Test #3 ////////////////////////////////////////////
546 // Copy with different stride between src and dst.
547 memset(buf, 0xFF, bufSize);
548 bufBm.setConfig(gPairs[i].fConfig, subW, subH,
549 subset.rowBytes()+1);
550 bufBm.setPixels(buf);
551 successExpected = true; // Should always work.
552 REPORTER_ASSERT(reporter,
553 subset.copyPixelsTo(buf, bufSize,
554 subset.rowBytes()+1) == successExpected);
555 if (successExpected)
556 reportCopyVerification(subset, bufBm, coords,
557 "copyPixelsTo(buf, bufSize, rowBytes+1)", reporter);
558
559 // Test #4 ////////////////////////////////////////////
560 // Test copy with stride too small.
561 memset(buf, 0xFF, bufSize);
562 bufBm.setConfig(gPairs[i].fConfig, subW, subH);
563 bufBm.setPixels(buf);
564 successExpected = false;
565 // Request copy with stride too small.
566 REPORTER_ASSERT(reporter,
567 subset.copyPixelsTo(buf, bufSize, bufBm.rowBytes()-1)
568 == successExpected);
569 if (successExpected)
570 reportCopyVerification(subset, bufBm, coords,
571 "copyPixelsTo(buf, bufSize, rowBytes()-1)", reporter);
572 563
573 #if 0 // copyPixelsFrom is gone 564 #if 0 // copyPixelsFrom is gone
574 // Test #5 //////////////////////////////////////////// 565 // Test #5 ////////////////////////////////////////////
575 // Tests the case where the source stride is too small 566 // Tests the case where the source stride is too small
576 // for the source configuration. 567 // for the source configuration.
577 memset(buf, 0xFF, bufSize); 568 memset(buf, 0xFF, bufSize);
578 bufBm.setConfig(gPairs[i].fConfig, subW, subH); 569 bufBm.setConfig(gPairs[i].fConfig, subW, subH);
579 bufBm.setPixels(buf); 570 bufBm.setPixels(buf);
580 writeCoordPixels(bufBm, coords); 571 writeCoordPixels(bufBm, coords);
581 REPORTER_ASSERT(reporter, 572 REPORTER_ASSERT(reporter,
582 subset.copyPixelsFrom(buf, bufSize, 1) == false); 573 subset.copyPixelsFrom(buf, bufSize, 1) == false);
583 574
584 // Test #6 /////////////////////////////////////////// 575 // Test #6 ///////////////////////////////////////////
585 // Tests basic copy from an external buffer to the bitmap. 576 // Tests basic copy from an external buffer to the bitmap.
586 // If the bitmap is "extracted", this also tests the case 577 // If the bitmap is "extracted", this also tests the case
587 // where the source stride is different from the dest. 578 // where the source stride is different from the dest.
588 // stride. 579 // stride.
589 // We've made the buffer large enough to always succeed. 580 // We've made the buffer large enough to always succeed.
590 bufBm.setConfig(gPairs[i].fConfig, subW, subH); 581 bufBm.setConfig(gPairs[i].fConfig, subW, subH);
591 bufBm.setPixels(buf); 582 bufBm.setPixels(buf);
592 writeCoordPixels(bufBm, coords); 583 writeCoordPixels(bufBm, coords);
593 REPORTER_ASSERT(reporter, 584 REPORTER_ASSERT(reporter,
594 subset.copyPixelsFrom(buf, bufSize, bufBm.rowBytes()) == 585 subset.copyPixelsFrom(buf, bufSize, bufBm.rowBytes()) ==
595 true); 586 true);
596 reportCopyVerification(bufBm, subset, coords, 587 reportCopyVerification(bufBm, subset, coords,
597 "copyPixelsFrom(buf, bufSize)", 588 "copyPixelsFrom(buf, bufSize)",
598 reporter); 589 reporter);
599 590
600 // Test #7 //////////////////////////////////////////// 591 // Test #7 ////////////////////////////////////////////
601 // Tests the case where the source buffer is too small 592 // Tests the case where the source buffer is too small
602 // for the transfer. 593 // for the transfer.
603 REPORTER_ASSERT(reporter, 594 REPORTER_ASSERT(reporter,
604 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) == 595 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) ==
605 false); 596 false);
606 597
607 #endif 598 #endif
608 }
609 } 599 }
610 } // for (size_t copyCase ... 600 } // for (size_t copyCase ...
611 } 601 }
612 } 602 }
613 603
614 #include "TestClassDef.h" 604 #include "TestClassDef.h"
615 DEFINE_TESTCLASS("BitmapCopy", TestBitmapCopyClass, TestBitmapCopy) 605 DEFINE_TESTCLASS("BitmapCopy", TestBitmapCopyClass, TestBitmapCopy)
OLDNEW
« no previous file with comments | « src/pdf/SkPDFImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698