Chromium Code Reviews| Index: src/utils/SkBitmapTransformer.cpp |
| =================================================================== |
| --- src/utils/SkBitmapTransformer.cpp (revision 8685) |
| +++ src/utils/SkBitmapTransformer.cpp (working copy) |
| @@ -85,3 +85,30 @@ |
| fBitmap.unlockPixels(); |
| return true; |
| } |
| + |
| +bool SkBitmapTransformer::copyRowToPixelBuffer(int row, void *dstBuffer, |
| + size_t dstBufferSize) const { |
| + if (!this->isValid(true)) { |
| + return false; |
| + } |
| + if ((row < 0) || (row >= this->numRows())) { |
| + // EPOGER: add unit test for this check |
| + SkDEBUGF(("row %d must be within range [0,%d]\n", row, numRows()-1)); |
| + return false; |
| + } |
| + size_t bytesNeeded = this->bytesNeededPerRow(); |
| + if (dstBufferSize < bytesNeeded) { |
| + SkDEBUGF(("dstBufferSize %d must be >= %d\n", dstBufferSize, bytesNeeded)); |
| + return false; |
| + } |
| + |
| + fBitmap.lockPixels(); |
|
bungeman-skia
2013/04/22 05:14:02
This isn't cheap as it involves taking a mutex, as
|
| + int width = fBitmap.width(); |
| + size_t srcRowBytes = fBitmap.rowBytes(); |
| + const char *srcBytes = const_cast<const char *>(static_cast<char*>(fBitmap.getPixels())); |
| + char *dstBytes = static_cast<char *>(dstBuffer); |
| + srcBytes += srcRowBytes * row; |
| + transform_scanline(srcBytes, width, dstBytes); |
| + fBitmap.unlockPixels(); |
| + return true; |
| +} |