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

Go to the source code of this file.

Functions

 REG_FIDDLE (Color_Type_RGBA_1010102, 256, 96, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Color_Type_RGBA_1010102  ,
256  ,
96  ,
false  ,
 
)

Definition at line 5 of file Color_Type_RGBA_1010102.cpp.

5 {
6void draw(SkCanvas* canvas) {
7 canvas->scale(16, 16);
10 bitmap.allocPixels(imageInfo);
11 SkCanvas offscreen(bitmap);
12 offscreen.clear(SK_ColorGREEN);
13 canvas->drawImage(bitmap.asImage(), 0, 0);
14 auto pack1010102 = [](unsigned r, unsigned g, unsigned b, unsigned a) -> uint32_t {
15 return (r << 0) | (g << 10) | (b << 20) | (a << 30);
16 };
17 uint32_t redBits[] = { pack1010102(0x3FF, 0x000, 0x000, 0x3),
18 pack1010102(0x2ff, 0x000, 0x000, 0x3),
19 pack1010102(0x1ff, 0x000, 0x000, 0x3),
20 pack1010102(0x0ff, 0x000, 0x000, 0x3) };
21 uint32_t blueBits[] = { pack1010102(0x000, 0x000, 0x3FF, 0x3),
22 pack1010102(0x000, 0x000, 0x2ff, 0x3),
23 pack1010102(0x000, 0x000, 0x1ff, 0x3),
24 pack1010102(0x000, 0x000, 0x0ff, 0x3) };
25 if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {
26 canvas->drawImage(bitmap.asImage(), 2, 2);
27 }
28 SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());
29 if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {
30 canvas->drawImage(bitmap.asImage(), 4, 4);
31 }
32}
33} // END FIDDLE
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:27
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
static bool b
struct MyStruct a[10]
size_t minRowBytes() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)