summaryrefslogtreecommitdiffstats
path: root/gfx/2d/image_operations.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-14 05:11:39 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-14 07:43:25 +0200
commit6bb3a908d34728fec0a3520eac03ad9b69dd4a9b (patch)
treebe5f0e0c813cf342fe63d8a30376fe82e7dc0405 /gfx/2d/image_operations.cpp
parent1862bf7a35db66ce232ca5adde9bd7c71d669e1e (diff)
downloadUXP-6bb3a908d34728fec0a3520eac03ad9b69dd4a9b.tar
UXP-6bb3a908d34728fec0a3520eac03ad9b69dd4a9b.tar.gz
UXP-6bb3a908d34728fec0a3520eac03ad9b69dd4a9b.tar.lz
UXP-6bb3a908d34728fec0a3520eac03ad9b69dd4a9b.tar.xz
UXP-6bb3a908d34728fec0a3520eac03ad9b69dd4a9b.zip
Switch to Lanczos scaling from Hamming to get acceptable fast downscaling.
In visual tests we see that Hamming-1 is not as good as Lanczos-2, however it is about 40% faster, and Lanczos-2 itself is about 30% faster than Lanczos-3. The use of Hamming-1 has been deemed an unacceptable trade-off between quality and speed due to the limited pixel space it operates in, so we pick Lanczos-2 here. On modern hardware, Lanczos-2 doesn't have any noticeable impact in normal use.
Diffstat (limited to 'gfx/2d/image_operations.cpp')
-rw-r--r--gfx/2d/image_operations.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/gfx/2d/image_operations.cpp b/gfx/2d/image_operations.cpp
index 62215f007..79fa879d9 100644
--- a/gfx/2d/image_operations.cpp
+++ b/gfx/2d/image_operations.cpp
@@ -1,4 +1,5 @@
// Copyright (c) 2006-2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2018 Mark Straver BASc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
@@ -107,7 +108,7 @@ void ComputeFilters(ImageOperations::ResizeMethod method,
// 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.
+ float filter_sum = 0.0f; // Sum 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
@@ -158,28 +159,22 @@ void ComputeFilters(ImageOperations::ResizeMethod method,
ImageOperations::ResizeMethod ResizeMethodToAlgorithmMethod(
ImageOperations::ResizeMethod method) {
- // Convert any "Quality Method" into an "Algorithm Method"
+ // If we already have an "Algorithm Method", just return that.
if (method >= ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD &&
method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD) {
return method;
}
- // The call to ImageOperationsGtv::Resize() above took care of
- // GPU-acceleration in the cases where it is possible. So now we just
- // pick the appropriate software method for each resize quality.
+ // Convert any "Quality Method" into an "Algorithm Method"
switch (method) {
- // Users of RESIZE_GOOD are willing to trade a lot of quality to
- // get speed, allowing the use of linear resampling to get hardware
- // acceleration (SRB). Hence any of our "good" software filters
- // will be acceptable, and we use the fastest one, Hamming-1.
case ImageOperations::RESIZE_GOOD:
- // Users of RESIZE_BETTER are willing to trade some quality in order
- // to improve performance, but are guaranteed not to devolve to a linear
- // resampling. In visual tests we see that Hamming-1 is not as good as
- // Lanczos-2, however it is about 40% faster and Lanczos-2 itself is
+ // Users of RESIZE_GOOD are willing to trade quality to get speed.
+ // In visual tests we see that Hamming-1 is not as good as
+ // Lanczos-2, however it is about 40% faster, and Lanczos-2 itself is
// about 30% faster than Lanczos-3. The use of Hamming-1 has been deemed
- // an acceptable trade-off between quality and speed.
+ // an unacceptable trade-off between quality and speed due to the limited
+ // pixel space it operates in, so we pick Lanczos-2 here.
case ImageOperations::RESIZE_BETTER:
- return ImageOperations::RESIZE_HAMMING1;
+ return ImageOperations::RESIZE_LANCZOS2;
default:
return ImageOperations::RESIZE_LANCZOS3;
}