Flutter Engine
The Flutter Engine
third_party
skia
tests
CodecRecommendedTypeTest.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2017 Google Inc.
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/SkAndroidCodec.h
"
9
#include "
include/core/SkAlphaType.h
"
10
#include "
include/core/SkBitmap.h
"
11
#include "
include/core/SkColor.h
"
12
#include "
include/core/SkColorSpace.h
"
13
#include "
include/core/SkColorType.h
"
14
#include "
include/core/SkData.h
"
15
#include "
include/core/SkDataTable.h
"
16
#include "
include/core/SkImageInfo.h
"
17
#include "
include/core/SkStream.h
"
18
#include "
include/encode/SkPngEncoder.h
"
19
#include "
tests/Test.h
"
20
21
#include <memory>
22
#include <utility>
23
24
DEF_TEST
(Codec_recommendedF16, r) {
25
// Encode an F16 bitmap. SkPngEncoder will encode this to a true-color PNG
26
// with a bit depth of 16. SkAndroidCodec should always recommend F16 for
27
// such a PNG.
28
SkBitmap
bm;
29
bm.
allocPixels
(
SkImageInfo::Make
(10, 10,
kRGBA_F16_SkColorType
,
30
kPremul_SkAlphaType
,
SkColorSpace::MakeSRGB
()));
31
// What is drawn is not important.
32
bm.
eraseColor
(
SK_ColorBLUE
);
33
34
SkDynamicMemoryWStream
wstream;
35
REPORTER_ASSERT
(r,
SkPngEncoder::Encode
(&wstream, bm.
pixmap
(), {}));
36
auto
data
= wstream.
detachAsData
();
37
auto
androidCodec =
SkAndroidCodec::MakeFromData
(std::move(
data
));
38
if
(!androidCodec) {
39
ERRORF
(r,
"Failed to create SkAndroidCodec"
);
40
return
;
41
}
42
43
REPORTER_ASSERT
(r, androidCodec->computeOutputColorType(kN32_SkColorType)
44
==
kRGBA_F16_SkColorType
);
45
}
DEF_TEST
DEF_TEST(Codec_recommendedF16, r)
Definition:
CodecRecommendedTypeTest.cpp:24
SkAlphaType.h
kPremul_SkAlphaType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition:
SkAlphaType.h:29
SkAndroidCodec.h
SkBitmap.h
SkColorSpace.h
SkColorType.h
kRGBA_F16_SkColorType
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition:
SkColorType.h:38
SkColor.h
SK_ColorBLUE
constexpr SkColor SK_ColorBLUE
Definition:
SkColor.h:135
SkDataTable.h
SkData.h
SkImageInfo.h
SkPngEncoder.h
SkStream.h
Test.h
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition:
Test.h:286
ERRORF
#define ERRORF(r,...)
Definition:
Test.h:293
SkAndroidCodec::MakeFromData
static std::unique_ptr< SkAndroidCodec > MakeFromData(sk_sp< SkData >, SkPngChunkReader *=nullptr)
Definition:
SkAndroidCodec.cpp:250
SkBitmap
Definition:
SkBitmap.h:59
SkBitmap::allocPixels
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition:
SkBitmap.cpp:258
SkBitmap::pixmap
const SkPixmap & pixmap() const
Definition:
SkBitmap.h:133
SkBitmap::eraseColor
void eraseColor(SkColor4f) const
Definition:
SkBitmap.cpp:442
SkColorSpace::MakeSRGB
static sk_sp< SkColorSpace > MakeSRGB()
Definition:
SkColorSpace.cpp:87
SkDynamicMemoryWStream
Definition:
SkStream.h:455
SkDynamicMemoryWStream::detachAsData
sk_sp< SkData > detachAsData()
Definition:
SkStream.cpp:707
SkPngEncoder::Encode
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
Definition:
SkPngEncoder_none.cpp:20
SkImageInfo::Make
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
Definition:
SkImageInfo.cpp:127
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:37 for Flutter Engine by
1.9.4