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

Go to the source code of this file.

Functions

 REG_FIDDLE (Pixmap_writable_addr_2, 256, 256, true, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Pixmap_writable_addr_2  ,
256  ,
256  ,
true  ,
 
)

Definition at line 4 of file Pixmap_writable_addr_2.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 const int w = 4;
7 const int h = 4;
8 SkPMColor storage[w * h * 4];
9 SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), storage, w * 4);
10 SkDebugf("pixmap.writable_addr() %c= (void *)storage\n",
11 pixmap.writable_addr() == (void *)storage ? '=' : '!');
12 pixmap.erase(0x00000000);
13 *(SkPMColor*)pixmap.writable_addr(1, 2) = 0xFFFFFFFF;
14 SkDebugf("pixmap.getColor(0, 0) %c= 0x00000000\n",
15 pixmap.getColor(0, 0) == 0x00000000 ? '=' : '!');
16 SkDebugf("pixmap.getColor(1, 2) %c= 0xFFFFFFFF\n",
17 pixmap.getColor(1, 2) == 0xFFFFFFFF ? '=' : '!');
18}
19} // END FIDDLE
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
uint32_t SkPMColor
Definition: SkColor.h:205
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
SkScalar w
SkScalar h
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)