diff options
Diffstat (limited to 'src/core/SkBitmapDevice.cpp')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 76 |
1 files changed, 2 insertions, 74 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 0f3cc2be5..1dfc3a6c0 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -155,59 +155,8 @@ void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { return NULL; } -static void rect_memcpy(void* dst, size_t dstRB, const void* src, size_t srcRB, size_t bytesPerRow, - int rowCount) { - SkASSERT(bytesPerRow <= srcRB); - SkASSERT(bytesPerRow <= dstRB); - for (int i = 0; i < rowCount; ++i) { - memcpy(dst, src, bytesPerRow); - dst = (char*)dst + dstRB; - src = (const char*)src + srcRB; - } -} - #include "SkConfig8888.h" -static bool copy_pixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, - const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes) { - if (srcInfo.dimensions() != dstInfo.dimensions()) { - return false; - } - if (4 == srcInfo.bytesPerPixel() && 4 == dstInfo.bytesPerPixel()) { - SkDstPixelInfo dstPI; - dstPI.fColorType = dstInfo.colorType(); - dstPI.fAlphaType = dstInfo.alphaType(); - dstPI.fPixels = dstPixels; - dstPI.fRowBytes = dstRowBytes; - - SkSrcPixelInfo srcPI; - srcPI.fColorType = srcInfo.colorType(); - srcPI.fAlphaType = srcInfo.alphaType(); - srcPI.fPixels = srcPixels; - srcPI.fRowBytes = srcRowBytes; - - return srcPI.convertPixelsTo(&dstPI, srcInfo.width(), srcInfo.height()); - } - if (srcInfo.colorType() == dstInfo.colorType()) { - switch (srcInfo.colorType()) { - case kRGB_565_SkColorType: - case kAlpha_8_SkColorType: - break; - case kARGB_4444_SkColorType: - if (srcInfo.alphaType() != dstInfo.alphaType()) { - return false; - } - break; - default: - return false; - } - rect_memcpy(dstPixels, dstRowBytes, srcPixels, srcRowBytes, - srcInfo.width() * srcInfo.bytesPerPixel(), srcInfo.height()); - } - // TODO: add support for more conversions as needed - return false; -} - bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes, int x, int y) { // since we don't stop creating un-pixeled devices yet, check for no pixels here @@ -222,7 +171,7 @@ bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi void* dstPixels = fBitmap.getAddr(x, y); size_t dstRowBytes = fBitmap.rowBytes(); - if (copy_pixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPixels, srcRowBytes)) { + if (SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPixels, srcRowBytes)) { fBitmap.notifyPixelsChanged(); return true; } @@ -231,28 +180,7 @@ bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int x, int y) { - // since we don't stop creating un-pixeled devices yet, check for no pixels here - if (NULL == fBitmap.getPixels()) { - return false; - } - - SkImageInfo srcInfo = fBitmap.info(); - - // perhaps can relax these in the future - if (4 != dstInfo.bytesPerPixel()) { - return false; - } - if (4 != srcInfo.bytesPerPixel()) { - return false; - } - - srcInfo.fWidth = dstInfo.width(); - srcInfo.fHeight = dstInfo.height(); - - const void* srcPixels = fBitmap.getAddr(x, y); - const size_t srcRowBytes = fBitmap.rowBytes(); - - return copy_pixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPixels, srcRowBytes); + return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); } /////////////////////////////////////////////////////////////////////////////// |