• 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 "src/gpu/GrOpFlushState.h"
12 #include "src/gpu/ops/GrOp.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)28     void visitProxies(const VisitProxyFunc& func) const override {
29         func(fSrc.get(), GrMipMapped::kNo);
30         func(fDst.get(), GrMipMapped::kNo);
31     }
32 
33 #ifdef SK_DEBUG
dumpInfo()34     SkString dumpInfo() const override {
35         SkString string;
36         string = INHERITED::dumpInfo();
37         string.appendf(
38                 "srcProxyID: %d,\n"
39                 "srcRect: [ L: %d, T: %d, R: %d, B: %d ], dstPt: [ X: %d, Y: %d ]\n",
40                 fSrc.get()->uniqueID().asUInt(), fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight,
41                 fSrcRect.fBottom, fDstPoint.fX, fDstPoint.fY);
42         return string;
43     }
44 #endif
45 
46 private:
47     friend class GrOpMemoryPool; // for ctor
48 
GrCopySurfaceOp(GrSurfaceProxy * src,GrSurfaceProxy * dst,const SkIRect & srcRect,const SkIPoint & dstPoint)49     GrCopySurfaceOp(GrSurfaceProxy* src, GrSurfaceProxy* dst, const SkIRect& srcRect,
50                     const SkIPoint& dstPoint)
51             : INHERITED(ClassID())
52             , fSrc(src)
53             , fDst(dst)
54             , fSrcRect(srcRect)
55             , fDstPoint(dstPoint) {
56         SkRect bounds =
57                 SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
58                                  SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
59         this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
60 
61         SkASSERT(dst->origin() == src->origin());
62         if (kBottomLeft_GrSurfaceOrigin == src->origin()) {
63             int rectHeight = fSrcRect.height();
64             fSrcRect.fTop = src->height() - fSrcRect.fBottom;
65             fSrcRect.fBottom = fSrcRect.fTop + rectHeight;
66             fDstPoint.fY = dst->height() - fDstPoint.fY - rectHeight;
67         }
68 
69     }
70 
onPrepare(GrOpFlushState *)71     void onPrepare(GrOpFlushState*) override {}
72 
73     void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
74 
75     GrProxyPendingIO fSrc;
76     GrProxyPendingIO fDst;
77     SkIRect          fSrcRect;
78     SkIPoint         fDstPoint;
79 
80     typedef GrOp INHERITED;
81 };
82 
83 #endif
84