| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkRect.h" | 9 #include "SkRect.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 { true, { 0, 0 }, { 4, 4 }, { 0, 0 }, { 0, 0, 4, 4 } }, | 602 { true, { 0, 0 }, { 4, 4 }, { 0, 0 }, { 0, 0, 4, 4 } }, |
| 603 { true, { 1, 1 }, { 2, 2 }, { 0, 0 }, { 1, 1, 3, 3 } }, | 603 { true, { 1, 1 }, { 2, 2 }, { 0, 0 }, { 1, 1, 3, 3 } }, |
| 604 { true, { 2, 2 }, { 4, 4 }, { 0, 0 }, { 2, 2, 4, 4 } }, | 604 { true, { 2, 2 }, { 4, 4 }, { 0, 0 }, { 2, 2, 4, 4 } }, |
| 605 { true, {-1,-1 }, { 2, 2 }, { 1, 1 }, { 0, 0, 1, 1 } }, | 605 { true, {-1,-1 }, { 2, 2 }, { 1, 1 }, { 0, 0, 1, 1 } }, |
| 606 { false, {-1,-1 }, { 1, 1 }, { 0, 0 }, { 0, 0, 0, 0 } }, | 606 { false, {-1,-1 }, { 1, 1 }, { 0, 0 }, { 0, 0, 0, 0 } }, |
| 607 }; | 607 }; |
| 608 | 608 |
| 609 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 609 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 610 clear_4x4_pixels(dstPixels); | 610 clear_4x4_pixels(dstPixels); |
| 611 | 611 |
| 612 dstInfo.fWidth = gRec[i].fRequestedDstSize.width(); | 612 dstInfo = dstInfo.makeWH(gRec[i].fRequestedDstSize.width(), |
| 613 dstInfo.fHeight = gRec[i].fRequestedDstSize.height(); | 613 gRec[i].fRequestedDstSize.height()); |
| 614 bool success = srcBM.readPixels(dstInfo, dstPixels, rowBytes, | 614 bool success = srcBM.readPixels(dstInfo, dstPixels, rowBytes, |
| 615 gRec[i].fRequestedSrcLoc.x(), gRec[i].fR
equestedSrcLoc.y()); | 615 gRec[i].fRequestedSrcLoc.x(), gRec[i].fR
equestedSrcLoc.y()); |
| 616 | 616 |
| 617 REPORTER_ASSERT(reporter, gRec[i].fExpectedSuccess == success); | 617 REPORTER_ASSERT(reporter, gRec[i].fExpectedSuccess == success); |
| 618 if (success) { | 618 if (success) { |
| 619 const SkIRect srcR = gRec[i].fExpectedSrcR; | 619 const SkIRect srcR = gRec[i].fExpectedSrcR; |
| 620 const int dstX = gRec[i].fExpectedDstLoc.x(); | 620 const int dstX = gRec[i].fExpectedDstLoc.x(); |
| 621 const int dstY = gRec[i].fExpectedDstLoc.y(); | 621 const int dstY = gRec[i].fExpectedDstLoc.y(); |
| 622 // Walk the dst pixels, and check if we got what we expected | 622 // Walk the dst pixels, and check if we got what we expected |
| 623 for (int y = 0; y < H; ++y) { | 623 for (int y = 0; y < H; ++y) { |
| 624 for (int x = 0; x < W; ++x) { | 624 for (int x = 0; x < W; ++x) { |
| 625 SkPMColor dstC = dstPixels[y*4+x]; | 625 SkPMColor dstC = dstPixels[y*4+x]; |
| 626 // get into src coordinates | 626 // get into src coordinates |
| 627 int sx = x - dstX + srcR.x(); | 627 int sx = x - dstX + srcR.x(); |
| 628 int sy = y - dstY + srcR.y(); | 628 int sy = y - dstY + srcR.y(); |
| 629 if (srcR.contains(sx, sy)) { | 629 if (srcR.contains(sx, sy)) { |
| 630 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy))
; | 630 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy))
; |
| 631 } else { | 631 } else { |
| 632 REPORTER_ASSERT(reporter, 0 == dstC); | 632 REPORTER_ASSERT(reporter, 0 == dstC); |
| 633 } | 633 } |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 } | 638 } |
| 639 | 639 |
| OLD | NEW |