Flutter Engine
The Flutter Engine
dl_op_spy.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_COMMON_DL_OP_SPY_H_
6#define FLUTTER_SHELL_COMMON_DL_OP_SPY_H_
7
8#include "flutter/display_list/dl_op_receiver.h"
9#include "flutter/display_list/utils/dl_receiver_utils.h"
10
11namespace flutter {
12
13//------------------------------------------------------------------------------
14/// Receives to drawing commands of a DisplayListBuilder.
15///
16/// This is used to determine whether any non-transparent pixels will be drawn
17/// on the canvas.
18/// All the drawImage operations are considered drawing non-transparent pixels.
19///
20/// To use this class, dispatch the operations from DisplayList to a concrete
21/// DlOpSpy object, and check the result of `did_draw` method.
22///
23/// ```
24/// DlOpSpy dl_op_spy;
25/// display_list.Dispatch(dl_op_spy);
26/// bool did_draw = dl_op_spy.did_draw()
27/// ```
28///
29class DlOpSpy final : public virtual DlOpReceiver,
33 public:
34 //----------------------------------------------------------------------------
35 /// @brief Returns true if any non transparent content has been drawn.
36 bool did_draw();
37
38 private:
39 void setColor(DlColor color) override;
40 void setColorSource(const DlColorSource* source) override;
41 void save() override;
42 void saveLayer(const SkRect& bounds,
44 const DlImageFilter* backdrop) override;
45 void restore() override;
46 void drawColor(DlColor color, DlBlendMode mode) override;
47 void drawPaint() override;
48 void drawLine(const SkPoint& p0, const SkPoint& p1) override;
49 void drawDashedLine(const DlPoint& p0,
50 const DlPoint& p1,
51 DlScalar on_length,
52 DlScalar off_length) override;
53 void drawRect(const SkRect& rect) override;
54 void drawOval(const SkRect& bounds) override;
55 void drawCircle(const SkPoint& center, SkScalar radius) override;
56 void drawRRect(const SkRRect& rrect) override;
57 void drawDRRect(const SkRRect& outer, const SkRRect& inner) override;
58 void drawPath(const SkPath& path) override;
59 void drawArc(const SkRect& oval_bounds,
60 SkScalar start_degrees,
61 SkScalar sweep_degrees,
62 bool use_center) override;
63 void drawPoints(PointMode mode,
64 uint32_t count,
65 const SkPoint points[]) override;
66 void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
67 void drawImage(const sk_sp<DlImage> image,
68 const SkPoint point,
70 bool render_with_attributes) override;
71 void drawImageRect(
73 const SkRect& src,
74 const SkRect& dst,
76 bool render_with_attributes,
77 SrcRectConstraint constraint = SrcRectConstraint::kFast) override;
78 void drawImageNine(const sk_sp<DlImage> image,
79 const SkIRect& center,
80 const SkRect& dst,
81 DlFilterMode filter,
82 bool render_with_attributes) override;
83 void drawAtlas(const sk_sp<DlImage> atlas,
84 const SkRSXform xform[],
85 const SkRect tex[],
86 const DlColor colors[],
87 int count,
90 const SkRect* cull_rect,
91 bool render_with_attributes) override;
92 void drawDisplayList(const sk_sp<DisplayList> display_list,
93 SkScalar opacity = SK_Scalar1) override;
94 void drawTextBlob(const sk_sp<SkTextBlob> blob,
95 SkScalar x,
96 SkScalar y) override;
97 void drawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
98 SkScalar x,
99 SkScalar y) override;
100 void drawShadow(const SkPath& path,
101 const DlColor color,
102 const SkScalar elevation,
103 bool transparent_occluder,
104 SkScalar dpr) override;
105
106 // Indicates if the attributes are set to values that will modify the
107 // destination. For now, the test only checks if there is a non-transparent
108 // color set.
109 bool will_draw_ = true;
110
111 bool did_draw_ = false;
112};
113
114} // namespace flutter
115
116#endif // FLUTTER_SHELL_COMMON_DL_OP_SPY_H_
const char * options
int count
Definition: FontMgrTest.cpp:50
static const int points[]
#define SK_Scalar1
Definition: SkScalar.h:18
Definition: SkPath.h:59
Internal API for rendering recorded display lists to backends.
bool did_draw()
Returns true if any non transparent content has been drawn.
Definition: dl_op_spy.cc:9
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
Definition: dl_vertices.h:71
DlColor color
SkBitmap source
Definition: examples.cpp:28
float SkScalar
Definition: extension.cpp:12
double y
double x
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337
impeller::Scalar DlScalar
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
Definition: switches.h:57
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 mode
Definition: switches.h:228
dst
Definition: cp.py:12
Definition: SkRect.h:32