Home | History | Annotate | Download | only in ops
      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 
     22     const char* name() const override { return "CopySurface"; }
     23 
     24     void visitProxies(const VisitProxyFunc& func) const override {
     25         func(fSrc.get());
     26     }
     27 
     28     SkString dumpInfo() const override {
     29         SkString string;
     30         string.append(INHERITED::dumpInfo());
     31         string.printf("srcProxyID: %d,\n"
     32                       "srcRect: [ L: %d, T: %d, R: %d, B: %d ], dstPt: [ X: %d, Y: %d ]\n",
     33                       fSrc.get()->uniqueID().asUInt(),
     34                       fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
     35                       fDstPoint.fX, fDstPoint.fY);
     36         return string;
     37     }
     38 
     39 private:
     40     GrCopySurfaceOp(GrSurfaceProxy* dst, GrSurfaceProxy* src,
     41                     const SkIRect& srcRect, const SkIPoint& dstPoint)
     42             : INHERITED(ClassID())
     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 
     52     bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; }
     53 
     54     void onPrepare(GrOpFlushState*) override {}
     55 
     56     void onExecute(GrOpFlushState* state) override;
     57 
     58     GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType>  fSrc;
     59     SkIRect                                              fSrcRect;
     60     SkIPoint                                             fDstPoint;
     61 
     62     typedef GrOp INHERITED;
     63 };
     64 
     65 #endif
     66