blob: bf4ec6021911d4ec15b3d3f00459bfd66279f50a [file] [log] [blame]
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkBitmapSourceDeserializer.h"
#include "SkBitmap.h"
#include "SkFilterQuality.h"
#include "SkImage.h"
#include "SkImageSource.h"
#include "SkReadBuffer.h"
sk_sp<SkFlattenable> SkBitmapSourceDeserializer::CreateProc(SkReadBuffer& buffer) {
SkFilterQuality filterQuality;
if (buffer.isVersionLT(SkReadBuffer::kBitmapSourceFilterQuality_Version)) {
filterQuality = kHigh_SkFilterQuality;
} else {
filterQuality = (SkFilterQuality)buffer.readInt();
}
SkRect src, dst;
buffer.readRect(&src);
buffer.readRect(&dst);
SkBitmap bitmap;
if (!buffer.readBitmap(&bitmap)) {
return nullptr;
}
bitmap.setImmutable();
return SkImageSource::Make(SkImage::MakeFromBitmap(bitmap), src, dst, filterQuality);
}