aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPixmap.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-01-14 23:43:24 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-15 00:15:34 +0000
commit7a6c9f7be115031a8a86fdae20e8869fd973fdb6 (patch)
treecfea263ca408161e7b57aee4dd31c26372fbc985 /src/core/SkPixmap.cpp
parent8bbdd49805bd77fec61e6e31f59d31a361e8be30 (diff)
Revert "Add SkImageInfoValidConversion() and SkImageInfoIsValid"
This reverts commit cf5d6caff7a58f1c7ecc36d9a91ccdada5fc7b78. Reason for revert: Chrome DEPS roll failing, based on the unit tests, I suspect this is the cause. Original change's description: > Add SkImageInfoValidConversion() and SkImageInfoIsValid > > The idea is share these standards for the following: > SkImage::readPixels() > SkCanvas::readPixels() > SkCanvas::writePixels() > SkBitmap::readPixels() > SkPixmap::readPixels() > > On the raster side, SkPixmap::readPixels() is the right > place to check, because all raster calls go through > there eventually. Then at lower levels (ex: SkPixelInfo), > we can assert. > > There's not really a unifying location for gpu calls, > so I've added this in multiple places. I haven't really > dug into the gpu code to SkASSERT() on invalid cases > that we will have already caught. > > Follow-up work: > Similar refactor for SkReadPixelRec::trim(). > Code cleanup in SkPixelInfo::CopyPixels() > > BUG=skia:6021 > > Change-Id: I91ecce10e46c1a6530f0af24a9eb8226dbecaaa2 > Reviewed-on: https://skia-review.googlesource.com/6887 > Reviewed-by: Brian Osman <brianosman@google.com> > Reviewed-by: Mike Reed <reed@google.com> > TBR=mtklein@google.com,msarett@google.com,brianosman@google.com,reed@google.com,reviews@skia.org # Not skipping CQ checks because original CL landed > 1 day ago. BUG=skia:6021 Change-Id: I63b88e90bdbb3051a14de00ac73a8351ab776d25 Reviewed-on: https://skia-review.googlesource.com/7095 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/core/SkPixmap.cpp')
-rw-r--r--src/core/SkPixmap.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index 1e24b93a60..3e89af65ed 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -10,7 +10,6 @@
#include "SkColorPriv.h"
#include "SkConfig8888.h"
#include "SkData.h"
-#include "SkImageInfoPriv.h"
#include "SkHalf.h"
#include "SkMask.h"
#include "SkNx.h"
@@ -85,13 +84,15 @@ bool SkPixmap::extractSubset(SkPixmap* result, const SkIRect& subset) const {
bool SkPixmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, size_t dstRB,
int x, int y) const {
- if (!SkImageInfoValidConversion(requestedDstInfo, fInfo)) {
+ if (kUnknown_SkColorType == requestedDstInfo.colorType()) {
return false;
}
-
if (nullptr == dstPixels || dstRB < requestedDstInfo.minRowBytes()) {
return false;
}
+ if (0 == requestedDstInfo.width() || 0 == requestedDstInfo.height()) {
+ return false;
+ }
SkIRect srcR = SkIRect::MakeXYWH(x, y, requestedDstInfo.width(), requestedDstInfo.height());
if (!srcR.intersect(0, 0, this->width(), this->height())) {