Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
ColorTypeValidateAlphaType.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (ColorTypeValidateAlphaType, 256, 640, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( ColorTypeValidateAlphaType  ,
256  ,
640  ,
false  ,
 
)

Definition at line 5 of file ColorTypeValidateAlphaType.cpp.

5 {
6void draw(SkCanvas* canvas) {
7 const char* colors[] = { "Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
8 "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16Norm",
9 "RGBA_F16" };
10 const char* alphas[] = {"Unknown ", "Opaque ", "Premul ", "Unpremul"};
13 };
15 SkFont font(fontMgr->matchFamilyStyle("monospace", SkFontStyle()), 10);
16 int y = 15;
17 canvas->drawString(" colorType alphaType canonical", 10, y, font, paint);
18 for (SkColorType colorType : {
23 } ) {
24 for (SkAlphaType alphaType : alphaTypes) {
25 SkAlphaType canonicalAlphaType = kUnknown_SkAlphaType;
26 bool result = SkColorTypeValidateAlphaType(colorType, alphaType, &canonicalAlphaType);
27 SkString string;
28 string.printf("%13s %10s %10s", colors[(int) colorType], alphas[(int) alphaType],
29 result ? alphas[(int) canonicalAlphaType] : "------ ");
30 canvas->drawString(string, 10, y += 14, font, paint);
31 }
32 }
33}
34} // END FIDDLE
kUnpremul_SkAlphaType
SkAlphaType
Definition SkAlphaType.h:26
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
SkColorType
Definition SkColorType.h:19
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition SkColorType.h:23
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition SkColorType.h:21
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:29
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:25
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:27
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
SK_API bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, SkAlphaType *canonical=nullptr)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition SkCanvas.h:1803
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
const Paint & paint
sk_sp< SkFontMgr > fontMgr
Definition examples.cpp:32
GAsyncResult * result
double y
PODArray< SkColor > colors
Definition SkRecords.h:276
font
Font Metadata and Metrics.