Flutter Engine
The Flutter Engine
Canvas_MakeRasterDirect.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(Canvas_MakeRasterDirect, 256, 256, true, 0) {
5void draw(SkCanvas*) {
6 SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3); // device aligned, 32 bpp, Premultiplied
7 const size_t minRowBytes = info.minRowBytes(); // bytes used by one bitmap row
8 const size_t size = info.computeMinByteSize(); // bytes used by all rows
9 SkPMColor* pixels = new SkPMColor[size]; // allocate storage for pixels
10 // create a SkCanvas backed by a raster device, and delete it when the
11 // function goes out of scope.
12 std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, pixels, minRowBytes);
13 canvas->clear(SK_ColorWHITE); // white is Unpremultiplied, in ARGB order
14 SkPMColor pmWhite = pixels[0]; // the Premultiplied format may vary
15 SkPaint paint; // by default, draws black
16 canvas->drawPoint(1, 1, paint); // draw in the center
17 for (int y = 0; y < info.height(); ++y) {
18 for (int x = 0; x < info.width(); ++x) {
19 SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
20 }
21 SkDebugf("\n");
22 }
23 delete[] pixels;
24}
25} // END FIDDLE
REG_FIDDLE(Canvas_MakeRasterDirect, 256, 256, true, 0)
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)
Definition: SkCanvas.cpp:2801
const Paint & paint
Definition: color_source.cc:38
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)