Flutter Engine
 
Loading...
Searching...
No Matches
pixel_formats.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
7
8#include "third_party/skia/include/core/SkColorSpace.h"
9#include "third_party/skia/include/core/SkColorType.h"
10#include "third_party/skia/include/core/SkImageInfo.h"
11
12std::optional<SkColorType> getSkColorType(FlutterSoftwarePixelFormat pixfmt) {
13 switch (pixfmt) {
15 return kGray_8_SkColorType;
17 return kRGB_565_SkColorType;
19 return kARGB_4444_SkColorType;
21 return kRGBA_8888_SkColorType;
23 return kRGB_888x_SkColorType;
25 return kBGRA_8888_SkColorType;
27 return kN32_SkColorType;
28 default:
29 FML_LOG(ERROR) << "Invalid software rendering pixel format";
30 return std::nullopt;
31 }
32}
33
34std::optional<SkColorInfo> getSkColorInfo(FlutterSoftwarePixelFormat pixfmt) {
35 auto ct = getSkColorType(pixfmt);
36 if (!ct) {
37 return std::nullopt;
38 }
39
40 auto at = SkColorTypeIsAlwaysOpaque(*ct) ? kOpaque_SkAlphaType
41 : kPremul_SkAlphaType;
42
43 return SkColorInfo(*ct, at, SkColorSpace::MakeSRGB());
44}
FlutterSoftwarePixelFormat
Definition embedder.h:450
@ kFlutterSoftwarePixelFormatRGBA4444
Definition embedder.h:473
@ kFlutterSoftwarePixelFormatRGBA8888
Definition embedder.h:483
@ kFlutterSoftwarePixelFormatBGRA8888
Definition embedder.h:502
@ kFlutterSoftwarePixelFormatGray8
Definition embedder.h:454
@ kFlutterSoftwarePixelFormatNative32
Definition embedder.h:506
@ kFlutterSoftwarePixelFormatRGBX8888
Definition embedder.h:492
@ kFlutterSoftwarePixelFormatRGB565
Definition embedder.h:463
#define FML_LOG(severity)
Definition logging.h:101
std::optional< SkColorType > getSkColorType(FlutterSoftwarePixelFormat pixfmt)
std::optional< SkColorInfo > getSkColorInfo(FlutterSoftwarePixelFormat pixfmt)