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