Flutter Engine
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). More...
 
SkCanvas * GetSpyingCanvas ()
 The returned canvas delegate all operations to the target canvas while spying on them. More...
 

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 25 of file canvas_spy.h.

Constructor & Destructor Documentation

◆ CanvasSpy()

flutter::CanvasSpy::CanvasSpy ( SkCanvas *  target_canvas)

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 }

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 33 of file canvas_spy.cc.

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

33  {
34  return did_draw_canvas_->DidDrawIntoCanvas();
35 }

◆ GetSpyingCanvas()

SkCanvas * flutter::CanvasSpy::GetSpyingCanvas ( )

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

Definition at line 19 of file canvas_spy.cc.

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

19  {
20  return n_way_canvas_.get();
21 }

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