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

Side by Side Diff: tests/BitmapCopyTest.cpp

Issue 137753017: move all Config specific APIs into SkBitmapConfig.cpp -- Config is deprecated (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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/utils/SkGatherPixelRefsAndRects.h ('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 * 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 #include "SkBitmap.h" 7 #include "SkBitmap.h"
8 #include "SkRect.h" 8 #include "SkRect.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 425 }
426 426
427 // Not all configurations will generate a valid 'subset'. 427 // Not all configurations will generate a valid 'subset'.
428 if (srcReady) { 428 if (srcReady) {
429 429
430 // Allocate our target buffer 'buf' for all copies. 430 // Allocate our target buffer 'buf' for all copies.
431 // To simplify verifying correctness of copies attach 431 // To simplify verifying correctness of copies attach
432 // buf to a SkBitmap, but copies are done using the 432 // buf to a SkBitmap, but copies are done using the
433 // raw buffer pointer. 433 // raw buffer pointer.
434 const size_t bufSize = subH * 434 const size_t bufSize = subH *
435 SkBitmap::ComputeRowBytes(src.config(), subW) * 2; 435 SkColorTypeMinRowBytes(src.colorType(), subW) * 2;
436 SkAutoMalloc autoBuf (bufSize); 436 SkAutoMalloc autoBuf (bufSize);
437 uint8_t* buf = static_cast<uint8_t*>(autoBuf.get()); 437 uint8_t* buf = static_cast<uint8_t*>(autoBuf.get());
438 438
439 SkBitmap bufBm; // Attach buf to this bitmap. 439 SkBitmap bufBm; // Attach buf to this bitmap.
440 bool successExpected; 440 bool successExpected;
441 441
442 // Set up values for each pixel being copied. 442 // Set up values for each pixel being copied.
443 Coordinates coords(subW * subH); 443 Coordinates coords(subW * subH);
444 for (int x = 0; x < subW; ++x) 444 for (int x = 0; x < subW; ++x)
445 for (int y = 0; y < subH; ++y) 445 for (int y = 0; y < subH; ++y)
446 { 446 {
447 int index = y * subW + x; 447 int index = y * subW + x;
448 SkASSERT(index < coords.length); 448 SkASSERT(index < coords.length);
449 coords[index]->fX = x; 449 coords[index]->fX = x;
450 coords[index]->fY = y; 450 coords[index]->fY = y;
451 } 451 }
452 452
453 writeCoordPixels(subset, coords); 453 writeCoordPixels(subset, coords);
454 454
455 // Test #1 //////////////////////////////////////////// 455 // Test #1 ////////////////////////////////////////////
456 456
457 // Before/after comparisons easier if we attach buf 457 // Before/after comparisons easier if we attach buf
458 // to an appropriately configured SkBitmap. 458 // to an appropriately configured SkBitmap.
459 memset(buf, 0xFF, bufSize); 459 memset(buf, 0xFF, bufSize);
460 // Config with stride greater than src but that fits in buf. 460 // Config with stride greater than src but that fits in buf.
461 bufBm.setConfig(gPairs[i].fConfig, subW, subH, 461 bufBm.setConfig(gPairs[i].fConfig, subW, subH,
462 SkBitmap::ComputeRowBytes(subset.config(), subW) * 2); 462 SkColorTypeMinRowBytes(subset.colorType(), subW) * 2);
463 bufBm.setPixels(buf); 463 bufBm.setPixels(buf);
464 successExpected = false; 464 successExpected = false;
465 // Then attempt to copy with a stride that is too large 465 // Then attempt to copy with a stride that is too large
466 // to fit in the buffer. 466 // to fit in the buffer.
467 REPORTER_ASSERT(reporter, 467 REPORTER_ASSERT(reporter,
468 subset.copyPixelsTo(buf, bufSize, bufBm.rowBytes() * 3) 468 subset.copyPixelsTo(buf, bufSize, bufBm.rowBytes() * 3)
469 == successExpected); 469 == successExpected);
470 470
471 if (successExpected) 471 if (successExpected)
472 reportCopyVerification(subset, bufBm, coords, 472 reportCopyVerification(subset, bufBm, coords,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // for the transfer. 550 // for the transfer.
551 REPORTER_ASSERT(reporter, 551 REPORTER_ASSERT(reporter,
552 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) == 552 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) ==
553 false); 553 false);
554 554
555 #endif 555 #endif
556 } 556 }
557 } // for (size_t copyCase ... 557 } // for (size_t copyCase ...
558 } 558 }
559 } 559 }
OLDNEW
« no previous file with comments | « src/utils/SkGatherPixelRefsAndRects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698