aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkBitmapSourceDeserializer.cpp
blob: 1f8cc1c7bd8cea31b7e740c8949f3c6fd77952f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * 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);
    sk_sp<SkImage> image = buffer.readBitmapAsImage();
    if (image) {
        return SkImageSource::Make(std::move(image), src, dst, filterQuality);
    }
    return nullptr;
}