blob: b93cbb79c2fc274db64e72a8e7173d16381ef789 [file] [log] [blame]
bsalomon872062c2015-08-18 12:12:35 -07001/*
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
Brian Salomon7dae46a2016-12-14 16:21:37 -05008#ifndef GrCopySurfaceOp_DEFINED
9#define GrCopySurfaceOp_DEFINED
bsalomon872062c2015-08-18 12:12:35 -070010
Brian Salomon25a88092016-12-01 09:36:50 -050011#include "GrOp.h"
Brian Salomon742e31d2016-12-07 17:06:19 -050012#include "GrOpFlushState.h"
bsalomon872062c2015-08-18 12:12:35 -070013
Brian Salomon7dae46a2016-12-14 16:21:37 -050014class GrCopySurfaceOp final : public GrOp {
bsalomon872062c2015-08-18 12:12:35 -070015public:
Brian Salomon25a88092016-12-01 09:36:50 -050016 DEFINE_OP_CLASS_ID
reed1b55a962015-09-17 20:16:13 -070017
Robert Phillips7c525e62018-06-12 10:11:12 -040018 static std::unique_ptr<GrOp> Make(GrContext*,
19 GrSurfaceProxy* dst,
20 GrSurfaceProxy* src,
Robert Phillipsbf25d432017-04-07 10:08:53 -040021 const SkIRect& srcRect,
Brian Salomonf8334782017-01-03 09:42:58 -050022 const SkIPoint& dstPoint);
bsalomon872062c2015-08-18 12:12:35 -070023
24 const char* name() const override { return "CopySurface"; }
25
Robert Phillipsf1748f52017-09-14 14:11:24 -040026 void visitProxies(const VisitProxyFunc& func) const override {
Robert Phillips9d6c64f2017-09-14 10:56:45 -040027 func(fSrc.get());
28 }
29
bsalomon872062c2015-08-18 12:12:35 -070030 SkString dumpInfo() const override {
31 SkString string;
Robert Phillipsf5442bb2017-04-17 14:18:34 -040032 string.append(INHERITED::dumpInfo());
Robert Phillips47c315e2017-11-08 16:26:53 -050033 string.printf("srcProxyID: %d,\n"
Robert Phillipsa16f6cb2017-06-01 11:06:13 -040034 "srcRect: [ L: %d, T: %d, R: %d, B: %d ], dstPt: [ X: %d, Y: %d ]\n",
35 fSrc.get()->uniqueID().asUInt(),
Robert Phillipsbf25d432017-04-07 10:08:53 -040036 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
37 fDstPoint.fX, fDstPoint.fY);
bsalomon872062c2015-08-18 12:12:35 -070038 return string;
39 }
40
41private:
Robert Phillips7c525e62018-06-12 10:11:12 -040042 friend class GrOpMemoryPool; // for ctor
43
Robert Phillipsa16f6cb2017-06-01 11:06:13 -040044 GrCopySurfaceOp(GrSurfaceProxy* dst, GrSurfaceProxy* src,
Robert Phillipsbf25d432017-04-07 10:08:53 -040045 const SkIRect& srcRect, const SkIPoint& dstPoint)
46 : INHERITED(ClassID())
Robert Phillipsbf25d432017-04-07 10:08:53 -040047 , fSrc(src)
48 , fSrcRect(srcRect)
49 , fDstPoint(dstPoint) {
bsalomon88cf17d2016-07-08 06:40:56 -070050 SkRect bounds =
51 SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
52 SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
53 this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
bsalomon872062c2015-08-18 12:12:35 -070054 }
55
Brian Salomon742e31d2016-12-07 17:06:19 -050056 void onPrepare(GrOpFlushState*) override {}
bsalomon872062c2015-08-18 12:12:35 -070057
Robert Phillips646e4292017-06-13 12:44:56 -040058 void onExecute(GrOpFlushState* state) override;
bsalomon872062c2015-08-18 12:12:35 -070059
Robert Phillipsa16f6cb2017-06-01 11:06:13 -040060 GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fSrc;
61 SkIRect fSrcRect;
62 SkIPoint fDstPoint;
reed1b55a962015-09-17 20:16:13 -070063
Brian Salomon25a88092016-12-01 09:36:50 -050064 typedef GrOp INHERITED;
bsalomon872062c2015-08-18 12:12:35 -070065};
66
67#endif