GrSoftwarePathRenderer.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2012 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 GrSoftwarePathRenderer_DEFINED
  8. #define GrSoftwarePathRenderer_DEFINED
  9. #include "src/gpu/GrPathRenderer.h"
  10. class GrProxyProvider;
  11. class GrTextureProxy;
  12. /**
  13. * This class uses the software side to render a path to an SkBitmap and
  14. * then uploads the result to the gpu
  15. */
  16. class GrSoftwarePathRenderer : public GrPathRenderer {
  17. public:
  18. GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching)
  19. : fProxyProvider(proxyProvider)
  20. , fAllowCaching(allowCaching) {
  21. }
  22. static bool GetShapeAndClipBounds(GrRenderTargetContext*,
  23. const GrClip& clip,
  24. const GrShape& shape,
  25. const SkMatrix& matrix,
  26. SkIRect* unclippedDevShapeBounds,
  27. SkIRect* clippedDevShapeBounds,
  28. SkIRect* devClipBounds);
  29. private:
  30. static void DrawNonAARect(GrRenderTargetContext* renderTargetContext,
  31. GrPaint&& paint,
  32. const GrUserStencilSettings& userStencilSettings,
  33. const GrClip& clip,
  34. const SkMatrix& viewMatrix,
  35. const SkRect& rect,
  36. const SkMatrix& localMatrix);
  37. static void DrawAroundInvPath(GrRenderTargetContext* renderTargetContext,
  38. GrPaint&& paint,
  39. const GrUserStencilSettings& userStencilSettings,
  40. const GrClip& clip,
  41. const SkMatrix& viewMatrix,
  42. const SkIRect& devClipBounds,
  43. const SkIRect& devPathBounds);
  44. // This utility draws a path mask using a provided paint. The rectangle is drawn in device
  45. // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
  46. // any fragment processors in the paint.
  47. static void DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy,
  48. GrRenderTargetContext* renderTargetContext,
  49. GrPaint&& paint,
  50. const GrUserStencilSettings& userStencilSettings,
  51. const GrClip& clip,
  52. const SkMatrix& viewMatrix,
  53. const SkIPoint& textureOriginInDeviceSpace,
  54. const SkIRect& deviceSpaceRectToDraw);
  55. StencilSupport onGetStencilSupport(const GrShape&) const override {
  56. return GrPathRenderer::kNoSupport_StencilSupport;
  57. }
  58. CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
  59. bool onDrawPath(const DrawPathArgs&) override;
  60. private:
  61. GrProxyProvider* fProxyProvider;
  62. bool fAllowCaching;
  63. typedef GrPathRenderer INHERITED;
  64. };
  65. #endif