diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 13f03e0bf4..e28a989d94 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -458,7 +458,7 @@ bool GrGpu::writePixels(GrSurface* surface, int left, int top, int width, int he bool GrGpu::transferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) { + sk_sp transferBuffer, size_t offset, size_t rowBytes) { TRACE_EVENT0("skia.gpu", TRACE_FUNC); SkASSERT(texture); SkASSERT(transferBuffer); @@ -490,7 +490,7 @@ bool GrGpu::transferPixelsTo(GrTexture* texture, int left, int top, int width, i this->handleDirtyContext(); if (this->onTransferPixelsTo(texture, left, top, width, height, textureColorType, - bufferColorType, transferBuffer, offset, rowBytes)) { + bufferColorType, std::move(transferBuffer), offset, rowBytes)) { SkIRect rect = SkIRect::MakeXYWH(left, top, width, height); this->didWriteToSurface(texture, kTopLeft_GrSurfaceOrigin, &rect); fStats.incTransfersToTexture(); @@ -502,7 +502,7 @@ bool GrGpu::transferPixelsTo(GrTexture* texture, int left, int top, int width, i bool GrGpu::transferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) { + sk_sp transferBuffer, size_t offset) { TRACE_EVENT0("skia.gpu", TRACE_FUNC); SkASSERT(surface); SkASSERT(transferBuffer); @@ -524,7 +524,7 @@ bool GrGpu::transferPixelsFrom(GrSurface* surface, int left, int top, int width, this->handleDirtyContext(); if (this->onTransferPixelsFrom(surface, left, top, width, height, surfaceColorType, - bufferColorType, transferBuffer, offset)) { + bufferColorType, std::move(transferBuffer), offset)) { fStats.incTransfersFromSurface(); return true; } diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 9d328ef061..2cfc3971c0 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -302,7 +302,7 @@ public: */ bool transferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes); + sk_sp transferBuffer, size_t offset, size_t rowBytes); /** * Reads the pixels from a rectangle of a surface into a buffer. Use @@ -327,7 +327,7 @@ public: */ bool transferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset); + sk_sp transferBuffer, size_t offset); // Called to perform a surface to surface copy. Fallbacks to issuing a draw from the src to dst // take place at higher levels and this function implement faster copy paths. The rect @@ -849,12 +849,13 @@ private: // overridden by backend-specific derived class to perform the texture transfer virtual bool onTransferPixelsTo(GrTexture*, int left, int top, int width, int height, GrColorType textiueColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, + sk_sp transferBuffer, size_t offset, size_t rowBytes) = 0; // overridden by backend-specific derived class to perform the surface transfer virtual bool onTransferPixelsFrom(GrSurface*, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) = 0; + sk_sp transferBuffer, + size_t offset) = 0; // overridden by backend-specific derived class to perform the resolve virtual void onResolveRenderTarget(GrRenderTarget* target, const SkIRect& resolveRect) = 0; diff --git a/src/gpu/GrTransferFromRenderTask.cpp b/src/gpu/GrTransferFromRenderTask.cpp index 7826bceca9..4c1d848799 100644 --- a/src/gpu/GrTransferFromRenderTask.cpp +++ b/src/gpu/GrTransferFromRenderTask.cpp @@ -26,5 +26,5 @@ bool GrTransferFromRenderTask::onExecute(GrOpFlushState* flushState) { } return flushState->gpu()->transferPixelsFrom( fSrcProxy->peekSurface(), fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.width(), - fSrcRect.height(), fSurfaceColorType, fDstColorType, fDstBuffer.get(), fDstOffset); + fSrcRect.height(), fSurfaceColorType, fDstColorType, fDstBuffer, fDstOffset); } diff --git a/src/gpu/d3d/GrD3DGpu.h b/src/gpu/d3d/GrD3DGpu.h index 52a18084d2..2640c72398 100644 --- a/src/gpu/d3d/GrD3DGpu.h +++ b/src/gpu/d3d/GrD3DGpu.h @@ -176,12 +176,13 @@ private: bool onTransferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) override { + sk_sp transferBuffer, size_t offset, + size_t rowBytes) override { return true; } bool onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) override { + sk_sp transferBuffer, size_t offset) override { return true; } bool onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, diff --git a/src/gpu/dawn/GrDawnGpu.cpp b/src/gpu/dawn/GrDawnGpu.cpp index e8006d9beb..4f5b6073ba 100644 --- a/src/gpu/dawn/GrDawnGpu.cpp +++ b/src/gpu/dawn/GrDawnGpu.cpp @@ -189,7 +189,7 @@ bool GrDawnGpu::onWritePixels(GrSurface* surface, int left, int top, int width, bool GrDawnGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t bufferOffset, + sk_sp transferBuffer, size_t bufferOffset, size_t rowBytes) { SkASSERT(!"unimplemented"); return false; @@ -197,7 +197,7 @@ bool GrDawnGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int wi bool GrDawnGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) { + sk_sp transferBuffer, size_t offset) { SkASSERT(!"unimplemented"); return false; } diff --git a/src/gpu/dawn/GrDawnGpu.h b/src/gpu/dawn/GrDawnGpu.h index ce9c3e7fbd..cf3feed801 100644 --- a/src/gpu/dawn/GrDawnGpu.h +++ b/src/gpu/dawn/GrDawnGpu.h @@ -172,11 +172,12 @@ private: bool onTransferPixelsTo(GrTexture*, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) override; + sk_sp transferBuffer, size_t offset, + size_t rowBytes) override; bool onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) override; + sk_sp transferBuffer, size_t offset) override; void onResolveRenderTarget(GrRenderTarget*, const SkIRect&) override {} diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index d692d41f54..146b5cc8ca 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -835,7 +835,8 @@ bool GrGLGpu::onWritePixels(GrSurface* surface, int left, int top, int width, in bool GrGLGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) { + sk_sp transferBuffer, size_t offset, + size_t rowBytes) { GrGLTexture* glTex = static_cast(texture); // Can't transfer compressed data @@ -854,7 +855,7 @@ bool GrGLGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int widt SkASSERT(!transferBuffer->isMapped()); SkASSERT(!transferBuffer->isCpuBuffer()); - const GrGLBuffer* glBuffer = static_cast(transferBuffer); + const GrGLBuffer* glBuffer = static_cast(transferBuffer.get()); this->bindBuffer(GrGpuBufferType::kXferCpuToGpu, glBuffer); SkDEBUGCODE( @@ -906,8 +907,8 @@ bool GrGLGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int widt bool GrGLGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType dstColorType, - GrGpuBuffer* transferBuffer, size_t offset) { - auto* glBuffer = static_cast(transferBuffer); + sk_sp transferBuffer, size_t offset) { + auto* glBuffer = static_cast(transferBuffer.get()); this->bindBuffer(GrGpuBufferType::kXferGpuToCpu, glBuffer); auto offsetAsPtr = reinterpret_cast(offset); return this->readOrTransferPixelsFrom(surface, left, top, width, height, surfaceColorType, diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 5db2a61d3b..3b9405d311 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -303,10 +303,11 @@ private: bool onTransferPixelsTo(GrTexture*, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) override; + sk_sp transferBuffer, size_t offset, + size_t rowBytes) override; bool onTransferPixelsFrom(GrSurface*, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) override; + sk_sp transferBuffer, size_t offset) override; bool readOrTransferPixelsFrom(GrSurface*, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType dstColorType, void* offsetOrPtr, int rowWidthInPixels); diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h index cd9de08716..366c3177c0 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -104,12 +104,13 @@ private: bool onTransferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) override { + sk_sp transferBuffer, size_t offset, + size_t rowBytes) override { return true; } bool onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) override { + sk_sp transferBuffer, size_t offset) override { return true; } bool onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h index 994c78a6e0..a8366d59ba 100644 --- a/src/gpu/mtl/GrMtlGpu.h +++ b/src/gpu/mtl/GrMtlGpu.h @@ -190,11 +190,11 @@ private: bool prepForTexSampling) override; bool onTransferPixelsTo(GrTexture*, int left, int top, int width, int height, - GrColorType textureColorType, GrColorType bufferColorType, GrGpuBuffer*, - size_t offset, size_t rowBytes) override; + GrColorType textureColorType, GrColorType bufferColorType, + sk_sp, size_t offset, size_t rowBytes) override; bool onTransferPixelsFrom(GrSurface*, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer*, size_t offset) override; + sk_sp, size_t offset) override; bool onRegenerateMipMapLevels(GrTexture*) override; diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm index ef80f118db..1e14b0bba3 100644 --- a/src/gpu/mtl/GrMtlGpu.mm +++ b/src/gpu/mtl/GrMtlGpu.mm @@ -1259,7 +1259,8 @@ bool GrMtlGpu::onReadPixels(GrSurface* surface, int left, int top, int width, in bool GrMtlGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) { + sk_sp transferBuffer, size_t offset, + size_t rowBytes) { SkASSERT(texture); SkASSERT(transferBuffer); if (textureColorType != bufferColorType) { @@ -1270,7 +1271,7 @@ bool GrMtlGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int wid id mtlTexture = grMtlTexture->mtlTexture(); SkASSERT(mtlTexture); - GrMtlBuffer* grMtlBuffer = static_cast(transferBuffer); + GrMtlBuffer* grMtlBuffer = static_cast(transferBuffer.get()); id mtlBuffer = grMtlBuffer->mtlBuffer(); SkASSERT(mtlBuffer); @@ -1300,7 +1301,7 @@ bool GrMtlGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int wid bool GrMtlGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) { + sk_sp transferBuffer, size_t offset) { SkASSERT(surface); SkASSERT(transferBuffer); @@ -1317,7 +1318,7 @@ bool GrMtlGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int w return false; } - GrMtlBuffer* grMtlBuffer = static_cast(transferBuffer); + GrMtlBuffer* grMtlBuffer = static_cast(transferBuffer.get()); size_t transBufferRowBytes = bpp * width; size_t transBufferImageBytes = transBufferRowBytes * height; diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 1efd472fda..b58b1fc837 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -473,7 +473,7 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, int left, int top, int width, in bool GrVkGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t bufferOffset, + sk_sp transferBuffer, size_t bufferOffset, size_t rowBytes) { if (!this->currentCommandBuffer()) { return false; @@ -499,7 +499,7 @@ bool GrVkGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int widt // Can't transfer compressed data SkASSERT(!GrVkFormatIsCompressed(vkTex->imageFormat())); - GrVkTransferBuffer* vkBuffer = static_cast(transferBuffer); + GrVkTransferBuffer* vkBuffer = static_cast(transferBuffer.get()); if (!vkBuffer) { return false; } @@ -541,7 +541,7 @@ bool GrVkGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int widt bool GrVkGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) { + sk_sp transferBuffer, size_t offset) { if (!this->currentCommandBuffer()) { return false; } @@ -554,7 +554,7 @@ bool GrVkGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int wi return false; } - GrVkTransferBuffer* vkBuffer = static_cast(transferBuffer); + GrVkTransferBuffer* vkBuffer = static_cast(transferBuffer.get()); GrVkImage* srcImage; if (GrVkRenderTarget* rt = static_cast(surface->asRenderTarget())) { diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index 030c8c503c..313f6a51da 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -270,10 +270,11 @@ private: bool onTransferPixelsTo(GrTexture*, int left, int top, int width, int height, GrColorType textureColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) override; + sk_sp transferBuffer, size_t offset, + size_t rowBytes) override; bool onTransferPixelsFrom(GrSurface* surface, int left, int top, int width, int height, GrColorType surfaceColorType, GrColorType bufferColorType, - GrGpuBuffer* transferBuffer, size_t offset) override; + sk_sp transferBuffer, size_t offset) override; bool onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override; diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp index d6751d17bb..f89eba8750 100644 --- a/tests/TransferPixelsTest.cpp +++ b/tests/TransferPixelsTest.cpp @@ -168,7 +168,7 @@ void basic_transfer_to_test(skiatest::Reporter* reporter, bool result; result = gpu->transferPixelsTo(tex.get(), 0, 0, kTexDims.fWidth, kTexDims.fHeight, colorType, - allowedSrc.fColorType, buffer.get(), 0, srcRowBytes); + allowedSrc.fColorType, buffer, 0, srcRowBytes); REPORTER_ASSERT(reporter, result); size_t dstRowBytes = GrColorTypeBytesPerPixel(colorType) * kTexDims.fWidth; @@ -227,10 +227,10 @@ void basic_transfer_to_test(skiatest::Reporter* reporter, buffer->unmap(); result = gpu->transferPixelsTo(tex.get(), left, top, width, height, colorType, - allowedSrc.fColorType, buffer.get(), offset, srcRowBytes); + allowedSrc.fColorType, buffer, offset, srcRowBytes); if (!result) { gpu->transferPixelsTo(tex.get(), left, top, width, height, colorType, allowedSrc.fColorType, - buffer.get(), offset, srcRowBytes); + buffer, offset, srcRowBytes); ERRORF(reporter, "Could not transfer pixels to texture, color type: %d", static_cast(colorType)); return; @@ -327,7 +327,7 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C ////////////////////////// // transfer full data bool result = gpu->transferPixelsFrom(tex.get(), 0, 0, kTexDims.fWidth, kTexDims.fHeight, - colorType, allowedRead.fColorType, buffer.get(), 0); + colorType, allowedRead.fColorType, buffer, 0); if (!result) { ERRORF(reporter, "transferPixelsFrom failed."); return; @@ -368,7 +368,7 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C // Now test a partial read at an offset into the buffer. result = gpu->transferPixelsFrom(tex.get(), kPartialLeft, kPartialTop, kPartialWidth, kPartialHeight, colorType, allowedRead.fColorType, - buffer.get(), partialReadOffset); + buffer, partialReadOffset); if (!result) { ERRORF(reporter, "transferPixelsFrom failed."); return;