diff options
author | Mike Reed <reed@google.com> | 2017-11-30 16:14:34 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-30 21:43:08 +0000 |
commit | efe7c4920194796e997bff5bdb94e6fade6cb367 (patch) | |
tree | ce58f4d9d5c6b199008460dd5cb574bed208ebec /src/core/SkBitmap.cpp | |
parent | 8a90c4da1cc7998927ce8f282b28baaf976a3873 (diff) |
remove read/write rawpixels
Bug: skia:
Change-Id: I000b70414119355fef0d45de4ae9ef996b8a5568
Reviewed-on: https://skia-review.googlesource.com/77903
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r-- | src/core/SkBitmap.cpp | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 2b505fd80d..603bdf3141 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -620,99 +620,6 @@ bool SkBitmap::extractAlpha(SkBitmap* dst, const SkPaint* paint, /////////////////////////////////////////////////////////////////////////////// -static void write_raw_pixels(SkWriteBuffer* buffer, const SkPixmap& pmap) { - const SkImageInfo& info = pmap.info(); - const size_t snugRB = info.width() * info.bytesPerPixel(); - const char* src = (const char*)pmap.addr(); - const size_t ramRB = pmap.rowBytes(); - - buffer->write32(SkToU32(snugRB)); - info.flatten(*buffer); - - const size_t size = snugRB * info.height(); - SkAutoTMalloc<char> storage(size); - char* dst = storage.get(); - for (int y = 0; y < info.height(); ++y) { - memcpy(dst, src, snugRB); - dst += snugRB; - src += ramRB; - } - buffer->writeByteArray(storage.get(), size); - // no colortable - buffer->writeBool(false); -} - -void SkBitmap::WriteRawPixels(SkWriteBuffer* buffer, const SkBitmap& bitmap) { - const SkImageInfo info = bitmap.info(); - if (0 == info.width() || 0 == info.height() || bitmap.isNull()) { - buffer->writeUInt(0); // instead of snugRB, signaling no pixels - return; - } - - SkPixmap result; - if (!bitmap.peekPixels(&result)) { - buffer->writeUInt(0); // instead of snugRB, signaling no pixels - return; - } - - write_raw_pixels(buffer, result); -} - -bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) { - if (0 == buffer->readUInt()) { - return false; // no pixels - } - - SkImageInfo info; - info.unflatten(*buffer); - - if (info.width() < 0 || info.height() < 0) { - return false; - } - - // If there was an error reading "info" or if it is bogus, - // don't use it to compute minRowBytes(). - if (!buffer->validate(SkColorTypeValidateAlphaType(info.colorType(), - info.alphaType()))) { - return false; - } - - // write_raw_pixels() always writes snug buffers with rowBytes == minRowBytes(). - size_t bytes = info.computeMinByteSize(); - if (!buffer->validate(bytes != 0)) { - return false; - } - - sk_sp<SkData> data(SkData::MakeUninitialized(bytes)); - unsigned char* dst = (unsigned char*)data->writable_data(); - if (!buffer->readByteArray(dst, bytes)) { - return false; - } - - if (buffer->readBool()) { - SkColorTable::Skip(*buffer); - if (!buffer->isValid()) { - return false; - } - } - - sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeWithData(info, info.minRowBytes(), - std::move(data)); - if (!pr) { - return false; - } - bitmap->setInfo(info); - bitmap->setPixelRef(std::move(pr), 0, 0); - return true; -} - -enum { - SERIALIZE_PIXELTYPE_NONE, - SERIALIZE_PIXELTYPE_REF_DATA -}; - -/////////////////////////////////////////////////////////////////////////////// - #ifdef SK_DEBUG void SkBitmap::validate() const { fInfo.validate(); |