blob: c6c56b61f7a50fd6b498ef182d4e8758583c32a5 [file] [log] [blame]
robertphillips@google.com736dd032013-07-15 15:06:54 +00001/*
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
Brian Osman11052242016-10-27 14:47:55 -040012#include "GrRenderTargetContext.h"
reedc9b5f8b2015-10-22 13:20:20 -070013
robertphillipsf8237782016-05-11 12:41:35 -070014class GrContext;
robertphillips04c84af2016-05-12 11:13:00 -070015class GrTexture;
robertphillips@google.com736dd032013-07-15 15:06:54 +000016
17struct SkRect;
18
19namespace SkGpuBlurUtils {
robertphillips@google.com736dd032013-07-15 15:06:54 +000020 /**
robertphillips04c84af2016-05-12 11:13:00 -070021 * Applies a 2D Gaussian blur to a given texture. The blurred result is returned
Brian Osman11052242016-10-27 14:47:55 -040022 * as a renderTargetContext in case the caller wishes to future draw into the result.
robertphillips04c84af2016-05-12 11:13:00 -070023 * Note: one of sigmaX and sigmaY should be non-zero!
robertphillips@google.com736dd032013-07-15 15:06:54 +000024 * @param context The GPU context
Robert Phillips08c5ec72017-01-30 12:26:47 -050025 * @param src The source to be blurred.
Brian Osman11052242016-10-27 14:47:55 -040026 * @param colorSpace Color space of the source (used for the renderTargetContext result,
27 * too).
senorblanco07d56b12015-11-10 07:32:37 -080028 * @param dstBounds The destination bounds, relative to the source texture.
29 * @param srcBounds The source bounds, relative to the source texture. If non-null,
30 * no pixels will be sampled outside of this rectangle.
robertphillips@google.com736dd032013-07-15 15:06:54 +000031 * @param sigmaX The blur's standard deviation in X.
32 * @param sigmaY The blur's standard deviation in Y.
Brian Osman11052242016-10-27 14:47:55 -040033 * @param fit backing fit for the returned render target context
34 * @return The renderTargetContext containing the blurred result.
robertphillips@google.com736dd032013-07-15 15:06:54 +000035 */
Brian Osman11052242016-10-27 14:47:55 -040036 sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
Robert Phillips08c5ec72017-01-30 12:26:47 -050037 sk_sp<GrTextureProxy> src,
Brian Osman11052242016-10-27 14:47:55 -040038 sk_sp<SkColorSpace> colorSpace,
39 const SkIRect& dstBounds,
40 const SkIRect* srcBounds,
41 float sigmaX,
42 float sigmaY,
43 SkBackingFit fit = SkBackingFit::kApprox);
robertphillips@google.com736dd032013-07-15 15:06:54 +000044};
45
robertphillips@google.comcce41022013-07-15 15:47:10 +000046#endif
robertphillips04c84af2016-05-12 11:13:00 -070047#endif