From a8046af0b0501e53726c01fa5ec2ec6590c79a82 Mon Sep 17 00:00:00 2001 From: Timothy Liang Date: Thu, 19 Jul 2018 09:58:00 -0400 Subject: implemented onWritePixels and related tests for metal gpu backend Bug: skia: Change-Id: Iab8bc8611a9de8afcf0eaeb58a8ef46fdc38d4f1 Reviewed-on: https://skia-review.googlesource.com/140571 Commit-Queue: Timothy Liang Reviewed-by: Greg Daniel --- src/gpu/mtl/GrMtlGpu.h | 4 +--- src/gpu/mtl/GrMtlGpu.mm | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h index 1c25dedbac..054f1e6842 100644 --- a/src/gpu/mtl/GrMtlGpu.h +++ b/src/gpu/mtl/GrMtlGpu.h @@ -113,9 +113,7 @@ private: void* buffer, size_t rowBytes) override; bool onWritePixels(GrSurface*, int left, int top, int width, int height, GrColorType, - const GrMipLevel[], int) override { - return false; - } + const GrMipLevel[], int mipLevelCount) override; bool onTransferPixels(GrTexture*, int left, int top, int width, int height, diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm index 892e4bc5a1..e4c7c64e5f 100644 --- a/src/gpu/mtl/GrMtlGpu.mm +++ b/src/gpu/mtl/GrMtlGpu.mm @@ -527,6 +527,25 @@ void GrMtlGpu::testingOnly_flushGpuAndSync() { } #endif // GR_TEST_UTILS +bool GrMtlGpu::onWritePixels(GrSurface* surface, int left, int top, int width, int height, + GrColorType srcColorType, const GrMipLevel texels[], + int mipLevelCount) { + GrMtlTexture* mtlTexture = static_cast(surface->asTexture()); + if (!mtlTexture) { + return false; + } + if (!mipLevelCount) { + return false; + } +#ifdef SK_DEBUG + for (int i = 0; i < mipLevelCount; i++) { + SkASSERT(texels[i].fPixels); + } +#endif + return this->uploadToTexture(mtlTexture, left, top, width, height, srcColorType, texels, + mipLevelCount); +} + bool GrMtlGpu::onReadPixels(GrSurface* surface, int left, int top, int width, int height, GrColorType dstColorType, void* buffer, size_t rowBytes) { SkASSERT(surface); -- cgit v1.2.3