Flutter Engine
The Flutter Engine
Functions
gpu4444diff.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE_SRGB (gpu4444diff, 260, 260, false, 3, 0, false)
 

Function Documentation

◆ REG_FIDDLE_SRGB()

REG_FIDDLE_SRGB ( gpu4444diff  ,
260  ,
260  ,
false  ,
,
,
false   
)

Definition at line 4 of file gpu4444diff.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 canvas->scale(16, 16);
9 bitmap.allocPixels(imageInfo);
10 SkCanvas offscreen(bitmap);
11 offscreen.clear(SK_ColorGREEN);
12 canvas->drawImage(bitmap.asImage(), 0, 0);
13 offscreen.clear(SK_ColorGRAY);
14 canvas->drawImage(bitmap.asImage(), 2, 2);
15 auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t {
16 return (a << 0) | (b << 4) | (g << 8) | (r << 12);
17 };
18 uint16_t red4444[] = { pack4444(0xF, 0xF, 0x0, 0x0), pack4444(0xF, 0xb, 0x0, 0x0),
19 pack4444(0xF, 0x9, 0x0, 0x0), pack4444(0xF, 0x5, 0x0, 0x0) };
20 uint16_t blue4444[] = { pack4444(0xF, 0x0, 0x0, 0x0F), pack4444(0xF, 0x0, 0x0, 0x0b),
21 pack4444(0xF, 0x0, 0x0, 0x09), pack4444(0xF, 0x0, 0x0, 0x05) };
23 SkPixmap redPixmap(imageInfo, &red4444, 4);
24 if (bitmap.writePixels(redPixmap, 0, 0)) {
25 canvas->drawImage(bitmap.asImage(), 4, 4);
26 }
27 SkPixmap bluePixmap(imageInfo, &blue4444, 4);
28 if (bitmap.writePixels(bluePixmap, 0, 0)) {
29 canvas->drawImage(bitmap.asImage(), 6, 6);
30 }
31}
32} // END FIDDLE
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
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)
Definition: SkCanvas.cpp:1289
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static bool b
struct MyStruct a[10]
Definition: bitmap.py:1
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)