OLD | NEW |
(Empty) | |
| 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 GrCopySurfaceBatch_DEFINED |
| 9 #define GrCopySurfaceBatch_DEFINED |
| 10 |
| 11 #include "GrBatch.h" |
| 12 #include "GrBatchFlushState.h" |
| 13 #include "GrGpu.h" |
| 14 #include "GrRenderTarget.h" |
| 15 |
| 16 class GrCopySurfaceBatch final : public GrBatch { |
| 17 public: |
| 18 static GrBatch* Create(GrSurface* dst, GrSurface* src, const SkIRect& srcRec
t, |
| 19 const SkIPoint& dstPoint); |
| 20 |
| 21 const char* name() const override { return "CopySurface"; } |
| 22 |
| 23 uint32_t renderTargetUniqueID() const override { |
| 24 GrRenderTarget* rt = fDst.get()->asRenderTarget(); |
| 25 return rt ? rt->getUniqueID() : 0; |
| 26 } |
| 27 |
| 28 SkString dumpInfo() const override { |
| 29 SkString string; |
| 30 string.printf("SRC: 0x%p, DST: 0x%p, SRECT: [L: %d, T: %d, R: %d, B: %d]
, " |
| 31 "DPT:[X: %d, Y: %d]", |
| 32 fDst.get(), fSrc.get(), fSrcRect.fLeft, fSrcRect.fTop, fSr
cRect.fRight, |
| 33 fSrcRect.fBottom, fDstPoint.fX, fDstPoint.fY); |
| 34 return string; |
| 35 } |
| 36 |
| 37 private: |
| 38 GrCopySurfaceBatch(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, |
| 39 const SkIPoint& dstPoint) |
| 40 : fDst(dst) |
| 41 , fSrc(src) |
| 42 , fSrcRect(srcRect) |
| 43 , fDstPoint(dstPoint) { |
| 44 this->initClassID<GrCopySurfaceBatch>(); |
| 45 fBounds = SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dst
Point.fY), |
| 46 SkIntToScalar(srcRect.width()), SkIntToScalar
(srcRect.height())); |
| 47 } |
| 48 |
| 49 bool onCombineIfPossible(GrBatch* that, const GrCaps& caps) override { retur
n false; } |
| 50 |
| 51 void onPrepare(GrBatchFlushState*) override {} |
| 52 |
| 53 void onDraw(GrBatchFlushState* state) override { |
| 54 state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoint); |
| 55 } |
| 56 |
| 57 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
| 58 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
| 59 SkIRect fSrcRect; |
| 60 SkIPoint fDstPoint; |
| 61 }; |
| 62 |
| 63 #endif |
OLD | NEW |