| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrCopySurfaceBatch_DEFINED | 8 #ifndef GrCopySurfaceBatch_DEFINED |
| 9 #define GrCopySurfaceBatch_DEFINED | 9 #define GrCopySurfaceBatch_DEFINED |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 static GrBatch* Create(GrSurface* dst, GrSurface* src, const SkIRect& srcRec
t, | 30 static GrBatch* Create(GrSurface* dst, GrSurface* src, const SkIRect& srcRec
t, |
| 31 const SkIPoint& dstPoint); | 31 const SkIPoint& dstPoint); |
| 32 | 32 |
| 33 const char* name() const override { return "CopySurface"; } | 33 const char* name() const override { return "CopySurface"; } |
| 34 | 34 |
| 35 uint32_t renderTargetUniqueID() const override { | 35 uint32_t renderTargetUniqueID() const override { |
| 36 GrRenderTarget* rt = fDst.get()->asRenderTarget(); | 36 GrRenderTarget* rt = fDst.get()->asRenderTarget(); |
| 37 return rt ? rt->getUniqueID() : 0; | 37 return rt ? rt->getUniqueID() : 0; |
| 38 } | 38 } |
| 39 GrRenderTarget* renderTarget() const override { return fDst.get()->asRenderT
arget(); } | 39 GrRenderTarget* renderTarget() const override { return nullptr; } |
| 40 | 40 |
| 41 SkString dumpInfo() const override { | 41 SkString dumpInfo() const override { |
| 42 SkString string; | 42 SkString string; |
| 43 string.printf("SRC: 0x%p, DST: 0x%p, SRECT: [L: %d, T: %d, R: %d, B: %d]
, " | 43 string.printf("SRC: 0x%p, DST: 0x%p, SRECT: [L: %d, T: %d, R: %d, B: %d]
, " |
| 44 "DPT:[X: %d, Y: %d]", | 44 "DPT:[X: %d, Y: %d]", |
| 45 fDst.get(), fSrc.get(), fSrcRect.fLeft, fSrcRect.fTop, fSr
cRect.fRight, | 45 fDst.get(), fSrc.get(), fSrcRect.fLeft, fSrcRect.fTop, fSr
cRect.fRight, |
| 46 fSrcRect.fBottom, fDstPoint.fX, fDstPoint.fY); | 46 fSrcRect.fBottom, fDstPoint.fX, fDstPoint.fY); |
| 47 return string; | 47 return string; |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 GrCopySurfaceBatch(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, | 51 GrCopySurfaceBatch(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, |
| 52 const SkIPoint& dstPoint) | 52 const SkIPoint& dstPoint) |
| 53 : INHERITED(ClassID()) | 53 : INHERITED(ClassID()) |
| 54 , fDst(dst) | 54 , fDst(dst) |
| 55 , fSrc(src) | 55 , fSrc(src) |
| 56 , fSrcRect(srcRect) | 56 , fSrcRect(srcRect) |
| 57 , fDstPoint(dstPoint) { | 57 , fDstPoint(dstPoint) { |
| 58 fBounds = SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dst
Point.fY), | 58 fBounds = SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dst
Point.fY), |
| 59 SkIntToScalar(srcRect.width()), SkIntToScalar
(srcRect.height())); | 59 SkIntToScalar(srcRect.width()), SkIntToScalar
(srcRect.height())); |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool onCombineIfPossible(GrBatch* that, const GrCaps& caps) override { retur
n false; } | 62 bool onCombineIfPossible(GrBatch* that, const GrCaps& caps) override { retur
n false; } |
| 63 | 63 |
| 64 void onPrepare(GrBatchFlushState*) override {} | 64 void onPrepare(GrBatchFlushState*) override {} |
| 65 | 65 |
| 66 void onDraw(GrBatchFlushState* state) override { | 66 void onDraw(GrBatchFlushState* state) override { |
| 67 state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoint); | 67 if (!state->commandBuffer()) { |
| 68 state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoin
t); |
| 69 } else { |
| 70 // currently we are not sending copies through the GrGpuCommandBuffe
r |
| 71 SkASSERT(false); |
| 72 } |
| 68 } | 73 } |
| 69 | 74 |
| 70 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 75 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
| 71 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 76 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
| 72 SkIRect fSrcRect; | 77 SkIRect fSrcRect; |
| 73 SkIPoint fDstPoint; | 78 SkIPoint fDstPoint; |
| 74 | 79 |
| 75 typedef GrBatch INHERITED; | 80 typedef GrBatch INHERITED; |
| 76 }; | 81 }; |
| 77 | 82 |
| 78 #endif | 83 #endif |
| OLD | NEW |