Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: src/effects/SkBlurMask.cpp

Issue 23530039: Add test to exercise extreme blur sigmas (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Renamed function Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/BlurTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBlurMask.h" 10 #include "SkBlurMask.h"
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 // useful for correctness comparisons. 865 // useful for correctness comparisons.
866 866
867 bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, 867 bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
868 Style style, SkIPoint* margin) { 868 Style style, SkIPoint* margin) {
869 869
870 if (src.fFormat != SkMask::kA8_Format) { 870 if (src.fFormat != SkMask::kA8_Format) {
871 return false; 871 return false;
872 } 872 }
873 873
874 float variance = sigma * sigma; 874 float variance = sigma * sigma;
875 875
robertphillips 2013/09/05 13:30:38 The 4x window still had some edge effects (when co
876 int windowSize = SkScalarCeil(sigma*4); 876 int windowSize = SkScalarCeil(sigma*6);
877 // round window size up to nearest odd number 877 // round window size up to nearest odd number
878 windowSize |= 1; 878 windowSize |= 1;
879 879
880 SkAutoTMalloc<float> gaussWindow(windowSize); 880 SkAutoTMalloc<float> gaussWindow(windowSize);
881 881
882 int halfWindow = windowSize >> 1; 882 int halfWindow = windowSize >> 1;
883 883
884 gaussWindow[halfWindow] = 1; 884 gaussWindow[halfWindow] = 1;
885 885
886 float windowSum = 1; 886 float windowSum = 1;
887 for (int x = 1 ; x <= halfWindow ; ++x) { 887 for (int x = 1 ; x <= halfWindow ; ++x) {
888 float gaussian = expf(-x*x / variance); 888 float gaussian = expf(-x*x / (2*variance));
humper 2013/09/05 14:19:23 WHOOPS, nice catch.
889 gaussWindow[halfWindow + x] = gaussWindow[halfWindow-x] = gaussian; 889 gaussWindow[halfWindow + x] = gaussWindow[halfWindow-x] = gaussian;
890 windowSum += 2*gaussian; 890 windowSum += 2*gaussian;
891 } 891 }
892 892
893 // leave the filter un-normalized for now; we will divide by the normalizati on 893 // leave the filter un-normalized for now; we will divide by the normalizati on
894 // sum later; 894 // sum later;
895 895
896 int pad = halfWindow; 896 int pad = halfWindow;
897 if (margin) { 897 if (margin) {
898 margin->set( pad, pad ); 898 margin->set( pad, pad );
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 (void)autoCall.detach(); 1000 (void)autoCall.detach();
1001 } 1001 }
1002 1002
1003 if (style == kInner_Style) { 1003 if (style == kInner_Style) {
1004 dst->fBounds = src.fBounds; // restore trimmed bounds 1004 dst->fBounds = src.fBounds; // restore trimmed bounds
1005 dst->fRowBytes = src.fRowBytes; 1005 dst->fRowBytes = src.fRowBytes;
1006 } 1006 }
1007 1007
1008 return true; 1008 return true;
1009 } 1009 }
OLDNEW
« no previous file with comments | « no previous file | tests/BlurTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698