Flutter Engine
The Flutter Engine
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
14#include "include/core/SkData.h"
19#include "tests/Test.h"
20
21#include <memory>
22#include <utility>
23
24DEF_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;
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}
DEF_TEST(Codec_recommendedF16, r)
@ 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