Flutter Engine
The Flutter Engine
Classes | Typedefs | Functions
rasterhandleallocator.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkRasterHandleAllocator.h"
#include "include/core/SkSurface.h"
#include "include/private/base/SkMalloc.h"

Go to the source code of this file.

Classes

class  GraphicsPort
 
class  SkiaGraphicsPort
 
class  SkiaAllocator
 

Typedefs

using MyPort = SkiaGraphicsPort
 
using MyAllocator = SkiaAllocator
 

Functions

 DEF_SIMPLE_GM (rasterallocator, canvas, 600, 300)
 

Typedef Documentation

◆ MyAllocator

Definition at line 272 of file rasterhandleallocator.cpp.

◆ MyPort

Definition at line 271 of file rasterhandleallocator.cpp.

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( rasterallocator  ,
canvas  ,
600  ,
300   
)

Definition at line 276 of file rasterhandleallocator.cpp.

276 {
277 auto doDraw = [](GraphicsPort* port) {
278 SkAutoCanvasRestore acr(port->peekCanvas(), true);
279
280 port->drawRect({0, 0, 256, 256}, SK_ColorRED);
281 port->save();
282 port->translate(30, 30);
283 port->drawRect({0, 0, 30, 30}, SK_ColorBLUE);
284 port->drawOval({10, 10, 20, 20}, SK_ColorWHITE);
285 port->restore();
286
287 port->saveLayer({50, 50, 100, 100}, 0x80);
288 port->drawRect({55, 55, 95, 95}, SK_ColorGREEN);
289 port->restore();
290
291 port->clip({150, 50, 200, 200});
292 port->drawRect({0, 0, 256, 256}, 0xFFCCCCCC);
293 };
294
295 // TODO: this common code fails pic-8888 and serialize-8888
296 //GraphicsPort skiaPort(canvas);
297 //doDraw(&skiaPort);
298
300 std::unique_ptr<SkCanvas> nativeCanvas =
301 SkRasterHandleAllocator::MakeCanvas(std::make_unique<MyAllocator>(), info);
302 MyPort nativePort(nativeCanvas.get());
303 doDraw(&nativePort);
304
305 SkPixmap pm;
306 nativeCanvas->peekPixels(&pm);
307 canvas->drawImage(SkImages::RasterFromPixmapCopy(pm), 280, 0);
308}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static std::unique_ptr< SkCanvas > MakeCanvas(std::unique_ptr< SkRasterHandleAllocator >, const SkImageInfo &, const Rec *rec=nullptr, const SkSurfaceProps *props=nullptr)
Definition: SkCanvas.cpp:2871
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
Definition: switches.h:87
static SkImageInfo MakeN32Premul(int width, int height)