GrStencilPathOp.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2017 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 "src/gpu/ops/GrStencilPathOp.h"
  8. #include "include/private/GrRecordingContext.h"
  9. #include "src/gpu/GrGpu.h"
  10. #include "src/gpu/GrMemoryPool.h"
  11. #include "src/gpu/GrOpFlushState.h"
  12. #include "src/gpu/GrRecordingContextPriv.h"
  13. #include "src/gpu/GrRenderTargetPriv.h"
  14. std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext* context,
  15. const SkMatrix& viewMatrix,
  16. bool useHWAA,
  17. GrPathRendering::FillType fillType,
  18. bool hasStencilClip,
  19. const GrScissorState& scissor,
  20. const GrPath* path) {
  21. GrOpMemoryPool* pool = context->priv().opMemoryPool();
  22. return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA, fillType,
  23. hasStencilClip, scissor, path);
  24. }
  25. void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
  26. GrRenderTarget* rt = state->drawOpArgs().renderTarget();
  27. SkASSERT(rt);
  28. int numStencilBits = rt->renderTargetPriv().numStencilBits();
  29. GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fFillType),
  30. fHasStencilClip, numStencilBits);
  31. GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy,
  32. &fViewMatrix, &fScissor, &stencil);
  33. state->gpu()->pathRendering()->stencilPath(args, fPath.get());
  34. }