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