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

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

Issue 471473002: Optimize CSS box-shadow performance (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: store SkMask and SkCachedData in cache Created 6 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkBlurMask_DEFINED 8 #ifndef SkBlurMask_DEFINED
9 #define SkBlurMask_DEFINED 9 #define SkBlurMask_DEFINED
10 10
11 #include "SkBlurTypes.h" 11 #include "SkBlurTypes.h"
12 #include "SkCachedData.h"
12 #include "SkShader.h" 13 #include "SkShader.h"
13 #include "SkMask.h" 14 #include "SkMask.h"
14 #include "SkRRect.h" 15 #include "SkRRect.h"
15 16
16 class SkBlurMask { 17 class SkBlurMask {
17 public: 18 public:
18 static bool BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src, SkBlurS tyle, 19 static bool BlurRect(SkScalar sigma, SkMask *dst, SkCachedData** data, const SkRect &src,
19 SkIPoint *margin = NULL, 20 SkBlurStyle, SkIPoint *margin = NULL,
20 SkMask::CreateMode createMode = 21 SkMask::CreateMode createMode =
21 SkMask::kComputeBoundsAndRenderI mage_CreateMode); 22 SkMask::kComputeBoundsAndRenderI mage_CreateMode);
22 static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src, SkBlu rStyle, 23 static bool BlurRRect(SkScalar sigma, SkMask *dst, SkCachedData** data, cons t SkRRect &src,
23 SkIPoint *margin = NULL, 24 SkBlurStyle, SkIPoint *margin = NULL,
24 SkMask::CreateMode createMode = 25 SkMask::CreateMode createMode =
25 SkMask::kComputeBoundsAndRenderI mage_CreateMode); 26 SkMask::kComputeBoundsAndRenderI mage_CreateMode);
26 27
27 // forceQuality will prevent BoxBlur from falling back to the low quality ap proach when sigma 28 // forceQuality will prevent BoxBlur from falling back to the low quality ap proach when sigma
28 // is very small -- this can be used predict the margin bump ahead of time w ithout completely 29 // is very small -- this can be used predict the margin bump ahead of time w ithout completely
29 // replicating the internal logic. This permits not only simpler caching of blurred results, 30 // replicating the internal logic. This permits not only simpler caching of blurred results,
30 // but also being able to predict precisely at what pixels the blurred profi le of e.g. a 31 // but also being able to predict precisely at what pixels the blurred profi le of e.g. a
31 // rectangle will lie. 32 // rectangle will lie.
32 33
33 static bool BoxBlur(SkMask* dst, const SkMask& src, 34 static bool BoxBlur(SkMask* dst, SkCachedData** data, const SkMask& src,
34 SkScalar sigma, SkBlurStyle style, SkBlurQuality quality , 35 SkScalar sigma, SkBlurStyle style, SkBlurQuality quality ,
35 SkIPoint* margin = NULL, bool force_quality=false); 36 SkIPoint* margin = NULL, bool force_quality=false);
36 37
37 // the "ground truth" blur does a gaussian convolution; it's slow 38 // the "ground truth" blur does a gaussian convolution; it's slow
38 // but useful for comparison purposes. 39 // but useful for comparison purposes.
39 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, SkBlurStyle, 40 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, SkBlurStyle,
40 SkIPoint* margin = NULL); 41 SkIPoint* margin = NULL);
41 42
42 // If radius > 0, return the corresponding sigma, else return 0 43 // If radius > 0, return the corresponding sigma, else return 0
43 static SkScalar ConvertRadiusToSigma(SkScalar radius); 44 static SkScalar ConvertRadiusToSigma(SkScalar radius);
(...skipping 25 matching lines...) Expand all
69 @param pixels Location to store the resulting pixel data; allocated and managed by caller 70 @param pixels Location to store the resulting pixel data; allocated and managed by caller
70 @param profile Precomputed blur profile computed by ComputeBlurProfile a bove. 71 @param profile Precomputed blur profile computed by ComputeBlurProfile a bove.
71 @param width Size of the pixels array. 72 @param width Size of the pixels array.
72 @param sigma Standard deviation of the gaussian blur kernel used to comp ute the profile; 73 @param sigma Standard deviation of the gaussian blur kernel used to comp ute the profile;
73 this implicitly gives the size of the pixels array. 74 this implicitly gives the size of the pixels array.
74 */ 75 */
75 76
76 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, 77 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile,
77 unsigned int width, SkScalar sigma); 78 unsigned int width, SkScalar sigma);
78 79
79
80
81 }; 80 };
82 81
83 #endif 82 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698