robertphillips@google.com | 736dd03 | 2013-07-15 15:06:54 +0000 | [diff] [blame] | 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 |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 12 | #include "GrRenderTargetContext.h" |
wutao | 039a7c7 | 2017-06-30 10:44:45 -0700 | [diff] [blame] | 13 | #include "effects/GrTextureDomain.h" |
reed | c9b5f8b | 2015-10-22 13:20:20 -0700 | [diff] [blame] | 14 | |
robertphillips | f823778 | 2016-05-11 12:41:35 -0700 | [diff] [blame] | 15 | class GrContext; |
robertphillips | 04c84af | 2016-05-12 11:13:00 -0700 | [diff] [blame] | 16 | class GrTexture; |
robertphillips@google.com | 736dd03 | 2013-07-15 15:06:54 +0000 | [diff] [blame] | 17 | |
| 18 | struct SkRect; |
| 19 | |
| 20 | namespace SkGpuBlurUtils { |
robertphillips@google.com | 736dd03 | 2013-07-15 15:06:54 +0000 | [diff] [blame] | 21 | /** |
robertphillips | 04c84af | 2016-05-12 11:13:00 -0700 | [diff] [blame] | 22 | * Applies a 2D Gaussian blur to a given texture. The blurred result is returned |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 23 | * as a renderTargetContext in case the caller wishes to future draw into the result. |
robertphillips | 04c84af | 2016-05-12 11:13:00 -0700 | [diff] [blame] | 24 | * Note: one of sigmaX and sigmaY should be non-zero! |
robertphillips@google.com | 736dd03 | 2013-07-15 15:06:54 +0000 | [diff] [blame] | 25 | * @param context The GPU context |
Robert Phillips | 08c5ec7 | 2017-01-30 12:26:47 -0500 | [diff] [blame] | 26 | * @param src The source to be blurred. |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 27 | * @param colorSpace Color space of the source (used for the renderTargetContext result, |
| 28 | * too). |
senorblanco | 07d56b1 | 2015-11-10 07:32:37 -0800 | [diff] [blame] | 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. |
robertphillips@google.com | 736dd03 | 2013-07-15 15:06:54 +0000 | [diff] [blame] | 32 | * @param sigmaX The blur's standard deviation in X. |
| 33 | * @param sigmaY The blur's standard deviation in Y. |
wutao | 039a7c7 | 2017-06-30 10:44:45 -0700 | [diff] [blame] | 34 | * @param mode The mode to handle samples outside bounds. |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 35 | * @param fit backing fit for the returned render target context |
| 36 | * @return The renderTargetContext containing the blurred result. |
robertphillips@google.com | 736dd03 | 2013-07-15 15:06:54 +0000 | [diff] [blame] | 37 | */ |
wutao | 039a7c7 | 2017-06-30 10:44:45 -0700 | [diff] [blame] | 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); |
robertphillips@google.com | 736dd03 | 2013-07-15 15:06:54 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
robertphillips@google.com | cce4102 | 2013-07-15 15:47:10 +0000 | [diff] [blame] | 50 | #endif |
robertphillips | 04c84af | 2016-05-12 11:13:00 -0700 | [diff] [blame] | 51 | #endif |