Flutter Engine
The Flutter Engine
third_party
skia
src
codec
SkImageGenerator_FromEncoded.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2023 Google LLC
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#include "
include/codec/SkCodec.h
"
9
#include "
include/core/SkAlphaType.h
"
10
#include "
include/core/SkData.h
"
11
#include "
include/core/SkGraphics.h
"
12
#include "
include/core/SkImage.h
"
13
#include "
include/core/SkImageGenerator.h
"
14
#include "
include/core/SkRefCnt.h
"
15
#include "
include/core/SkTypes.h
"
16
#include "
src/codec/SkCodecImageGenerator.h
"
17
#include "
src/image/SkImageGeneratorPriv.h
"
18
19
#include <memory>
20
#include <optional>
21
#include <utility>
22
23
static
SkGraphics::ImageGeneratorFromEncodedDataFactory
gFactory
;
24
25
SkGraphics::ImageGeneratorFromEncodedDataFactory
26
SkGraphics::SetImageGeneratorFromEncodedDataFactory
(ImageGeneratorFromEncodedDataFactory factory)
27
{
28
ImageGeneratorFromEncodedDataFactory
prev
=
gFactory
;
29
gFactory
= factory;
30
return
prev
;
31
}
32
33
namespace
SkImageGenerators
{
34
35
std::unique_ptr<SkImageGenerator>
MakeFromEncoded
(
sk_sp<SkData>
data
,
36
std::optional<SkAlphaType> at) {
37
if
(!
data
|| at ==
kOpaque_SkAlphaType
) {
38
return
nullptr
;
39
}
40
if
(
gFactory
) {
41
if
(std::unique_ptr<SkImageGenerator> generator =
gFactory
(
data
)) {
42
return
generator;
43
}
44
}
45
return
SkCodecImageGenerator::MakeFromEncodedCodec
(std::move(
data
), at);
46
}
47
48
}
// namespace SkImageGenerators
49
50
namespace
SkImages
{
51
52
sk_sp<SkImage>
DeferredFromEncodedData
(
sk_sp<SkData>
encoded,
53
std::optional<SkAlphaType> alphaType) {
54
if
(
nullptr
== encoded || encoded->
isEmpty
()) {
55
return
nullptr
;
56
}
57
return
DeferredFromGenerator
(
SkImageGenerators::MakeFromEncoded
(std::move(encoded), alphaType));
58
}
59
60
}
// namespace SkImages
61
62
namespace
SkCodecs
{
63
64
sk_sp<SkImage>
DeferredImage
(std::unique_ptr<SkCodec> codec, std::optional<SkAlphaType> alphaType) {
65
return
SkImages::DeferredFromGenerator
(
66
SkCodecImageGenerator::MakeFromCodec
(std::move(codec), alphaType));
67
}
68
69
}
// namespace SkCodecs
prev
static float prev(float f)
Definition:
PathOpsAngleTest.cpp:40
SkAlphaType.h
kOpaque_SkAlphaType
@ kOpaque_SkAlphaType
pixel is opaque
Definition:
SkAlphaType.h:28
SkCodecImageGenerator.h
SkCodec.h
SkData.h
SkGraphics.h
SkImageGeneratorPriv.h
SkImageGenerator.h
gFactory
static SkGraphics::ImageGeneratorFromEncodedDataFactory gFactory
Definition:
SkImageGenerator_FromEncoded.cpp:23
SkImage.h
SkRefCnt.h
SkTypes.h
SkCodecImageGenerator::MakeFromEncodedCodec
static std::unique_ptr< SkImageGenerator > MakeFromEncodedCodec(sk_sp< SkData >, std::optional< SkAlphaType >=std::nullopt)
Definition:
SkCodecImageGenerator.cpp:21
SkCodecImageGenerator::MakeFromCodec
static std::unique_ptr< SkImageGenerator > MakeFromCodec(std::unique_ptr< SkCodec >, std::optional< SkAlphaType >=std::nullopt)
Definition:
SkCodecImageGenerator.cpp:31
SkData::isEmpty
bool isEmpty() const
Definition:
SkData.h:32
SkGraphics::ImageGeneratorFromEncodedDataFactory
std::unique_ptr< SkImageGenerator >(* ImageGeneratorFromEncodedDataFactory)(sk_sp< SkData >)
Definition:
SkGraphics.h:144
SkGraphics::SetImageGeneratorFromEncodedDataFactory
static ImageGeneratorFromEncodedDataFactory SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory)
Definition:
SkImageGenerator_FromEncoded.cpp:26
sk_sp< SkData >
SkCodecs
Definition:
SkCodec.h:51
SkCodecs::DeferredImage
SK_API sk_sp< SkImage > DeferredImage(std::unique_ptr< SkCodec > codec, std::optional< SkAlphaType > alphaType=std::nullopt)
Definition:
SkImageGenerator_FromEncoded.cpp:64
SkImageGenerators
Definition:
SkImageGenerator_FromEncoded.cpp:33
SkImageGenerators::MakeFromEncoded
std::unique_ptr< SkImageGenerator > MakeFromEncoded(sk_sp< SkData > data, std::optional< SkAlphaType > at)
Definition:
SkImageGenerator_FromEncoded.cpp:35
SkImages
Definition:
SkImageAndroid.h:20
SkImages::DeferredFromEncodedData
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
Definition:
SkImageGenerator_FromEncoded.cpp:52
SkImages::DeferredFromGenerator
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
Definition:
SkImage_Lazy.cpp:282
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:09 for Flutter Engine by
1.9.4