aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGpuDevice.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-01-23 12:15:09 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-23 18:12:46 +0000
commit03dd6d5208a6e3d92190e7020300e4399178ae4b (patch)
tree8d062392a5072a50d10f032bbea8502aaa713581 /src/gpu/SkGpuDevice.cpp
parenta6725fcb14f63734d7668bb0550cd9c128e841b0 (diff)
Reland "Refactor trimming logic for read/writePixels()"
Original CL: https://skia-review.googlesource.com/c/7326/ (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. CQ_INCLUDE_TRYBOTS=skia.primary:Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug BUG=skia:6021 Change-Id: I25a964e3c610c4e36d195a255e2150657baec649 Reviewed-on: https://skia-review.googlesource.com/7404 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r--src/gpu/SkGpuDevice.cpp16
1 files changed, 14 insertions, 2 deletions
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) {