diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-25 21:22:57 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-25 21:22:57 +0000 |
commit | a4308def0ae0a90dbf3a4000ba1dabae091ea449 (patch) | |
tree | e90077c51159a5c5c64c59eddf8a9f355869690a /skia/ext/image_operations_unittest.cc | |
parent | 12d13759db11a3bffd678f5838a36b60d4803bf5 (diff) | |
download | chromium_src-a4308def0ae0a90dbf3a4000ba1dabae091ea449.zip chromium_src-a4308def0ae0a90dbf3a4000ba1dabae091ea449.tar.gz chromium_src-a4308def0ae0a90dbf3a4000ba1dabae091ea449.tar.bz2 |
Fix half-pixel misalignment in skia::ImageOperations
Also tighten the error bound in related unit tests.
BUG=146195
TEST=unit_test --gtest_filter=ImageOperations*
Review URL: https://chromiumcodereview.appspot.com/10916038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158657 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/image_operations_unittest.cc')
-rw-r--r-- | skia/ext/image_operations_unittest.cc | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/skia/ext/image_operations_unittest.cc b/skia/ext/image_operations_unittest.cc index dc0108d..23353fa 100644 --- a/skia/ext/image_operations_unittest.cc +++ b/skia/ext/image_operations_unittest.cc @@ -263,15 +263,11 @@ void CheckResizeMethodShouldAverageGrid( bool* method_passed) { *method_passed = false; - // TODO(evannier): The math inside image_operations.cc is incorrect is off - // by half a pixel. As a result, the calculated distances become extremely - // large. Once the fix is in to correct this half pixel issue, most of these - // values can become a lot tighter. const TestedPixel tested_pixels[] = { // Corners - { 0, 0, 59.0f, "Top left corner" }, + { 0, 0, 2.3f, "Top left corner" }, { 0, dest_h - 1, 2.3f, "Bottom left corner" }, - { dest_w - 1, 0, 7.1f, "Top right corner" }, + { dest_w - 1, 0, 2.3f, "Top right corner" }, { dest_w - 1, dest_h - 1, 2.3f, "Bottom right corner" }, // Middle points of each side { dest_w / 2, 0, 1.0f, "Top middle" }, @@ -406,18 +402,11 @@ TEST(ImageOperations, Halve) { // offset that comes into play due to considering the coordinates // of the center of the pixels. So x * 2 is a simplification // of ((x+0.5) * 2 - 1) and (x * 2 + 1) is really (x + 0.5) * 2. - // TODO(evannier): for now these stay broken because of the half pixel - // issue mentioned inside image_operations.cc. The code should read: - // int first_x = x * 2; - // int last_x = std::min(src_w - 1, x * 2 + 1); - - // int first_y = y * 2; - // int last_y = std::min(src_h - 1, y * 2 + 1); - int first_x = std::max(0, x * 2 - 1); - int last_x = std::min(src_w - 1, x * 2); - - int first_y = std::max(0, y * 2 - 1); - int last_y = std::min(src_h - 1, y * 2); + int first_x = x * 2; + int last_x = std::min(src_w - 1, x * 2 + 1); + + int first_y = y * 2; + int last_y = std::min(src_h - 1, y * 2 + 1); const uint32_t expected_color = AveragePixel(src, first_x, last_x, |