GrPathRendering.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright 2014 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. #include "include/core/SkMatrix.h"
  8. #include "include/core/SkTypeface.h"
  9. #include "include/gpu/GrRenderTarget.h"
  10. #include "src/core/SkDescriptor.h"
  11. #include "src/core/SkGlyph.h"
  12. #include "src/core/SkScalerContext.h"
  13. #include "src/gpu/GrGpu.h"
  14. #include "src/gpu/GrPathRendering.h"
  15. const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) {
  16. switch (fill) {
  17. default:
  18. SK_ABORT("Unexpected path fill.");
  19. case GrPathRendering::kWinding_FillType: {
  20. constexpr static GrUserStencilSettings kWindingStencilPass(
  21. GrUserStencilSettings::StaticInit<
  22. 0xffff,
  23. GrUserStencilTest::kAlwaysIfInClip,
  24. 0xffff,
  25. GrUserStencilOp::kIncWrap,
  26. GrUserStencilOp::kIncWrap,
  27. 0xffff>()
  28. );
  29. return kWindingStencilPass;
  30. }
  31. case GrPathRendering::kEvenOdd_FillType: {
  32. constexpr static GrUserStencilSettings kEvenOddStencilPass(
  33. GrUserStencilSettings::StaticInit<
  34. 0xffff,
  35. GrUserStencilTest::kAlwaysIfInClip,
  36. 0xffff,
  37. GrUserStencilOp::kInvert,
  38. GrUserStencilOp::kInvert,
  39. 0xffff>()
  40. );
  41. return kEvenOddStencilPass;
  42. }
  43. }
  44. }
  45. void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) {
  46. fGpu->handleDirtyContext();
  47. this->onStencilPath(args, path);
  48. }
  49. void GrPathRendering::drawPath(GrRenderTarget* renderTarget, GrSurfaceOrigin origin,
  50. const GrPrimitiveProcessor& primProc,
  51. const GrPipeline& pipeline,
  52. const GrPipeline::FixedDynamicState& fixedDynamicState,
  53. // Cover pass settings in pipeline.
  54. const GrStencilSettings& stencilPassSettings,
  55. const GrPath* path) {
  56. fGpu->handleDirtyContext();
  57. if (GrXferBarrierType barrierType = pipeline.xferBarrierType(renderTarget->asTexture(),
  58. *fGpu->caps())) {
  59. fGpu->xferBarrier(renderTarget, barrierType);
  60. }
  61. this->onDrawPath(renderTarget, origin, primProc, pipeline, fixedDynamicState,
  62. stencilPassSettings, path);
  63. }