From 977f64cbfad1ecd7fd4b1231c694c7e828fda1f0 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Fri, 20 Jan 2017 16:59:02 -0500 Subject: Refactor trimming logic for read/writePixels() (1) Move trimming logic into Bitmap/Pixmap level for raster. Everything goes through here, so we'll only do the work once. (2) This means it also goes to GPU level. (3) Always use SkReadPixelsRec rather than inlining the logic. (4) Create an SkWritePixelsRec to encapsulate write trimming. (5) Disabled kIndex8 as a dst - always. BUG=skia:6021 Change-Id: I748f50c3b726f7c6de5462e2b1ccb54bc387a510 Reviewed-on: https://skia-review.googlesource.com/7326 Reviewed-by: Mike Reed Commit-Queue: Matt Sarett --- src/gpu/SkGpuDevice.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/gpu') diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 85eb671206..c5ade9e7b1 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -35,6 +35,7 @@ #include "SkPictureData.h" #include "SkRRect.h" #include "SkRasterClip.h" +#include "SkReadPixelsRec.h" #include "SkRecord.h" #include "SkSpecialImage.h" #include "SkStroke.h" @@ -43,6 +44,7 @@ #include "SkTLazy.h" #include "SkUtils.h" #include "SkVertState.h" +#include "SkWritePixelsRec.h" #include "effects/GrBicubicEffect.h" #include "effects/GrSimpleTextureEffect.h" #include "effects/GrTextureDomain.h" @@ -199,7 +201,12 @@ bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size return false; } - return fRenderTargetContext->readPixels(dstInfo, dstPixels, dstRowBytes, x, y); + SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, x, y); + if (!rec.trim(this->width(), this->height())) { + return false; + } + + return fRenderTargetContext->readPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY); } bool SkGpuDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixels, @@ -210,7 +217,12 @@ bool SkGpuDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixel return false; } - return fRenderTargetContext->writePixels(srcInfo, srcPixels, srcRowBytes, x, y); + SkWritePixelsRec rec(srcInfo, srcPixels, srcRowBytes, x, y); + if (!rec.trim(this->width(), this->height())) { + return false; + } + + return fRenderTargetContext->writePixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY); } bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) { -- cgit v1.2.3