GrCopySurfaceOp.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright 2015 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 GrCopySurfaceOp_DEFINED
  8. #define GrCopySurfaceOp_DEFINED
  9. #include "src/gpu/GrOpFlushState.h"
  10. #include "src/gpu/ops/GrOp.h"
  11. class GrRecordingContext;
  12. class GrCopySurfaceOp final : public GrOp {
  13. public:
  14. DEFINE_OP_CLASS_ID
  15. static std::unique_ptr<GrOp> Make(GrRecordingContext*,
  16. GrSurfaceProxy* dst,
  17. GrSurfaceProxy* src,
  18. const SkIRect& srcRect,
  19. const SkIPoint& dstPoint);
  20. const char* name() const override { return "CopySurface"; }
  21. void visitProxies(const VisitProxyFunc& func) const override {
  22. func(fSrc.get(), GrMipMapped::kNo);
  23. func(fDst.get(), GrMipMapped::kNo);
  24. }
  25. #ifdef SK_DEBUG
  26. SkString dumpInfo() const override {
  27. SkString string;
  28. string = INHERITED::dumpInfo();
  29. string.appendf(
  30. "srcProxyID: %d,\n"
  31. "srcRect: [ L: %d, T: %d, R: %d, B: %d ], dstPt: [ X: %d, Y: %d ]\n",
  32. fSrc.get()->uniqueID().asUInt(), fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight,
  33. fSrcRect.fBottom, fDstPoint.fX, fDstPoint.fY);
  34. return string;
  35. }
  36. #endif
  37. private:
  38. friend class GrOpMemoryPool; // for ctor
  39. GrCopySurfaceOp(GrSurfaceProxy* src, GrSurfaceProxy* dst, const SkIRect& srcRect,
  40. const SkIPoint& dstPoint)
  41. : INHERITED(ClassID())
  42. , fSrc(src)
  43. , fDst(dst)
  44. , fSrcRect(srcRect)
  45. , fDstPoint(dstPoint) {
  46. SkRect bounds =
  47. SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
  48. SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
  49. this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
  50. SkASSERT(dst->origin() == src->origin());
  51. if (kBottomLeft_GrSurfaceOrigin == src->origin()) {
  52. int rectHeight = fSrcRect.height();
  53. fSrcRect.fTop = src->height() - fSrcRect.fBottom;
  54. fSrcRect.fBottom = fSrcRect.fTop + rectHeight;
  55. fDstPoint.fY = dst->height() - fDstPoint.fY - rectHeight;
  56. }
  57. }
  58. void onPrepare(GrOpFlushState*) override {}
  59. void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
  60. GrProxyPendingIO fSrc;
  61. GrProxyPendingIO fDst;
  62. SkIRect fSrcRect;
  63. SkIPoint fDstPoint;
  64. typedef GrOp INHERITED;
  65. };
  66. #endif