1/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkGpuBlurUtils_DEFINED
9#define SkGpuBlurUtils_DEFINED
10
11#if SK_SUPPORT_GPU
12#include "GrRenderTargetContext.h"
13#include "effects/GrTextureDomain.h"
14
15class GrContext;
16class GrTexture;
17
18struct SkRect;
19
20namespace SkGpuBlurUtils {
21  /**
22    * Applies a 2D Gaussian blur to a given texture. The blurred result is returned
23    * as a renderTargetContext in case the caller wishes to future draw into the result.
24    * Note: one of sigmaX and sigmaY should be non-zero!
25    * @param context         The GPU context
26    * @param src             The source to be blurred.
27    * @param colorSpace      Color space of the source (used for the renderTargetContext result,
28    *                        too).
29    * @param dstBounds       The destination bounds, relative to the source texture.
30    * @param srcBounds       The source bounds, relative to the source texture. If non-null,
31    *                        no pixels will be sampled outside of this rectangle.
32    * @param sigmaX          The blur's standard deviation in X.
33    * @param sigmaY          The blur's standard deviation in Y.
34    * @param mode            The mode to handle samples outside bounds.
35    * @param fit             backing fit for the returned render target context
36    * @return                The renderTargetContext containing the blurred result.
37    */
38    sk_sp<GrRenderTargetContext> GaussianBlur(
39            GrContext* context,
40            sk_sp<GrTextureProxy> src,
41            sk_sp<SkColorSpace> colorSpace,
42            const SkIRect& dstBounds,
43            const SkIRect& srcBounds,
44            float sigmaX,
45            float sigmaY,
46            GrTextureDomain::Mode mode,
47            SkBackingFit fit = SkBackingFit::kApprox);
48};
49
50#endif
51#endif
52