aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-11-30 16:14:34 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-30 21:43:08 +0000
commitefe7c4920194796e997bff5bdb94e6fade6cb367 (patch)
treece58f4d9d5c6b199008460dd5cb574bed208ebec /src
parent8a90c4da1cc7998927ce8f282b28baaf976a3873 (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')
-rw-r--r--src/core/SkBitmap.cpp93
-rw-r--r--src/core/SkReadBuffer.cpp10
-rw-r--r--src/core/SkWriteBuffer.cpp8
3 files changed, 3 insertions, 108 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();
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 318785b479..628e3af062 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -242,13 +242,9 @@ sk_sp<SkImage> SkReadBuffer::readImage() {
return MakeEmptyImage(width, height);
}
if (encoded_size == 1) {
- // We had to encode the image as raw pixels via SkBitmap.
- (void)this->readUInt(); // Swallow that encoded_size == 1 sentinel.
- SkBitmap bm;
- if (SkBitmap::ReadRawPixels(this, &bm)) {
- return SkImage::MakeFromBitmap(bm);
- }
- return MakeEmptyImage(width, height);
+ // legacy check (we stopped writing this for "raw" images Nov-2017)
+ this->validate(false);
+ return nullptr;
}
// The SkImage encoded itself.
diff --git a/src/core/SkWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp
index 45f3ccaedd..e6620f9e83 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -151,14 +151,6 @@ void SkBinaryWriteBuffer::writeImage(const SkImage* image) {
write_encoded_bitmap(this, encoded.get(), SkIPoint::Make(0, 0));
return;
}
-
- SkBitmap bm;
- if (image->asLegacyBitmap(&bm, SkImage::kRO_LegacyBitmapMode)) {
- this->writeUInt(1); // signal raw pixels.
- SkBitmap::WriteRawPixels(this, bm);
- return;
- }
-
this->writeUInt(0); // signal no pixels (in place of the size of the encoded data)
}