Flutter Engine
The Flutter Engine
Functions
CodecRecommendedTypeTest.cpp File Reference
#include "include/codec/SkAndroidCodec.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkDataTable.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkStream.h"
#include "include/encode/SkPngEncoder.h"
#include "tests/Test.h"
#include <memory>
#include <utility>

Go to the source code of this file.

Functions

 DEF_TEST (Codec_recommendedF16, r)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( Codec_recommendedF16  ,
 
)

Definition at line 24 of file CodecRecommendedTypeTest.cpp.

24 {
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;
31 // What is drawn is not important.
33
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)
45}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
#define ERRORF(r,...)
Definition: Test.h:293
static std::unique_ptr< SkAndroidCodec > MakeFromData(sk_sp< SkData >, SkPngChunkReader *=nullptr)
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
const SkPixmap & pixmap() const
Definition: SkBitmap.h:133
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkData > detachAsData()
Definition: SkStream.cpp:707
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63