GrClearStencilClipOp.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2016 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 GrClearStencilClipOp_DEFINED
  8. #define GrClearStencilClipOp_DEFINED
  9. #include "src/gpu/GrFixedClip.h"
  10. #include "src/gpu/GrRenderTargetProxy.h"
  11. #include "src/gpu/ops/GrOp.h"
  12. class GrOpFlushState;
  13. class GrRecordingContext;
  14. class GrClearStencilClipOp final : public GrOp {
  15. public:
  16. DEFINE_OP_CLASS_ID
  17. static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
  18. const GrFixedClip& clip,
  19. bool insideStencilMask,
  20. GrRenderTargetProxy* proxy);
  21. const char* name() const override { return "ClearStencilClip"; }
  22. #ifdef SK_DEBUG
  23. SkString dumpInfo() const override {
  24. SkString string("Scissor [");
  25. if (fClip.scissorEnabled()) {
  26. const SkIRect& r = fClip.scissorRect();
  27. string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
  28. } else {
  29. string.append("disabled");
  30. }
  31. string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false");
  32. string.append(INHERITED::dumpInfo());
  33. return string;
  34. }
  35. #endif
  36. private:
  37. friend class GrOpMemoryPool; // for ctor
  38. GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
  39. GrRenderTargetProxy* proxy)
  40. : INHERITED(ClassID())
  41. , fClip(clip)
  42. , fInsideStencilMask(insideStencilMask) {
  43. const SkRect& bounds = fClip.scissorEnabled()
  44. ? SkRect::Make(fClip.scissorRect())
  45. : SkRect::MakeIWH(proxy->width(), proxy->height());
  46. this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
  47. }
  48. void onPrepare(GrOpFlushState*) override {}
  49. void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
  50. const GrFixedClip fClip;
  51. const bool fInsideStencilMask;
  52. typedef GrOp INHERITED;
  53. };
  54. #endif