summaryrefslogtreecommitdiffstats
path: root/skia/ext/image_operations_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Change includes of gfx/* to ui/gfx/*sail@chromium.org2011-02-051-1/+1
| | | | | | | | | BUG=71063 TEST=compiled Review URL: http://codereview.chromium.org/6312156 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73890 0039d316-1c4b-4281-b951-d872f2087c98
* Integration of most changes from the GoogleTV project around the ↵brettw@chromium.org2011-01-301-26/+523
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | convolver/scaler. This contains the following improvements: - Adding a few extra convolution filters on top of the existing LANCZOS3 (used internally in Chrome), and BOX (used in unit tests): - LANCZOS2: a variation of LANCZOS3 except that the windowed function is limited to the [-2:2] range. - HAMMING1: this uses a Hamming window using the [-1:-1] range. If we define the zoom down factor to z, and w the size of the window, the actual cost of each filter (CPU wise) is proportional to (w * 2 * z + 1). So, if we look at what happens when you zoom down by a factor of 4 (as often found when creating thumbnails), the cost would be 25 for LANCZOS3, 17 for LANCZOS2, and 9 for HAMMING. As a result, HAMMING1 can end up be roughly three times as fast as the typical LANCZOS3. In terms of visual quality, HAMMING1 will be obviously worse than filters that have a larger window. The motivation of this change is that not all processors are equally equipped, and while LANCZOS3 does provide good quality, it will be completely inadequate in speed on slower processors (as found on Google TV), and it would be worth trading some visual quality for speed. Because the definitions of what is acceptable from one platform to another will differ, this change adds generic enums describing various trade offs between quality and speed. And depending on the platform, these would then be mapped to different filters. This change does not contain the other changes made to the all the call sites to transform LANCZOS3 to the appropriate enum. Another CL will have to be checked in for the policy definition. - Improvements in speed by around 10% (the actual speed up depends on the parameters of the scale (scale ratios, sizes of images), as well as the actual processor on which this is run on. The 10% was measured on scale down of 1920x1080 images to 1920/4x1080/4 using the LANCZOS3 filter on a 32bit Atom based using the image_operations_bench. Actual numbers for a 64bit processor are discussed below. This optimization attempts to basically eliminate all zeroes on each side of the filter_size, since it is very likely that the calculated window will go one fraction of a pixel outside of the window where the function is actuall not zero. In many cases, this means it gets rid the convolution by one point. So, using the math above, (w * 2 * z + 1) will have 1 subtracted. The code though is generic and will get rid of more points if possible. - To measure speed, a small utility image_operations_bench was added. Its purpose is to simply measure speed of the actual speed of the convolution without any regards to the actual data. Run with --help for a list of options. The actual measured number is in MB/s (source MB + dest MB / time). The following numbers were found on a 64 bit Release build on a z600: | zero optimization | Filter | no | yes | Hamming1 | 459 | 495 | Lanczos2 | 276 | 294 | Lanczos3 | 202 | 207 | The command line was: for i in HAMMING1 LANCZOS2 LANCZOS3 ; do echo $i; out/Release/image_operations_bench -source 1920x1080 -destination 480x270 -m $i -iter 50 ; done The actual improvements for the zero optimization mentioned above are much more prevalent on a 32bit Atom. - Commented that there is half-pixel error inside the code in image_operations. Because this would effectively changes the results of many scales that are used in win_layout tests, this would effectively break them. As a result, the change here only adds comments about what needs to be changed, but does not fix the issue itself. A subsequent change will remove the comments and enable the fix, and also adds the corrected reference images used for the test. See bug 69999: http://code.google.com/p/chromium/issues/detail?id=69999 - Enhanced the convolver to support arbitrary strides, instead of the hard coded 4 * width. This value is correct on most platforms, but is not on GoogleTV since buffers allocated need to be 32 pixel multiples to exploit HW capabilities. - Added numerous unit tests to cover the new filters as well as adding other ones that are more rigourous than the existing ones. Such a test is the reason, we have found the half pixel error mentioned above. TEST=This was tested against the existing unit tests, and the added unit tests on a 64 bit Linux platform. The tests were then ran under valgrind to check for possible memory leaks/ and errors. The tests do come out clean (except the preexisting file descriptor 'leaks' coming from other tests that are linked with test_shell_tests Actual credit to most of the actual changes go to various contributors of the Google TV team. Note that there are two types of optimizations that are possible beyond these changes that are not done here: 1/ Use the fact that the filter coefficients will be periodic to reduce the cost of calculating the coefficients (though typically in the noise), but rather when the convolution is done to decrease cache misses on the coefficients. Experiments showed that on an Atom, this can yield 5 % improvement. 2/ This code is the prime target for the use of SIMD instructions. BUG=47447, 62820, 69999 Patch by evannier@google.com Original review http://codereview.chromium.org/5575010/ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73110 0039d316-1c4b-4281-b951-d872f2087c98
* Move functions from skia/ext to app/gfx where possible: most of skia_utils.* ↵pkasting@chromium.org2009-09-241-376/+4
| | | | | | | | | | | | | and image_operations.* can be moved because they are not used by WebKit code. This also fixes the spelling of "Convolusion" to "Convolution" and updates some copyrights. This is a re-do of r26975, this time with WebKit update and some fixes to compile on Mac and Linux. BUG=none TEST=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27031 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 26975.pkasting@chromium.org2009-09-231-4/+376
| | | | | | Review URL: http://codereview.chromium.org/222011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26979 0039d316-1c4b-4281-b951-d872f2087c98
* Move functions from skia/ext to app/gfx where possible: most of skia_utils.* ↵pkasting@chromium.org2009-09-231-376/+4
| | | | | | | | | | | | and image_operations.* can be moved because they are not used by WebKit code. This also fixes the spelling of "Convolusion" to "Convolution" and updates some copyrights. BUG=none TEST=none Review URL: http://codereview.chromium.org/207059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26975 0039d316-1c4b-4281-b951-d872f2087c98
* Enable skia asserts. They were disabled some time ago due tosenorblanco@chromium.org2009-08-101-4/+4
| | | | | | | | | | | | http://crbug.com/6372, which has since been fixed. Some existing asserts were failing due to having been untested, and were fixed in this CL. BUG=http://crbug.com/6373. TEST=unit tests, layout tests, etc do not assert Review URL: http://codereview.chromium.org/165223 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22916 0039d316-1c4b-4281-b951-d872f2087c98
* Attempt to fix the ImageOperations::CreateMaskedBitmap UMR by bringing the ↵glen@chromium.org2009-07-251-8/+9
| | | | | | | | | | | | | | unittest code in line with the other tests in image_operations_unittest. My half-educated suspicion is that alpha wasn't getting initted correctly, as a new UMR appeared in the "SkColor alpha_pixel = " line. (Can't verify as all my machines are in boxes). (This is TBR because the build is red). TBR=tony BUG=15762 TEST=Run valgrind/purify as in bug Review URL: http://codereview.chromium.org/159381 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21610 0039d316-1c4b-4281-b951-d872f2087c98
* Our masker didn't account for the source image also having alpha.glen@chromium.org2009-07-251-10/+13
| | | | | | | | | BUG=17568 TEST=none Review URL: http://codereview.chromium.org/160034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21606 0039d316-1c4b-4281-b951-d872f2087c98
* Enable some skia unittests on linux and mac.tc@google.com2009-07-011-6/+6
| | | | | | | | | | This enables the ImageOperations.* and SkiaUtils.* test_shell_tests on linux and mac. Review URL: http://codereview.chromium.org/151097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19701 0039d316-1c4b-4281-b951-d872f2087c98
* Add a mipmap-like divide-by-two image scaling algorithm. I am going to use thisbrettw@chromium.org2009-06-091-0/+113
| | | | | | | for on-the-fly generated thumbnails. Review URL: http://codereview.chromium.org/118341 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17957 0039d316-1c4b-4281-b951-d872f2087c98
* Fix Skia includes to use the whole path name.brettw@chromium.org2009-05-191-2/+2
| | | | | | Review URL: http://codereview.chromium.org/115412 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16374 0039d316-1c4b-4281-b951-d872f2087c98
* This CL updates chrome to the latest version of skia, retrieved via DEPS, andsenorblanco@chromium.org2009-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | placed in third_party. All relevant skia changes (for all 3 platforms) have been upstreamed. Most of this CL is mind-numbingly repetitive. Things of interest are: skia.gyp (now points at third_party versions), DEPS, and SkUserConfig.h. stdint.h: Skia now requires C99 integer types, which MSVC doesn't support natively. I have put typedefs in config/win/stdint.h. Note that the new version of skia appears to render rects whose coordinates are "backwards" (ie., x2 < x1 or y2 < y1), which were formerly culled. There were a couple obvious instances of this in the code which I fixed, but there may be more. There were ~35 layout test failures due to minor pixel differences which I rebaselined on Windows and Linux, and 8 genuine failures related to masks and stroked text, which I have put in text_expectations.txt and assigned to myself. (There was another change which broke ~1700 tests on each platform, but I put that change behind an #ifdef for now). R=brettw Review URL: http://codereview.chromium.org/65012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15949 0039d316-1c4b-4281-b951-d872f2087c98
* This is the first pass at themes.glen@chromium.org2009-05-091-2/+2
| | | | | | | | | | | | This CL is paired with http://codereview.chromium.org/67284 This CL (for commit purposes) includes http://codereview.chromium.org/67284 BUG=4463,11232,11233,11234,11235 Review URL: http://codereview.chromium.org/99030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15704 0039d316-1c4b-4281-b951-d872f2087c98
* Redo of http://codereview.chromium.org/100097 to make work on Linux and Mac.glen@chromium.org2009-05-061-0/+254
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15380 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 14712 on behalf of glen.hbono@chromium.org2009-04-281-254/+0
| | | | | | | TBR=glen Review URL: http://codereview.chromium.org/100097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14713 0039d316-1c4b-4281-b951-d872f2087c98
* Add bitmap manipulation functions in advance of themes.glen@chromium.org2009-04-281-0/+254
| | | | | | | HSLToSkColor premultiplies its output, should this instead live in the ImageOperations bitmap munging code? Review URL: http://codereview.chromium.org/79082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14712 0039d316-1c4b-4281-b951-d872f2087c98
* Add back convolver_unittest.cc and image_operations_unittest.cc.maruel@chromium.org2009-01-221-3/+2
| | | | | | | | | | | | Fix a TODO in platform_canvas_unittest.cc. Make vector_canvas_unittest.cc slightly less dependent on base/. Remove Windows 2000 checks. (Same as r8458 with platform_canvas_unittest.cc and SConscript fixed) BUG=5113 Review URL: http://codereview.chromium.org/18511 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8498 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 8462,8458 since it broke the linux builder.maruel@chromium.org2009-01-221-2/+3
| | | | | | Review URL: http://codereview.chromium.org/18668 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8463 0039d316-1c4b-4281-b951-d872f2087c98
* Add back convolver_unittest.cc and image_operations_unittest.cc.maruel@chromium.org2009-01-221-3/+2
| | | | | | | | | | | Fix a TODO in platform_canvas_unittest.cc. Make vector_canvas_unittest.cc slightly less dependent on base/. Remove Windows 2000 checks. BUG=5113 Review URL: http://codereview.chromium.org/18623 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8458 0039d316-1c4b-4281-b951-d872f2087c98
* Move Image operations and convolver to the skia namespace and clean up a few ↵brettw@google.com2008-12-121-7/+7
| | | | | | | | (but not all) base types. Review URL: http://codereview.chromium.org/13726 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6921 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 6709,6708,6706.brettw@google.com2008-12-101-13/+11
| | | | | | Review URL: http://codereview.chromium.org/13345 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6710 0039d316-1c4b-4281-b951-d872f2087c98
* Remove base dependency from image_operations and associated unittests. I ↵brettw@google.com2008-12-101-11/+13
| | | | | | | | | also renamed the namespace from "gfx" to "skia". This also adds back the image_operations_unittest to a project (this had gotten lost in my move). Review URL: http://codereview.chromium.org/13143 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6706 0039d316-1c4b-4281-b951-d872f2087c98
* Move convolver and image_operations from base/gfx to skia/ext. This is justbrettw@google.com2008-12-031-0/+148
| | | | | | | | like my previous change except does no namespace renaming and doesn't touch skia_utils. Review URL: http://codereview.chromium.org/13080 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6290 0039d316-1c4b-4281-b951-d872f2087c98
* Revert my skia file moves because of layout test failures.brettw@google.com2008-12-031-149/+0
| | | | | | Review URL: http://codereview.chromium.org/12892 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6266 0039d316-1c4b-4281-b951-d872f2087c98
* Move convolver, image_operations, and skia_utils from base/gfx to skia/ext.brettw@google.com2008-12-021-0/+149
This changes the namespace in those files from "gfx" to "skia". I split skia_utils into two parts, the Windows specific part is now in a separate file called skia_utils_win. There were several obsolete includes of these headers which I removed. I also removed img_resize_perftest which isn't used and has bitrotted. Review URL: http://codereview.chromium.org/12842 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6248 0039d316-1c4b-4281-b951-d872f2087c98