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

Go to the source code of this file.

Functions

 REG_FIDDLE (draw_pixel_array_nocopy, 256, 256, false, 5)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( draw_pixel_array_nocopy  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file draw_pixel_array_nocopy.cpp.

4 {
5constexpr int kWidth = 4;
6constexpr int kHeight = 4;
7static const uint32_t kPixels[kHeight * kWidth] = {
8 0xFF000000, 0xFF005500, 0xFF00AA00, 0xFF00FF00,
9 0xFF000055, 0xFF005555, 0xFF00AA55, 0xFF00FF55,
10 0xFF0000AA, 0xFF0055AA, 0xFF00AAAA, 0xFF00FFAA,
11 0xFF0000FF, 0xFF0055FF, 0xFF00AAFF, 0xFF00FFFF,
12};
13
14void draw(SkCanvas* canvas) {
16 kPixels, sizeof(uint32_t) * kWidth);
17 sk_sp<SkImage> img = SkImages::RasterFromPixmap(pixmap, nullptr, nullptr);
18
19 canvas->scale(16, 16);
20 canvas->drawImage(img, 6, 6);
21}
22} // END FIDDLE
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
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
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
constexpr size_t kHeight
constexpr size_t kWidth