Flutter Engine
 
Loading...
Searching...
No Matches
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.
 
SkCanvas * GetRawSpyingCanvas ()
 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}
void set_canvas(SkCanvas *canvas)

References flutter::DlSkCanvasAdapter::set_canvas().

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}

Referenced by flutter::testing::TEST(), and flutter::testing::TEST().

◆ 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};

Referenced by flutter::testing::TEST().

◆ 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}

Referenced by flutter::testing::TEST().


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