SkGpuBlurUtils.h 2.4 KB

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