Line data Source code
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 0 : class GrCopySurfaceOp final : public GrOp {
15 : public:
16 0 : DEFINE_OP_CLASS_ID
17 :
18 : // MDB TODO: remove the resourceProvider parameter
19 : static std::unique_ptr<GrOp> Make(GrResourceProvider*,
20 : GrSurfaceProxy* dst, GrSurfaceProxy* src,
21 : const SkIRect& srcRect,
22 : const SkIPoint& dstPoint);
23 :
24 0 : const char* name() const override { return "CopySurface"; }
25 :
26 0 : SkString dumpInfo() const override {
27 0 : SkString string;
28 0 : string.printf("src: (proxyID: %d, rtID: %d), dst: (proxyID: %d, rtID: %d), "
29 : "srcRect: [L: %d, T: %d, R: %d, B: %d], dstPt: [X: %d, Y: %d]",
30 0 : fSrcProxyID.asUInt(), fSrc.get()->uniqueID().asUInt(),
31 0 : fDstProxyID.asUInt(), fDst.get()->uniqueID().asUInt(),
32 0 : fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
33 0 : fDstPoint.fX, fDstPoint.fY);
34 0 : string.append(INHERITED::dumpInfo());
35 0 : return string;
36 : }
37 :
38 : private:
39 0 : GrCopySurfaceOp(GrSurface* dst, GrSurface* src,
40 : GrSurfaceProxy::UniqueID dstID, GrSurfaceProxy::UniqueID srcID,
41 : const SkIRect& srcRect, const SkIPoint& dstPoint)
42 0 : : INHERITED(ClassID())
43 : , fDstProxyID(dstID)
44 : , fSrcProxyID(srcID)
45 : , fDst(dst)
46 : , fSrc(src)
47 : , fSrcRect(srcRect)
48 0 : , fDstPoint(dstPoint) {
49 : SkRect bounds =
50 0 : SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
51 0 : SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
52 0 : this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
53 0 : }
54 :
55 0 : bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; }
56 :
57 0 : void onPrepare(GrOpFlushState*) override {}
58 :
59 0 : void onExecute(GrOpFlushState* state) override {
60 0 : if (!state->commandBuffer()) {
61 0 : state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoint);
62 : } else {
63 : // Currently we are not sending copies through the GrGpuCommandBuffer. See comment in
64 : // renderTargetUniqueID().
65 0 : SkASSERT(false);
66 : }
67 0 : }
68 :
69 : // MDB TODO: remove the proxy IDs once the GrSurfaceProxy carries the ref since they will
70 : // be redundant
71 : GrSurfaceProxy::UniqueID fDstProxyID;
72 : GrSurfaceProxy::UniqueID fSrcProxyID;
73 : GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst;
74 : GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
75 : SkIRect fSrcRect;
76 : SkIPoint fDstPoint;
77 :
78 : typedef GrOp INHERITED;
79 : };
80 :
81 : #endif
|