Flutter Engine
The Flutter Engine
Pixmap_writable_addr.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(Pixmap_writable_addr, 256, 256, true, 0) {
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() = 0xFFFFFFFF;
14 SkDebugf("pixmap.getColor(0, 1) %c= 0x00000000\n",
15 pixmap.getColor(0, 1) == 0x00000000 ? '=' : '!');
16 SkDebugf("pixmap.getColor(0, 0) %c= 0xFFFFFFFF\n",
17 pixmap.getColor(0, 0) == 0xFFFFFFFF ? '=' : '!');
18}
19} // END FIDDLE
REG_FIDDLE(Pixmap_writable_addr, 256, 256, true, 0)
@ 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
SkColor getColor(int x, int y) const
Definition: SkPixmap.cpp:187
bool erase(SkColor color, const SkIRect &subset) const
Definition: SkPixmap.cpp:742
void * writable_addr() const
Definition: SkPixmap.h:483
SkScalar w
SkScalar h
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)