Bug 795378 - Clean up the high-quality scaler - Merge upstream changes to image_operations.cpp. r=joe
authorYazen Ghannam <yghannam@gmail.com>
Tue, 18 Dec 2012 16:25:07 -0500
changeset 125544 cf51fc0485f053f601571292c3369b52c97319ce
parent 125543 d5f731147e6c7063bd2f1551293d32ee3defa85e
child 125545 94fa710130da42f2da61595b08a4e6fb92e73e03
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs795378
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 795378 - Clean up the high-quality scaler - Merge upstream changes to image_operations.cpp. r=joe
gfx/2d/image_operations.cpp
--- a/gfx/2d/image_operations.cpp
+++ b/gfx/2d/image_operations.cpp
@@ -265,42 +265,35 @@ void ResizeFilter::ComputeFilters(int sr
     fixed_filter_values->clear();
 
     // This is the pixel in the source directly under the pixel in the dest.
     // Note that we base computations on the "center" of the pixels. To see
     // why, observe that the destination pixel at coordinates (0, 0) in a 5.0x
     // downscale should "cover" the pixels around the pixel with *its center*
     // at coordinates (2.5, 2.5) in the source, not those around (0, 0).
     // Hence we need to scale coordinates (0.5, 0.5), not (0, 0).
-    // TODO(evannier): this code is therefore incorrect and should read:
-    // float src_pixel = (static_cast<float>(dest_subset_i) + 0.5f) * inv_scale;
-    // I leave it incorrect, because changing it would require modifying
-    // the results for the webkit test, which I will do in a subsequent checkin.
-    float src_pixel = dest_subset_i * inv_scale;
+    float src_pixel = (static_cast<float>(dest_subset_i) + 0.5f) * inv_scale;
 
     // Compute the (inclusive) range of source pixels the filter covers.
     int src_begin = NS_MAX(0, FloorInt(src_pixel - src_support));
     int src_end = NS_MIN(src_size - 1, CeilInt(src_pixel + src_support));
 
     // Compute the unnormalized filter value at each location of the source
     // it covers.
     float filter_sum = 0.0f;  // Sub of the filter values for normalizing.
     for (int cur_filter_pixel = src_begin; cur_filter_pixel <= src_end;
          cur_filter_pixel++) {
       // Distance from the center of the filter, this is the filter coordinate
       // in source space. We also need to consider the center of the pixel
       // when comparing distance against 'src_pixel'. In the 5x downscale
       // example used above the distance from the center of the filter to
       // the pixel with coordinates (2, 2) should be 0, because its center
       // is at (2.5, 2.5).
-      // TODO(evannier): as above (in regards to the 0.5 pixel error),
-      // this code is incorrect, but is left it for the same reasons.
-      // float src_filter_dist =
-      //     ((static_cast<float>(cur_filter_pixel) + 0.5f) - src_pixel);
-      float src_filter_dist = cur_filter_pixel - src_pixel;
+      float src_filter_dist =
+           ((static_cast<float>(cur_filter_pixel) + 0.5f) - src_pixel);
 
       // Since the filter really exists in dest space, map it there.
       float dest_filter_dist = src_filter_dist * clamped_scale;
 
       // Compute the filter value at that location.
       float filter_value = ComputeFilter(dest_filter_dist);
       filter_values->push_back(filter_value);