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

Go to the source code of this file.

Functions

 REG_FIDDLE (Canvas_MakeRasterDirect, 256, 256, true, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Canvas_MakeRasterDirect  ,
256  ,
256  ,
true  ,
 
)

Definition at line 5 of file Canvas_MakeRasterDirect.cpp.

5 {
6void draw(SkCanvas*) {
7 SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3); // device aligned, 32 bpp, Premultiplied
8 const size_t minRowBytes = info.minRowBytes(); // bytes used by one bitmap row
9 const size_t size = info.computeMinByteSize(); // bytes used by all rows
10 SkPMColor* pixels = new SkPMColor[size]; // allocate storage for pixels
11 // create a SkCanvas backed by a raster device, and delete it when the
12 // function goes out of scope.
13 std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, pixels, minRowBytes);
14 canvas->clear(SK_ColorWHITE); // white is Unpremultiplied, in ARGB order
15 SkPMColor pmWhite = pixels[0]; // the Premultiplied format may vary
16 SkPaint paint; // by default, draws black
17 canvas->drawPoint(1, 1, paint); // draw in the center
18 for (int y = 0; y < info.height(); ++y) {
19 for (int x = 0; x < info.width(); ++x) {
20 SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
21 }
22 SkDebugf("\n");
23 }
24 delete[] pixels;
25}
26} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
uint32_t SkPMColor
Definition SkColor.h:205
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
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
static std::unique_ptr< SkCanvas > MakeRasterDirect(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr)
const Paint & paint
double y
double x
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
static SkImageInfo MakeN32Premul(int width, int height)