blob: 8a6f7b19225c9937fc120139df019f3ec32bd862 [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"
wutao039a7c72017-06-30 10:44:45 -070013#include "effects/GrTextureDomain.h"
reedc9b5f8b2015-10-22 13:20:20 -070014
robertphillipsf8237782016-05-11 12:41:35 -070015class GrContext;
robertphillips04c84af2016-05-12 11:13:00 -070016class GrTexture;
robertphillips@google.com736dd032013-07-15 15:06:54 +000017
18struct SkRect;
19
20namespace SkGpuBlurUtils {
robertphillips@google.com736dd032013-07-15 15:06:54 +000021 /**
robertphillips04c84af2016-05-12 11:13:00 -070022 * Applies a 2D Gaussian blur to a given texture. The blurred result is returned
Brian Osman11052242016-10-27 14:47:55 -040023 * as a renderTargetContext in case the caller wishes to future draw into the result.
robertphillips04c84af2016-05-12 11:13:00 -070024 * Note: one of sigmaX and sigmaY should be non-zero!
robertphillips@google.com736dd032013-07-15 15:06:54 +000025 * @param context The GPU context
Robert Phillips08c5ec72017-01-30 12:26:47 -050026 * @param src The source to be blurred.
Brian Osman11052242016-10-27 14:47:55 -040027 * @param colorSpace Color space of the source (used for the renderTargetContext result,
28 * too).
senorblanco07d56b12015-11-10 07:32:37 -080029 * @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.
robertphillips@google.com736dd032013-07-15 15:06:54 +000032 * @param sigmaX The blur's standard deviation in X.
33 * @param sigmaY The blur's standard deviation in Y.
wutao039a7c72017-06-30 10:44:45 -070034 * @param mode The mode to handle samples outside bounds.
Brian Osman11052242016-10-27 14:47:55 -040035 * @param fit backing fit for the returned render target context
36 * @return The renderTargetContext containing the blurred result.
robertphillips@google.com736dd032013-07-15 15:06:54 +000037 */
wutao039a7c72017-06-30 10:44:45 -070038 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);
robertphillips@google.com736dd032013-07-15 15:06:54 +000048};
49
robertphillips@google.comcce41022013-07-15 15:47:10 +000050#endif
robertphillips04c84af2016-05-12 11:13:00 -070051#endif