Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::CanvasSpy Class Reference

#include <canvas_spy.h>

Public Member Functions

 CanvasSpy (SkCanvas *target_canvas)
 
bool DidDrawIntoCanvas ()
 Returns true if any non transparent content has been drawn into the spying canvas. Note that this class does tries to detect empty canvases but in some cases may return true even for empty canvases (e.g when a transparent image is drawn into the canvas).
 
DlCanvasGetSpyingCanvas ()
 The returned canvas delegate all operations to the target canvas while spying on them.
 
SkCanvasGetRawSpyingCanvas ()
 The underlying Skia canvas that implements the spying (mainly for testing)
 

Detailed Description

Facilitates spying on drawing commands to an SkCanvas.

This is used to determine whether anything was drawn into a canvas so it is possible to implement optimizations that are specific to empty canvases.

Definition at line 26 of file canvas_spy.h.

Constructor & Destructor Documentation

◆ CanvasSpy()

flutter::CanvasSpy::CanvasSpy ( SkCanvas target_canvas)
explicit

Definition at line 9 of file canvas_spy.cc.

9 {
10 SkISize canvas_size = target_canvas->getBaseLayerSize();
11 n_way_canvas_ =
12 std::make_unique<SkNWayCanvas>(canvas_size.width(), canvas_size.height());
13 did_draw_canvas_ = std::make_unique<DidDrawCanvas>(canvas_size.width(),
14 canvas_size.height());
15 n_way_canvas_->addCanvas(target_canvas);
16 n_way_canvas_->addCanvas(did_draw_canvas_.get());
17 adapter_.set_canvas(n_way_canvas_.get());
18}
virtual SkISize getBaseLayerSize() const
Definition SkCanvas.cpp:373
void set_canvas(SkCanvas *canvas)
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

Member Function Documentation

◆ DidDrawIntoCanvas()

bool flutter::CanvasSpy::DidDrawIntoCanvas ( )

Returns true if any non transparent content has been drawn into the spying canvas. Note that this class does tries to detect empty canvases but in some cases may return true even for empty canvases (e.g when a transparent image is drawn into the canvas).

Definition at line 38 of file canvas_spy.cc.

38 {
39 return did_draw_canvas_->DidDrawIntoCanvas();
40}

◆ GetRawSpyingCanvas()

SkCanvas * flutter::CanvasSpy::GetRawSpyingCanvas ( )

The underlying Skia canvas that implements the spying (mainly for testing)

Definition at line 24 of file canvas_spy.cc.

24 {
25 return n_way_canvas_.get();
26};

◆ GetSpyingCanvas()

DlCanvas * flutter::CanvasSpy::GetSpyingCanvas ( )

The returned canvas delegate all operations to the target canvas while spying on them.

Definition at line 20 of file canvas_spy.cc.

20 {
21 return &adapter_;
22}

The documentation for this class was generated from the following files: