• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 GrCopySurfaceOp final : public GrOp {
15 public:
16     DEFINE_OP_CLASS_ID
17 
18     static std::unique_ptr<GrOp> Make(GrSurfaceProxy* dst, GrSurfaceProxy* src,
19                                       const SkIRect& srcRect,
20                                       const SkIPoint& dstPoint);
21 
name()22     const char* name() const override { return "CopySurface"; }
23 
dumpInfo()24     SkString dumpInfo() const override {
25         SkString string;
26         string.append(INHERITED::dumpInfo());
27         string.printf("srcProxyID: %d, dstProxyID: %d,\n"
28                       "srcRect: [ L: %d, T: %d, R: %d, B: %d ], dstPt: [ X: %d, Y: %d ]\n",
29                       fSrc.get()->uniqueID().asUInt(),
30                       fDst.get()->uniqueID().asUInt(),
31                       fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
32                       fDstPoint.fX, fDstPoint.fY);
33         return string;
34     }
35 
needsCommandBufferIsolation()36     bool needsCommandBufferIsolation() const override { return true; }
37 
38 private:
GrCopySurfaceOp(GrSurfaceProxy * dst,GrSurfaceProxy * src,const SkIRect & srcRect,const SkIPoint & dstPoint)39     GrCopySurfaceOp(GrSurfaceProxy* dst, GrSurfaceProxy* src,
40                     const SkIRect& srcRect, const SkIPoint& dstPoint)
41             : INHERITED(ClassID())
42             , fDst(dst)
43             , fSrc(src)
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     }
51 
onCombineIfPossible(GrOp * that,const GrCaps & caps)52     bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; }
53 
onPrepare(GrOpFlushState *)54     void onPrepare(GrOpFlushState*) override {}
55 
56     void onExecute(GrOpFlushState* state) override;
57 
58     // For RenderTargetContexts 'fDst' is redundant with the RenderTarget that will be passed
59     // into onExecute in the drawOpArgs.
60     GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fDst;
61     GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType>  fSrc;
62     SkIRect                                              fSrcRect;
63     SkIPoint                                             fDstPoint;
64 
65     typedef GrOp INHERITED;
66 };
67 
68 #endif
69