summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authortomhudson <tomhudson@google.com>2015-10-27 13:20:54 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-27 20:21:41 +0000
commit32ce3b13924d84004a3e05c35942626cbe93cbbd (patch)
tree88637e89ce70c124b66d56997b053b7a9b89c875 /skia
parent53fc07eb478520a80af6bf8b62be259bb55db0f1 (diff)
downloadchromium_src-32ce3b13924d84004a3e05c35942626cbe93cbbd.zip
chromium_src-32ce3b13924d84004a3e05c35942626cbe93cbbd.tar.gz
chromium_src-32ce3b13924d84004a3e05c35942626cbe93cbbd.tar.bz2
Remove Lanczos2 filters
This filter code is only used in tests and benchmarks. The code savings is rather small, but it's a bit odd to have a unit test comparing Lanczos2 vs Lanczos3 when you're using the exact same implementation for both of them, just varying the parameter for filter width. R=fmalita@chromium.org Review URL: https://codereview.chromium.org/1428613002 Cr-Commit-Position: refs/heads/master@{#356382}
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/image_operations.cc6
-rw-r--r--skia/ext/image_operations.h5
-rw-r--r--skia/ext/image_operations_bench.cc1
-rw-r--r--skia/ext/image_operations_unittest.cc117
4 files changed, 0 insertions, 129 deletions
diff --git a/skia/ext/image_operations.cc b/skia/ext/image_operations.cc
index a14344d..51f92c9 100644
--- a/skia/ext/image_operations.cc
+++ b/skia/ext/image_operations.cc
@@ -113,10 +113,6 @@ class ResizeFilter {
// The Hamming filter takes as much space in the source image in
// each direction as the size of the window = 1 for Hamming1.
return 1.0f;
- case ImageOperations::RESIZE_LANCZOS2:
- // The Lanczos filter takes as much space in the source image in
- // each direction as the size of the window = 2 for Lanczos2.
- return 2.0f;
case ImageOperations::RESIZE_LANCZOS3:
// The Lanczos filter takes as much space in the source image in
// each direction as the size of the window = 3 for Lanczos3.
@@ -149,8 +145,6 @@ class ResizeFilter {
return EvalBox(pos);
case ImageOperations::RESIZE_HAMMING1:
return EvalHamming(1, pos);
- case ImageOperations::RESIZE_LANCZOS2:
- return EvalLanczos(2, pos);
case ImageOperations::RESIZE_LANCZOS3:
return EvalLanczos(3, pos);
default:
diff --git a/skia/ext/image_operations.h b/skia/ext/image_operations.h
index 9e0b073..01d364b 100644
--- a/skia/ext/image_operations.h
+++ b/skia/ext/image_operations.h
@@ -70,11 +70,6 @@ class SK_API ImageOperations {
// a 2-cycle Lanczos.
RESIZE_HAMMING1,
- // 2-cycle Lanczos filter. This is tall in the middle, goes negative on
- // each side, then returns to zero. Does not provide as good a frequency
- // response as a 3-cycle Lanczos but is roughly 30% faster.
- RESIZE_LANCZOS2,
-
// 3-cycle Lanczos filter. This is tall in the middle, goes negative on
// each side, then oscillates 2 more times. It gives nice sharp edges.
RESIZE_LANCZOS3,
diff --git a/skia/ext/image_operations_bench.cc b/skia/ext/image_operations_bench.cc
index 9b2667f..91820be 100644
--- a/skia/ext/image_operations_bench.cc
+++ b/skia/ext/image_operations_bench.cc
@@ -41,7 +41,6 @@ const StringMethodPair resize_methods[] = {
ADD_METHOD(BEST),
ADD_METHOD(BOX),
ADD_METHOD(HAMMING1),
- ADD_METHOD(LANCZOS2),
ADD_METHOD(LANCZOS3),
};
diff --git a/skia/ext/image_operations_unittest.cc b/skia/ext/image_operations_unittest.cc
index 8f6d756..d522b5e 100644
--- a/skia/ext/image_operations_unittest.cc
+++ b/skia/ext/image_operations_unittest.cc
@@ -123,35 +123,6 @@ void FillDataToBitmap(int w, int h, SkBitmap* bmp) {
}
}
-// Draws a horizontal and vertical grid into the w x h bitmap passed in.
-// Each line in the grid is drawn with a width of "grid_width" pixels,
-// and those lines repeat every "grid_pitch" pixels. The top left pixel (0, 0)
-// is considered to be part of a grid line.
-// The pixels that fall on a line are colored with "grid_color", while those
-// outside of the lines are colored in "background_color".
-// Note that grid_with can be greather than or equal to grid_pitch, in which
-// case the resulting bitmap will be a solid color "grid_color".
-void DrawGridToBitmap(int w, int h,
- SkColor background_color, SkColor grid_color,
- int grid_pitch, int grid_width,
- SkBitmap* bmp) {
- ASSERT_GT(grid_pitch, 0);
- ASSERT_GT(grid_width, 0);
- ASSERT_NE(background_color, grid_color);
-
- bmp->allocN32Pixels(w, h);
-
- for (int y = 0; y < h; ++y) {
- bool y_on_grid = ((y % grid_pitch) < grid_width);
-
- for (int x = 0; x < w; ++x) {
- bool on_grid = (y_on_grid || ((x % grid_pitch) < grid_width));
-
- *bmp->getAddr32(x, y) = (on_grid ? grid_color : background_color);
- }
- }
-}
-
// Draws a checkerboard pattern into the w x h bitmap passed in.
// Each rectangle is rect_w in width, rect_h in height.
// The colors alternate between color1 and color2, color1 being used
@@ -473,10 +444,6 @@ TEST(ImageOperations, ResampleToSameHamming1) {
CheckResampleToSame(skia::ImageOperations::RESIZE_HAMMING1);
}
-TEST(ImageOperations, ResampleToSameLanczos2) {
- CheckResampleToSame(skia::ImageOperations::RESIZE_LANCZOS2);
-}
-
TEST(ImageOperations, ResampleToSameLanczos3) {
CheckResampleToSame(skia::ImageOperations::RESIZE_LANCZOS3);
}
@@ -501,7 +468,6 @@ TEST(ImageOperations, ResizeShouldAverageColors) {
{ skia::ImageOperations::RESIZE_BEST, "BEST", 0.0f },
{ skia::ImageOperations::RESIZE_BOX, "BOX", 0.0f },
{ skia::ImageOperations::RESIZE_HAMMING1, "HAMMING1", 0.0f },
- { skia::ImageOperations::RESIZE_LANCZOS2, "LANCZOS2", 0.0f },
{ skia::ImageOperations::RESIZE_LANCZOS3, "LANCZOS3", 0.0f },
};
@@ -537,89 +503,6 @@ TEST(ImageOperations, ResizeShouldAverageColors) {
}
-// Check that Lanczos2 and Lanczos3 thumbnails produce similar results
-TEST(ImageOperations, CompareLanczosMethods) {
- const int src_w = 640, src_h = 480, src_grid_pitch = 8, src_grid_width = 4;
-
- const int dest_w = src_w / 4;
- const int dest_h = src_h / 4;
-
- // 5.0f is the maximum distance we see in this test given the current
- // parameters. The value is very ad-hoc and the parameters of the scaling
- // were picked to produce a small value. So this test is very much about
- // revealing egregious regression rather than doing a good job at checking
- // the math behind the filters.
- // TODO(evannier): because of the half pixel error mentioned inside
- // image_operations.cc, this distance is much larger than it should be.
- // This should read:
- // const float max_color_distance = 5.0f;
- const float max_color_distance = 12.1f;
-
- // Make our source bitmap.
- SkColor grid_color = SK_ColorRED, background_color = SK_ColorBLUE;
- SkBitmap src;
- DrawGridToBitmap(src_w, src_h,
- background_color, grid_color,
- src_grid_pitch, src_grid_width,
- &src);
-
- // Resize the src using both methods.
- SkBitmap dest_l2 = skia::ImageOperations::Resize(
- src,
- skia::ImageOperations::RESIZE_LANCZOS2,
- dest_w, dest_h);
- ASSERT_EQ(dest_w, dest_l2.width());
- ASSERT_EQ(dest_h, dest_l2.height());
-
- SkBitmap dest_l3 = skia::ImageOperations::Resize(
- src,
- skia::ImageOperations::RESIZE_LANCZOS3,
- dest_w, dest_h);
- ASSERT_EQ(dest_w, dest_l3.width());
- ASSERT_EQ(dest_h, dest_l3.height());
-
- // Compare the pixels produced by both methods.
- float max_observed_distance = 0.0f;
- bool all_pixels_ok = true;
-
- SkAutoLockPixels l2_lock(dest_l2);
- SkAutoLockPixels l3_lock(dest_l3);
- for (int y = 0; y < dest_h; ++y) {
- for (int x = 0; x < dest_w; ++x) {
- const SkColor color_lanczos2 = *dest_l2.getAddr32(x, y);
- const SkColor color_lanczos3 = *dest_l3.getAddr32(x, y);
-
- float distance = ColorsEuclidianDistance(color_lanczos2, color_lanczos3);
-
- EXPECT_LE(distance, max_color_distance)
- << "pixel tested: (" << x << ", " << y
- << std::hex << std::showbase
- << "), lanczos2 hex: " << color_lanczos2
- << ", lanczos3 hex: " << color_lanczos3
- << std::setprecision(2)
- << ", distance: " << distance;
-
- if (distance > max_color_distance) {
- all_pixels_ok = false;
- }
- if (distance > max_observed_distance) {
- max_observed_distance = distance;
- }
- }
- }
-
- if (!all_pixels_ok) {
- ADD_FAILURE() << "Maximum observed color distance: "
- << max_observed_distance;
-
-#if DEBUG_BITMAP_GENERATION
- SaveBitmapToPNG(src, "/tmp/CompareLanczosMethods_source.png");
- SaveBitmapToPNG(dest_l2, "/tmp/CompareLanczosMethods_lanczos2.png");
- SaveBitmapToPNG(dest_l3, "/tmp/CompareLanczosMethods_lanczos3.png");
-#endif // #if DEBUG_BITMAP_GENERATION
- }
-}
-
#ifndef M_PI
// No M_PI in math.h on windows? No problem.
#define M_PI 3.14159265358979323846