blob: 72363f59fe930147a32093c391fc2b985ac8aaaa (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*
* 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 "SkBitmapRegionCodec.h"
#include "SkBitmapRegionDecoder.h"
#include "SkAndroidCodec.h"
#include "SkCodec.h"
#include "SkCodecPriv.h"
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
sk_sp<SkData> data, Strategy strategy) {
return SkBitmapRegionDecoder::Create(new SkMemoryStream(data),
strategy);
}
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
SkStreamRewindable* stream, Strategy strategy) {
std::unique_ptr<SkStreamRewindable> streamDeleter(stream);
switch (strategy) {
case kAndroidCodec_Strategy: {
auto codec = SkAndroidCodec::MakeFromStream(std::move(streamDeleter));
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create codec.\n");
return nullptr;
}
switch ((SkEncodedImageFormat)codec->getEncodedFormat()) {
case SkEncodedImageFormat::kJPEG:
case SkEncodedImageFormat::kPNG:
case SkEncodedImageFormat::kWEBP:
case SkEncodedImageFormat::kHEIF:
break;
default:
return nullptr;
}
return new SkBitmapRegionCodec(codec.release());
}
default:
SkASSERT(false);
return nullptr;
}
}
|