Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/core/SkRecordDraw.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2014 Google Inc.
3
 *
4
 * Use of this source code is governed by a BSD-style license that can be
5
 * found in the LICENSE file.
6
 */
7
8
#include "include/core/SkBBHFactory.h"
9
#include "include/core/SkImage.h"
10
#include "src/core/SkCanvasPriv.h"
11
#include "src/core/SkColorFilterBase.h"
12
#include "src/core/SkImageFilter_Base.h"
13
#include "src/core/SkRecordDraw.h"
14
#include "src/utils/SkPatchUtils.h"
15
16
void SkRecordDraw(const SkRecord& record,
17
                  SkCanvas* canvas,
18
                  SkPicture const* const drawablePicts[],
19
                  SkDrawable* const drawables[],
20
                  int drawableCount,
21
                  const SkBBoxHierarchy* bbh,
22
14.6k
                  SkPicture::AbortCallback* callback) {
23
14.6k
    SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
24
25
14.6k
    if (bbh) {
26
        // Draw only ops that affect pixels in the canvas's current clip.
27
        // The SkRecord and BBH were recorded in identity space.  This canvas
28
        // is not necessarily in that same space.  getLocalClipBounds() returns us
29
        // this canvas' clip bounds transformed back into identity space, which
30
        // lets us query the BBH.
31
0
        SkRect query = canvas->getLocalClipBounds();
32
33
0
        std::vector<int> ops;
34
0
        bbh->search(query, &ops);
35
36
0
        SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount);
37
0
        for (int i = 0; i < (int)ops.size(); i++) {
38
0
            if (callback && callback->abort()) {
39
0
                return;
40
0
            }
41
            // This visit call uses the SkRecords::Draw::operator() to call
42
            // methods on the |canvas|, wrapped by methods defined with the
43
            // DRAW() macro.
44
0
            record.visit(ops[i], draw);
45
0
        }
46
14.6k
    } else {
47
        // Draw all ops.
48
14.6k
        SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount);
49
521k
        for (int i = 0; i < record.count(); i++) {
50
506k
            if (callback && callback->abort()) {
51
0
                return;
52
0
            }
53
            // This visit call uses the SkRecords::Draw::operator() to call
54
            // methods on the |canvas|, wrapped by methods defined with the
55
            // DRAW() macro.
56
506k
            record.visit(i, draw);
57
506k
        }
58
14.6k
    }
59
14.6k
}
60
61
void SkRecordPartialDraw(const SkRecord& record, SkCanvas* canvas,
62
                         SkPicture const* const drawablePicts[], int drawableCount,
63
                         int start, int stop,
64
0
                         const SkM44& initialCTM) {
65
0
    SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
66
67
0
    stop = std::min(stop, record.count());
68
0
    SkRecords::Draw draw(canvas, drawablePicts, nullptr, drawableCount, &initialCTM);
69
0
    for (int i = start; i < stop; i++) {
70
0
        record.visit(i, draw);
71
0
    }
72
0
}
73
74
namespace SkRecords {
75
76
// NoOps draw nothing.
77
0
template <> void Draw::draw(const NoOp&) {}
78
79
509k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::Flush>(SkRecords::Flush const&)
Line
Count
Source
79
207k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::Restore>(SkRecords::Restore const&)
Line
Count
Source
79
65.5k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::Save>(SkRecords::Save const&)
Line
Count
Source
79
21.2k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::SaveLayer>(SkRecords::SaveLayer const&)
Line
Count
Source
79
44.2k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::MarkCTM>(SkRecords::MarkCTM const&)
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::SetMatrix>(SkRecords::SetMatrix const&)
void SkRecords::Draw::draw<SkRecords::SetM44>(SkRecords::SetM44 const&)
Line
Count
Source
79
1.73k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::Concat44>(SkRecords::Concat44 const&)
Line
Count
Source
79
11.0k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::Concat>(SkRecords::Concat const&)
void SkRecords::Draw::draw<SkRecords::Translate>(SkRecords::Translate const&)
Line
Count
Source
79
836
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::Scale>(SkRecords::Scale const&)
Line
Count
Source
79
1.07k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::ClipPath>(SkRecords::ClipPath const&)
Line
Count
Source
79
3.90k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::ClipRRect>(SkRecords::ClipRRect const&)
Line
Count
Source
79
1.85k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::ClipRect>(SkRecords::ClipRect const&)
Line
Count
Source
79
10.7k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::ClipRegion>(SkRecords::ClipRegion const&)
Line
Count
Source
79
3.93k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::ClipShader>(SkRecords::ClipShader const&)
void SkRecords::Draw::draw<SkRecords::DrawArc>(SkRecords::DrawArc const&)
Line
Count
Source
79
82
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawDRRect>(SkRecords::DrawDRRect const&)
Line
Count
Source
79
470
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawImage>(SkRecords::DrawImage const&)
Line
Count
Source
79
4.98k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawImageRect>(SkRecords::DrawImageRect const&)
Line
Count
Source
79
135
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawOval>(SkRecords::DrawOval const&)
Line
Count
Source
79
1.09k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawPaint>(SkRecords::DrawPaint const&)
Line
Count
Source
79
1.27k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawPath>(SkRecords::DrawPath const&)
Line
Count
Source
79
7.27k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawPatch>(SkRecords::DrawPatch const&)
Line
Count
Source
79
96.7k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawPicture>(SkRecords::DrawPicture const&)
Line
Count
Source
79
5.13k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawPoints>(SkRecords::DrawPoints const&)
Line
Count
Source
79
1.37k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawRRect>(SkRecords::DrawRRect const&)
Line
Count
Source
79
1.85k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawRect>(SkRecords::DrawRect const&)
Line
Count
Source
79
3.60k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawRegion>(SkRecords::DrawRegion const&)
Line
Count
Source
79
165
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
void SkRecords::Draw::draw<SkRecords::DrawTextBlob>(SkRecords::DrawTextBlob const&)
Line
Count
Source
79
11.8k
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::DrawAtlas>(SkRecords::DrawAtlas const&)
void SkRecords::Draw::draw<SkRecords::DrawVertices>(SkRecords::DrawVertices const&)
Line
Count
Source
79
310
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::DrawShadowRec>(SkRecords::DrawShadowRec const&)
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::DrawAnnotation>(SkRecords::DrawAnnotation const&)
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::DrawEdgeAAQuad>(SkRecords::DrawEdgeAAQuad const&)
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::DrawEdgeAAImageSet>(SkRecords::DrawEdgeAAImageSet const&)
80
DRAW(Flush, flush());
81
DRAW(Restore, restore());
82
DRAW(Save, save());
83
DRAW(SaveLayer, saveLayer(SkCanvas::SaveLayerRec(r.bounds,
84
                                                 r.paint,
85
                                                 r.backdrop.get(),
86
                                                 r.saveLayerFlags)));
87
88
0
template <> void Draw::draw(const SaveBehind& r) {
89
0
    SkCanvasPriv::SaveBehind(fCanvas, r.subset);
90
0
}
91
92
0
template <> void Draw::draw(const DrawBehind& r) {
93
0
    SkCanvasPriv::DrawBehind(fCanvas, r.paint);
94
0
}
95
96
DRAW(MarkCTM, markCTM(r.name.c_str()));
97
DRAW(SetMatrix, setMatrix(fInitialCTM.asM33() * r.matrix));
98
DRAW(SetM44, setMatrix(fInitialCTM * r.matrix));
99
DRAW(Concat44, concat(r.matrix));
100
DRAW(Concat, concat(r.matrix));
101
DRAW(Translate, translate(r.dx, r.dy));
102
DRAW(Scale, scale(r.sx, r.sy));
103
104
DRAW(ClipPath, clipPath(r.path, r.opAA.op(), r.opAA.aa()));
105
DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op(), r.opAA.aa()));
106
DRAW(ClipRect, clipRect(r.rect, r.opAA.op(), r.opAA.aa()));
107
DRAW(ClipRegion, clipRegion(r.region, r.op));
108
DRAW(ClipShader, clipShader(r.shader, r.op));
109
110
0
template <> void Draw::draw(const ResetClip& r) {
111
0
    SkCanvasPriv::ResetClip(fCanvas);
112
0
}
113
114
DRAW(DrawArc, drawArc(r.oval, r.startAngle, r.sweepAngle, r.useCenter, r.paint));
115
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
116
DRAW(DrawImage, drawImage(r.image.get(), r.left, r.top, r.sampling, r.paint));
117
118
187
template <> void Draw::draw(const DrawImageLattice& r) {
119
187
    SkCanvas::Lattice lattice;
120
187
    lattice.fXCount = r.xCount;
121
187
    lattice.fXDivs = r.xDivs;
122
187
    lattice.fYCount = r.yCount;
123
187
    lattice.fYDivs = r.yDivs;
124
187
    lattice.fRectTypes = (0 == r.flagCount) ? nullptr : r.flags;
125
187
    lattice.fColors = (0 == r.flagCount) ? nullptr : r.colors;
126
187
    lattice.fBounds = &r.src;
127
187
    fCanvas->drawImageLattice(r.image.get(), lattice, r.dst, r.filter, r.paint);
128
187
}
129
130
DRAW(DrawImageRect, drawImageRect(r.image.get(), r.src, r.dst, r.sampling, r.paint, r.constraint));
131
DRAW(DrawOval, drawOval(r.oval, r.paint));
132
DRAW(DrawPaint, drawPaint(r.paint));
133
DRAW(DrawPath, drawPath(r.path, r.paint));
134
DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.bmode, r.paint));
135
DRAW(DrawPicture, drawPicture(r.picture.get(), &r.matrix, r.paint));
136
DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint));
137
DRAW(DrawRRect, drawRRect(r.rrect, r.paint));
138
DRAW(DrawRect, drawRect(r.rect, r.paint));
139
DRAW(DrawRegion, drawRegion(r.region, r.paint));
140
DRAW(DrawTextBlob, drawTextBlob(r.blob.get(), r.x, r.y, r.paint));
141
DRAW(DrawAtlas, drawAtlas(r.atlas.get(), r.xforms, r.texs, r.colors, r.count, r.mode, r.sampling,
142
                          r.cull, r.paint));
143
DRAW(DrawVertices, drawVertices(r.vertices, r.bmode, r.paint));
144
DRAW(DrawShadowRec, private_draw_shadow_rec(r.path, r.rec));
145
DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value.get()));
146
147
DRAW(DrawEdgeAAQuad, experimental_DrawEdgeAAQuad(
148
        r.rect, r.clip, r.aa, r.color, r.mode));
149
DRAW(DrawEdgeAAImageSet, experimental_DrawEdgeAAImageSet(
150
        r.set.get(), r.count, r.dstClips, r.preViewMatrices, r.sampling, r.paint, r.constraint));
151
152
#undef DRAW
153
154
0
template <> void Draw::draw(const DrawDrawable& r) {
155
0
    SkASSERT(r.index >= 0);
156
0
    SkASSERT(r.index < fDrawableCount);
157
0
    if (fDrawables) {
158
0
        SkASSERT(nullptr == fDrawablePicts);
159
0
        fCanvas->drawDrawable(fDrawables[r.index], r.matrix);
160
0
    } else {
161
0
        fCanvas->drawPicture(fDrawablePicts[r.index], r.matrix, nullptr);
162
0
    }
163
0
}
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::DrawDrawable>(SkRecords::DrawDrawable const&)
Unexecuted instantiation: void SkRecords::Draw::draw<SkRecords::DrawDrawable>(SkRecords::DrawDrawable const&)
164
165
// This is an SkRecord visitor that fills an SkBBoxHierarchy.
166
//
167
// The interesting part here is how to calculate bounds for ops which don't
168
// have intrinsic bounds.  What is the bounds of a Save or a Translate?
169
//
170
// We answer this by thinking about a particular definition of bounds: if I
171
// don't execute this op, pixels in this rectangle might draw incorrectly.  So
172
// the bounds of a Save, a Translate, a Restore, etc. are the union of the
173
// bounds of Draw* ops that they might have an effect on.  For any given
174
// Save/Restore block, the bounds of the Save, the Restore, and any other
175
// non-drawing ("control") ops inside are exactly the union of the bounds of
176
// the drawing ops inside that block.
177
//
178
// To implement this, we keep a stack of active Save blocks.  As we consume ops
179
// inside the Save/Restore block, drawing ops are unioned with the bounds of
180
// the block, and control ops are stashed away for later.  When we finish the
181
// block with a Restore, our bounds are complete, and we go back and fill them
182
// in for all the control ops we stashed away.
183
class FillBounds : SkNoncopyable {
184
public:
185
    FillBounds(const SkRect& cullRect, const SkRecord& record,
186
               SkRect bounds[], SkBBoxHierarchy::Metadata meta[])
187
        : fCullRect(cullRect)
188
        , fBounds(bounds)
189
0
        , fMeta(meta) {
190
0
        fCTM = SkMatrix::I();
191
192
        // We push an extra save block to track the bounds of any top-level control operations.
193
0
        fSaveStack.push_back({ 0, Bounds::MakeEmpty(), nullptr, fCTM });
194
0
    }
195
196
0
    ~FillBounds() {
197
        // If we have any lingering unpaired Saves, simulate restores to make
198
        // sure all ops in those Save blocks have their bounds calculated.
199
0
        while (!fSaveStack.isEmpty()) {
200
0
            this->popSaveBlock();
201
0
        }
202
203
        // Any control ops not part of any Save/Restore block draw everywhere.
204
0
        while (!fControlIndices.isEmpty()) {
205
0
            this->popControl(fCullRect);
206
0
        }
207
0
    }
208
209
0
    void setCurrentOp(int currentOp) { fCurrentOp = currentOp; }
210
211
212
0
    template <typename T> void operator()(const T& op) {
213
0
        this->updateCTM(op);
214
0
        this->trackBounds(op);
215
0
    }
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::NoOp>(SkRecords::NoOp const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::Flush>(SkRecords::Flush const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::Restore>(SkRecords::Restore const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::Save>(SkRecords::Save const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::SaveLayer>(SkRecords::SaveLayer const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::SaveBehind>(SkRecords::SaveBehind const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::MarkCTM>(SkRecords::MarkCTM const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::SetMatrix>(SkRecords::SetMatrix const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::SetM44>(SkRecords::SetM44 const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::Translate>(SkRecords::Translate const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::Scale>(SkRecords::Scale const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::Concat>(SkRecords::Concat const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::Concat44>(SkRecords::Concat44 const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::ClipPath>(SkRecords::ClipPath const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::ClipRRect>(SkRecords::ClipRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::ClipRect>(SkRecords::ClipRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::ClipRegion>(SkRecords::ClipRegion const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::ClipShader>(SkRecords::ClipShader const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::ResetClip>(SkRecords::ResetClip const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawArc>(SkRecords::DrawArc const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawDrawable>(SkRecords::DrawDrawable const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawImage>(SkRecords::DrawImage const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawImageLattice>(SkRecords::DrawImageLattice const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawImageRect>(SkRecords::DrawImageRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawDRRect>(SkRecords::DrawDRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawOval>(SkRecords::DrawOval const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawBehind>(SkRecords::DrawBehind const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawPaint>(SkRecords::DrawPaint const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawPath>(SkRecords::DrawPath const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawPatch>(SkRecords::DrawPatch const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawPicture>(SkRecords::DrawPicture const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawPoints>(SkRecords::DrawPoints const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawRRect>(SkRecords::DrawRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawRect>(SkRecords::DrawRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawRegion>(SkRecords::DrawRegion const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawTextBlob>(SkRecords::DrawTextBlob const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawAtlas>(SkRecords::DrawAtlas const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawVertices>(SkRecords::DrawVertices const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawShadowRec>(SkRecords::DrawShadowRec const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawAnnotation>(SkRecords::DrawAnnotation const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawEdgeAAQuad>(SkRecords::DrawEdgeAAQuad const&)
Unexecuted instantiation: void SkRecords::FillBounds::operator()<SkRecords::DrawEdgeAAImageSet>(SkRecords::DrawEdgeAAImageSet const&)
216
217
    // In this file, SkRect are in local coordinates, Bounds are translated back to identity space.
218
    typedef SkRect Bounds;
219
220
    // Adjust rect for all paints that may affect its geometry, then map it to identity space.
221
0
    Bounds adjustAndMap(SkRect rect, const SkPaint* paint) const {
222
        // Inverted rectangles really confuse our BBHs.
223
0
        rect.sort();
224
225
        // Adjust the rect for its own paint.
226
0
        if (!AdjustForPaint(paint, &rect)) {
227
            // The paint could do anything to our bounds.  The only safe answer is the cull.
228
0
            return fCullRect;
229
0
        }
230
231
        // Adjust rect for all the paints from the SaveLayers we're inside.
232
0
        if (!this->adjustForSaveLayerPaints(&rect)) {
233
            // Same deal as above.
234
0
            return fCullRect;
235
0
        }
236
237
        // Map the rect back to identity space.
238
0
        fCTM.mapRect(&rect);
239
240
        // Nothing can draw outside the cull rect.
241
0
        if (!rect.intersect(fCullRect)) {
242
0
            return Bounds::MakeEmpty();
243
0
        }
244
245
0
        return rect;
246
0
    }
247
248
private:
249
    struct SaveBounds {
250
        int controlOps;        // Number of control ops in this Save block, including the Save.
251
        Bounds bounds;         // Bounds of everything in the block.
252
        const SkPaint* paint;  // Unowned.  If set, adjusts the bounds of all ops in this block.
253
        SkMatrix ctm;
254
    };
255
256
    // Only Restore, SetMatrix, Concat, and Translate change the CTM.
257
0
    template <typename T> void updateCTM(const T&) {}
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::NoOp>(SkRecords::NoOp const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::Flush>(SkRecords::Flush const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::Save>(SkRecords::Save const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::SaveLayer>(SkRecords::SaveLayer const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::SaveBehind>(SkRecords::SaveBehind const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::MarkCTM>(SkRecords::MarkCTM const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::ClipPath>(SkRecords::ClipPath const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::ClipRRect>(SkRecords::ClipRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::ClipRect>(SkRecords::ClipRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::ClipRegion>(SkRecords::ClipRegion const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::ClipShader>(SkRecords::ClipShader const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::ResetClip>(SkRecords::ResetClip const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawArc>(SkRecords::DrawArc const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawDrawable>(SkRecords::DrawDrawable const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawImage>(SkRecords::DrawImage const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawImageLattice>(SkRecords::DrawImageLattice const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawImageRect>(SkRecords::DrawImageRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawDRRect>(SkRecords::DrawDRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawOval>(SkRecords::DrawOval const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawBehind>(SkRecords::DrawBehind const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawPaint>(SkRecords::DrawPaint const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawPath>(SkRecords::DrawPath const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawPatch>(SkRecords::DrawPatch const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawPicture>(SkRecords::DrawPicture const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawPoints>(SkRecords::DrawPoints const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawRRect>(SkRecords::DrawRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawRect>(SkRecords::DrawRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawRegion>(SkRecords::DrawRegion const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawTextBlob>(SkRecords::DrawTextBlob const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawAtlas>(SkRecords::DrawAtlas const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawVertices>(SkRecords::DrawVertices const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawShadowRec>(SkRecords::DrawShadowRec const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawAnnotation>(SkRecords::DrawAnnotation const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawEdgeAAQuad>(SkRecords::DrawEdgeAAQuad const&)
Unexecuted instantiation: void SkRecords::FillBounds::updateCTM<SkRecords::DrawEdgeAAImageSet>(SkRecords::DrawEdgeAAImageSet const&)
258
0
    void updateCTM(const Restore& op)   { fCTM = op.matrix; }
259
0
    void updateCTM(const SetMatrix& op) { fCTM = op.matrix; }
260
0
    void updateCTM(const SetM44& op)    { fCTM = op.matrix.asM33(); }
261
0
    void updateCTM(const Concat44& op)  { fCTM.preConcat(op.matrix.asM33()); }
262
0
    void updateCTM(const Concat& op)    { fCTM.preConcat(op.matrix); }
263
0
    void updateCTM(const Scale& op)     { fCTM.preScale(op.sx, op.sy); }
264
0
    void updateCTM(const Translate& op) { fCTM.preTranslate(op.dx, op.dy); }
265
266
    // The bounds of these ops must be calculated when we hit the Restore
267
    // from the bounds of the ops in the same Save block.
268
0
    void trackBounds(const Save&)          { this->pushSaveBlock(nullptr); }
269
0
    void trackBounds(const SaveLayer& op)  { this->pushSaveBlock(op.paint); }
270
0
    void trackBounds(const SaveBehind&)    { this->pushSaveBlock(nullptr); }
271
0
    void trackBounds(const Restore&) {
272
0
        const bool isSaveLayer = fSaveStack.top().paint != nullptr;
273
0
        fBounds[fCurrentOp] = this->popSaveBlock();
274
0
        fMeta  [fCurrentOp].isDraw = isSaveLayer;
275
0
    }
276
277
0
    void trackBounds(const MarkCTM&)           { this->pushControl(); }
278
0
    void trackBounds(const SetMatrix&)         { this->pushControl(); }
279
0
    void trackBounds(const SetM44&)            { this->pushControl(); }
280
0
    void trackBounds(const Concat&)            { this->pushControl(); }
281
0
    void trackBounds(const Concat44&)          { this->pushControl(); }
282
0
    void trackBounds(const Scale&)             { this->pushControl(); }
283
0
    void trackBounds(const Translate&)         { this->pushControl(); }
284
0
    void trackBounds(const ClipRect&)          { this->pushControl(); }
285
0
    void trackBounds(const ClipRRect&)         { this->pushControl(); }
286
0
    void trackBounds(const ClipPath&)          { this->pushControl(); }
287
0
    void trackBounds(const ClipRegion&)        { this->pushControl(); }
288
0
    void trackBounds(const ClipShader&)        { this->pushControl(); }
289
0
    void trackBounds(const ResetClip&)         { this->pushControl(); }
290
291
292
    // For all other ops, we can calculate and store the bounds directly now.
293
0
    template <typename T> void trackBounds(const T& op) {
294
0
        fBounds[fCurrentOp] = this->bounds(op);
295
0
        fMeta  [fCurrentOp].isDraw = true;
296
0
        this->updateSaveBounds(fBounds[fCurrentOp]);
297
0
    }
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::NoOp>(SkRecords::NoOp const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::Flush>(SkRecords::Flush const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawArc>(SkRecords::DrawArc const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawDrawable>(SkRecords::DrawDrawable const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawImage>(SkRecords::DrawImage const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawImageLattice>(SkRecords::DrawImageLattice const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawImageRect>(SkRecords::DrawImageRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawDRRect>(SkRecords::DrawDRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawOval>(SkRecords::DrawOval const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawBehind>(SkRecords::DrawBehind const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawPaint>(SkRecords::DrawPaint const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawPath>(SkRecords::DrawPath const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawPatch>(SkRecords::DrawPatch const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawPicture>(SkRecords::DrawPicture const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawPoints>(SkRecords::DrawPoints const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawRRect>(SkRecords::DrawRRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawRect>(SkRecords::DrawRect const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawRegion>(SkRecords::DrawRegion const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawTextBlob>(SkRecords::DrawTextBlob const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawAtlas>(SkRecords::DrawAtlas const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawVertices>(SkRecords::DrawVertices const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawShadowRec>(SkRecords::DrawShadowRec const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawAnnotation>(SkRecords::DrawAnnotation const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawEdgeAAQuad>(SkRecords::DrawEdgeAAQuad const&)
Unexecuted instantiation: void SkRecords::FillBounds::trackBounds<SkRecords::DrawEdgeAAImageSet>(SkRecords::DrawEdgeAAImageSet const&)
298
299
0
    void pushSaveBlock(const SkPaint* paint) {
300
        // Starting a new Save block.  Push a new entry to represent that.
301
0
        SaveBounds sb;
302
0
        sb.controlOps = 0;
303
        // If the paint affects transparent black,
304
        // the bound shouldn't be smaller than the cull.
305
0
        sb.bounds =
306
0
            PaintMayAffectTransparentBlack(paint) ? fCullRect : Bounds::MakeEmpty();
307
0
        sb.paint = paint;
308
0
        sb.ctm = this->fCTM;
309
310
0
        fSaveStack.push_back(sb);
311
0
        this->pushControl();
312
0
    }
313
314
0
    static bool PaintMayAffectTransparentBlack(const SkPaint* paint) {
315
0
        if (paint) {
316
            // FIXME: this is very conservative
317
0
            if ((paint->getImageFilter() &&
318
0
                 as_IFB(paint->getImageFilter())->affectsTransparentBlack()) ||
319
0
                (paint->getColorFilter() &&
320
0
                 as_CFB(paint->getColorFilter())->affectsTransparentBlack())) {
321
0
                return true;
322
0
            }
323
0
            const auto bm = paint->asBlendMode();
324
0
            if (!bm) {
325
0
                return true;    // can we query other blenders for this?
326
0
            }
327
328
            // Unusual blendmodes require us to process a saved layer
329
            // even with operations outisde the clip.
330
            // For example, DstIn is used by masking layers.
331
            // https://code.google.com/p/skia/issues/detail?id=1291
332
            // https://crbug.com/401593
333
0
            switch (bm.value()) {
334
                // For each of the following transfer modes, if the source
335
                // alpha is zero (our transparent black), the resulting
336
                // blended alpha is not necessarily equal to the original
337
                // destination alpha.
338
0
                case SkBlendMode::kClear:
339
0
                case SkBlendMode::kSrc:
340
0
                case SkBlendMode::kSrcIn:
341
0
                case SkBlendMode::kDstIn:
342
0
                case SkBlendMode::kSrcOut:
343
0
                case SkBlendMode::kDstATop:
344
0
                case SkBlendMode::kModulate:
345
0
                    return true;
346
0
                    break;
347
0
                default:
348
0
                    break;
349
0
            }
350
0
        }
351
0
        return false;
352
0
    }
353
354
0
    Bounds popSaveBlock() {
355
        // We're done the Save block.  Apply the block's bounds to all control ops inside it.
356
0
        SaveBounds sb;
357
0
        fSaveStack.pop(&sb);
358
359
0
        while (sb.controlOps --> 0) {
360
0
            this->popControl(sb.bounds);
361
0
        }
362
363
        // This whole Save block may be part another Save block.
364
0
        this->updateSaveBounds(sb.bounds);
365
366
        // If called from a real Restore (not a phony one for balance), it'll need the bounds.
367
0
        return sb.bounds;
368
0
    }
369
370
0
    void pushControl() {
371
0
        fControlIndices.push_back(fCurrentOp);
372
0
        if (!fSaveStack.isEmpty()) {
373
0
            fSaveStack.top().controlOps++;
374
0
        }
375
0
    }
376
377
0
    void popControl(const Bounds& bounds) {
378
0
        fBounds[fControlIndices.top()] = bounds;
379
0
        fMeta  [fControlIndices.top()].isDraw = false;
380
0
        fControlIndices.pop();
381
0
    }
382
383
0
    void updateSaveBounds(const Bounds& bounds) {
384
        // If we're in a Save block, expand its bounds to cover these bounds too.
385
0
        if (!fSaveStack.isEmpty()) {
386
0
            fSaveStack.top().bounds.join(bounds);
387
0
        }
388
0
    }
389
390
0
    Bounds bounds(const Flush&) const { return fCullRect; }
391
392
0
    Bounds bounds(const DrawPaint&) const { return fCullRect; }
393
0
    Bounds bounds(const DrawBehind&) const { return fCullRect; }
394
0
    Bounds bounds(const NoOp&)  const { return Bounds::MakeEmpty(); }    // NoOps don't draw.
395
396
0
    Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); }
397
0
    Bounds bounds(const DrawRegion& op) const {
398
0
        SkRect rect = SkRect::Make(op.region.getBounds());
399
0
        return this->adjustAndMap(rect, &op.paint);
400
0
    }
401
0
    Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); }
402
    // Tighter arc bounds?
403
0
    Bounds bounds(const DrawArc& op) const { return this->adjustAndMap(op.oval, &op.paint); }
404
0
    Bounds bounds(const DrawRRect& op) const {
405
0
        return this->adjustAndMap(op.rrect.rect(), &op.paint);
406
0
    }
407
0
    Bounds bounds(const DrawDRRect& op) const {
408
0
        return this->adjustAndMap(op.outer.rect(), &op.paint);
409
0
    }
410
0
    Bounds bounds(const DrawImage& op) const {
411
0
        const SkImage* image = op.image.get();
412
0
        SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height());
413
414
0
        return this->adjustAndMap(rect, op.paint);
415
0
    }
416
0
    Bounds bounds(const DrawImageLattice& op) const {
417
0
        return this->adjustAndMap(op.dst, op.paint);
418
0
    }
419
0
    Bounds bounds(const DrawImageRect& op) const {
420
0
        return this->adjustAndMap(op.dst, op.paint);
421
0
    }
422
0
    Bounds bounds(const DrawPath& op) const {
423
0
        return op.path.isInverseFillType() ? fCullRect
424
0
                                           : this->adjustAndMap(op.path.getBounds(), &op.paint);
425
0
    }
426
0
    Bounds bounds(const DrawPoints& op) const {
427
0
        SkRect dst;
428
0
        dst.setBounds(op.pts, op.count);
429
430
        // Pad the bounding box a little to make sure hairline points' bounds aren't empty.
431
0
        SkScalar stroke = std::max(op.paint.getStrokeWidth(), 0.01f);
432
0
        dst.outset(stroke/2, stroke/2);
433
434
0
        return this->adjustAndMap(dst, &op.paint);
435
0
    }
436
0
    Bounds bounds(const DrawPatch& op) const {
437
0
        SkRect dst;
438
0
        dst.setBounds(op.cubics, SkPatchUtils::kNumCtrlPts);
439
0
        return this->adjustAndMap(dst, &op.paint);
440
0
    }
441
0
    Bounds bounds(const DrawVertices& op) const {
442
0
        return this->adjustAndMap(op.vertices->bounds(), &op.paint);
443
0
    }
444
445
0
    Bounds bounds(const DrawAtlas& op) const {
446
0
        if (op.cull) {
447
            // TODO: <reed> can we pass nullptr for the paint? Isn't cull already "correct"
448
            // for the paint (by the caller)?
449
0
            return this->adjustAndMap(*op.cull, op.paint);
450
0
        } else {
451
0
            return fCullRect;
452
0
        }
453
0
    }
454
455
0
    Bounds bounds(const DrawShadowRec& op) const {
456
0
        SkRect bounds;
457
0
        SkDrawShadowMetrics::GetLocalBounds(op.path, op.rec, fCTM, &bounds);
458
0
        return this->adjustAndMap(bounds, nullptr);
459
0
    }
460
461
0
    Bounds bounds(const DrawPicture& op) const {
462
0
        SkRect dst = op.picture->cullRect();
463
0
        op.matrix.mapRect(&dst);
464
0
        return this->adjustAndMap(dst, op.paint);
465
0
    }
466
467
0
    Bounds bounds(const DrawTextBlob& op) const {
468
0
        SkRect dst = op.blob->bounds();
469
0
        dst.offset(op.x, op.y);
470
0
        return this->adjustAndMap(dst, &op.paint);
471
0
    }
472
473
0
    Bounds bounds(const DrawDrawable& op) const {
474
0
        return this->adjustAndMap(op.worstCaseBounds, nullptr);
475
0
    }
476
477
0
    Bounds bounds(const DrawAnnotation& op) const {
478
0
        return this->adjustAndMap(op.rect, nullptr);
479
0
    }
480
0
    Bounds bounds(const DrawEdgeAAQuad& op) const {
481
0
        SkRect bounds = op.rect;
482
0
        if (op.clip) {
483
0
            bounds.setBounds(op.clip, 4);
484
0
        }
485
0
        return this->adjustAndMap(bounds, nullptr);
486
0
    }
487
0
    Bounds bounds(const DrawEdgeAAImageSet& op) const {
488
0
        SkRect rect = SkRect::MakeEmpty();
489
0
        int clipIndex = 0;
490
0
        for (int i = 0; i < op.count; ++i) {
491
0
            SkRect entryBounds = op.set[i].fDstRect;
492
0
            if (op.set[i].fHasClip) {
493
0
                entryBounds.setBounds(op.dstClips + clipIndex, 4);
494
0
                clipIndex += 4;
495
0
            }
496
0
            if (op.set[i].fMatrixIndex >= 0) {
497
0
                op.preViewMatrices[op.set[i].fMatrixIndex].mapRect(&entryBounds);
498
0
            }
499
0
            rect.join(this->adjustAndMap(entryBounds, nullptr));
500
0
        }
501
0
        return rect;
502
0
    }
503
504
    // Returns true if rect was meaningfully adjusted for the effects of paint,
505
    // false if the paint could affect the rect in unknown ways.
506
0
    static bool AdjustForPaint(const SkPaint* paint, SkRect* rect) {
507
0
        if (paint) {
508
0
            if (paint->canComputeFastBounds()) {
509
0
                *rect = paint->computeFastBounds(*rect, rect);
510
0
                return true;
511
0
            }
512
0
            return false;
513
0
        }
514
0
        return true;
515
0
    }
516
517
0
    bool adjustForSaveLayerPaints(SkRect* rect, int savesToIgnore = 0) const {
518
0
        for (int i = fSaveStack.count() - 1 - savesToIgnore; i >= 0; i--) {
519
0
            SkMatrix inverse;
520
0
            if (!fSaveStack[i].ctm.invert(&inverse)) {
521
0
                return false;
522
0
            }
523
0
            inverse.mapRect(rect);
524
0
            if (!AdjustForPaint(fSaveStack[i].paint, rect)) {
525
0
                return false;
526
0
            }
527
0
            fSaveStack[i].ctm.mapRect(rect);
528
0
        }
529
0
        return true;
530
0
    }
531
532
    // We do not guarantee anything for operations outside of the cull rect
533
    const SkRect fCullRect;
534
535
    // Conservative identity-space bounds for each op in the SkRecord.
536
    Bounds* fBounds;
537
538
    // Parallel array to fBounds, holding metadata for each bounds rect.
539
    SkBBoxHierarchy::Metadata* fMeta;
540
541
    // We walk fCurrentOp through the SkRecord,
542
    // as we go using updateCTM() to maintain the exact CTM (fCTM).
543
    int fCurrentOp;
544
    SkMatrix fCTM;
545
546
    // Used to track the bounds of Save/Restore blocks and the control ops inside them.
547
    SkTDArray<SaveBounds> fSaveStack;
548
    SkTDArray<int>   fControlIndices;
549
};
550
551
}  // namespace SkRecords
552
553
void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record,
554
0
                        SkRect bounds[], SkBBoxHierarchy::Metadata meta[]) {
555
0
    {
556
0
        SkRecords::FillBounds visitor(cullRect, record, bounds, meta);
557
0
        for (int i = 0; i < record.count(); i++) {
558
0
            visitor.setCurrentOp(i);
559
0
            record.visit(i, visitor);
560
0
        }
561
0
    }
562
0
}