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 * The GrSurfaceOrigin of the result will watch the GrSurfaceOrigin of srcView. The output
24 * color type, color space, and alpha type will be the same as the src.
25 *
26 * Note: one of sigmaX and sigmaY should be non-zero!
27 * @param context The GPU context
28 * @param srcView The source to be blurred.
29 * @param srcColorType The colorType of srcProxy
30 * @param srcAlphaType The alphaType of srcProxy
31 * @param colorSpace Color space of the source.
32 * @param dstBounds The destination bounds, relative to the source texture.
33 * @param srcBounds The source bounds, relative to the source texture's offset. No pixels
34 * will be sampled outside of this rectangle.
35 * @param sigmaX The blur's standard deviation in X.
36 * @param sigmaY The blur's standard deviation in Y.
37 * @param tileMode The mode to handle samples outside bounds.
38 * @param fit backing fit for the returned render target context
39 * @return The renderTargetContext containing the blurred result.
40 */
41std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
42 GrSurfaceProxyView srcView,
43 GrColorType srcColorType,
44 SkAlphaType srcAlphaType,
45 sk_sp<SkColorSpace> colorSpace,
46 SkIRect dstBounds,
47 SkIRect srcBounds,
48 float sigmaX,
49 float sigmaY,
50 SkTileMode mode,
51 SkBackingFit fit = SkBackingFit::kApprox);
52} // namespace SkGpuBlurUtils
53
54#endif
55#endif
56