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 "src/gpu/GrRenderTargetContext.h"
13
14class GrContext;
15class GrTexture;
16
17struct SkRect;
18
19namespace SkGpuBlurUtils {
20/**
21 * Applies a 2D Gaussian blur to a given texture. The blurred result is returned
22 * as a renderTargetContext in case the caller wishes to draw into the result.
23 *
24 * The 'proxyOffset' is kept separate form 'srcBounds' because they exist in different
25 * coordinate spaces. 'srcBounds' exists in the content space of the special image, and
26 * 'proxyOffset' maps from the content space to the proxy's space.
27 *
28 * Note: one of sigmaX and sigmaY should be non-zero!
29 * @param context The GPU context
30 * @param srcView The source to be blurred.
31 * @param srcColorType The colorType of srcProxy
32 * @param srcAlphaType The alphaType of srcProxy
33 * @param colorSpace Color space of the source (used for the renderTargetContext result,
34 * too).
35 * @param dstBounds The destination bounds, relative to the source texture.
36 * @param srcBounds The source bounds, relative to the source texture's offset. No pixels
37 * will be sampled outside of this rectangle.
38 * @param sigmaX The blur's standard deviation in X.
39 * @param sigmaY The blur's standard deviation in Y.
40 * @param tileMode The mode to handle samples outside bounds.
41 * @param fit backing fit for the returned render target context
42 * @return The renderTargetContext containing the blurred result.
43 */
44std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
45 GrSurfaceProxyView srcView,
46 GrColorType srcColorType,
47 SkAlphaType srcAlphaType,
48 sk_sp<SkColorSpace> colorSpace,
49 const SkIRect& dstBounds,
50 const SkIRect& srcBounds,
51 float sigmaX,
52 float sigmaY,
53 SkTileMode mode,
54 SkBackingFit fit = SkBackingFit::kApprox);
55};
56
57#endif
58#endif
59