diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-25 16:02:36 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-25 16:02:36 +0000 |
commit | 0ba4bf427acbd7707d04192a98c77ef194a0f25a (patch) | |
tree | 3f34f47095997ace5136a2bfdbf40281624d86bc /src | |
parent | 9447103029273a9f8dd7f5997e8af7a1e3ee7488 (diff) |
Use size_t for rowBytes.
Previously, we were using uint32_t sometimes, int sometimes, and
size_t sometimes. Switch to using size_t, since we are actually
talking about a number of bytes.
In copyPixelsTo, use 0 as a flag to use the internal rowBytes,
which is more consistent with setConfig.
Review URL: https://codereview.appspot.com/7370047
git-svn-id: http://skia.googlecode.com/svn/trunk@7843 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmap.cpp | 16 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 718a3fd365..7db65271bd 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -181,7 +181,7 @@ int SkBitmap::ComputeBytesPerPixel(SkBitmap::Config config) { return bpp; } -int SkBitmap::ComputeRowBytes(Config c, int width) { +size_t SkBitmap::ComputeRowBytes(Config c, int width) { if (width < 0) { return 0; } @@ -232,7 +232,7 @@ size_t SkBitmap::ComputeSize(Config c, int width, int height) { Sk64 SkBitmap::ComputeSafeSize64(Config config, uint32_t width, uint32_t height, - uint32_t rowBytes) { + size_t rowBytes) { Sk64 safeSize; safeSize.setZero(); if (height > 0) { @@ -248,7 +248,7 @@ Sk64 SkBitmap::ComputeSafeSize64(Config config, size_t SkBitmap::ComputeSafeSize(Config config, uint32_t width, uint32_t height, - uint32_t rowBytes) { + size_t rowBytes) { Sk64 safeSize = ComputeSafeSize64(config, width, height, rowBytes); return (safeSize.is32() ? safeSize.get32() : 0); } @@ -266,10 +266,10 @@ void SkBitmap::getBounds(SkIRect* bounds) const { /////////////////////////////////////////////////////////////////////////////// -void SkBitmap::setConfig(Config c, int width, int height, int rowBytes) { +void SkBitmap::setConfig(Config c, int width, int height, size_t rowBytes) { this->freePixels(); - if ((width | height | rowBytes) < 0) { + if ((width | height) < 0) { goto err; } @@ -465,11 +465,11 @@ Sk64 SkBitmap::getSafeSize64() const { } bool SkBitmap::copyPixelsTo(void* const dst, size_t dstSize, - int dstRowBytes, bool preserveDstPad) const { + size_t dstRowBytes, bool preserveDstPad) const { - if (dstRowBytes == -1) + if (0 == dstRowBytes) { dstRowBytes = fRowBytes; - SkASSERT(dstRowBytes >= 0); + } if (getConfig() == kRLE_Index8_Config || dstRowBytes < ComputeRowBytes(getConfig(), fWidth) || diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index b10cf153a1..d76a34a1cf 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -39,7 +39,7 @@ static void build_compressed_data(void* buffer, const SkBitmap& bitmap) { // always skip a full 256 number of entries, even if we memcpy'd fewer dst += kGrColorTableSize; - if (bitmap.width() == bitmap.rowBytes()) { + if ((unsigned)bitmap.width() == bitmap.rowBytes()) { memcpy(dst, bitmap.getPixels(), bitmap.getSize()); } else { // need to trim off the extra bytes per row |