skia2/include/core/SkAlphaType.h
Kevin Lubick 27be14f2ca [includes] Prepare to remove SkColor<->SkImageInfo
This breaks out the SkAlphaType and SkColorType enums into
their own files, which lets us break the dependency between
SkColor and SkImageInfo.

It does not yet sever the link, but we plan to land this
so as to migrate clients to the new enum files if necessary.

This is estimated to save Chrome 230 MB of build size [1]
(about 0.1%) http://screen/4dMqPC9rvAyCk6y

[1] https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes_2022-03-08_182556.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkColor%5C.h%24&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkColor%5C.h%24&included=&limit=1000

Change-Id: I331d414fe2996632ab11825c1092060ff5fe2ebd
Bug: 242216
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/517678
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-09 18:40:44 +00:00

46 lines
1.7 KiB
C

/*
* Copyright 2022 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkAlphaType_DEFINED
#define SkAlphaType_DEFINED
/** \enum SkAlphaType
Describes how to interpret the alpha component of a pixel. A pixel may
be opaque, or alpha, describing multiple levels of transparency.
In simple blending, alpha weights the draw color and the destination
color to create a new color. If alpha describes a weight from zero to one:
new color = draw color * alpha + destination color * (1 - alpha)
In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
RGB may have alpha included in each component value; the stored
value is the original RGB multiplied by alpha. Premultiplied color
components improve performance.
*/
enum SkAlphaType : int {
kUnknown_SkAlphaType, //!< uninitialized
kOpaque_SkAlphaType, //!< pixel is opaque
kPremul_SkAlphaType, //!< pixel components are premultiplied by alpha
kUnpremul_SkAlphaType, //!< pixel components are independent of alpha
kLastEnum_SkAlphaType = kUnpremul_SkAlphaType, //!< last valid value
};
/** Returns true if SkAlphaType equals kOpaque_SkAlphaType.
kOpaque_SkAlphaType is a hint that the SkColorType is opaque, or that all
alpha values are set to their 1.0 equivalent. If SkAlphaType is
kOpaque_SkAlphaType, and SkColorType is not opaque, then the result of
drawing any pixel with a alpha value less than 1.0 is undefined.
*/
static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
return kOpaque_SkAlphaType == at;
}
#endif