Flutter Engine
The Flutter Engine
SkBigPicture.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 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
9
13#include "src/core/SkRecord.h"
15#include "src/core/SkRecords.h"
16
17#include <utility>
18
20 sk_sp<SkRecord> record,
21 std::unique_ptr<SnapshotArray> drawablePicts,
23 size_t approxBytesUsedBySubPictures)
24 : fCullRect(cull)
25 , fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures)
26 , fRecord(std::move(record))
27 , fDrawablePicts(std::move(drawablePicts))
28 , fBBH(std::move(bbh))
29{}
30
32 SkASSERT(canvas);
33
34 // If the query contains the whole picture, don't bother with the BBH.
35 const bool useBBH = !canvas->getLocalClipBounds().contains(this->cullRect());
36
37 SkRecordDraw(*fRecord,
38 canvas,
39 this->drawablePicts(),
40 nullptr,
41 this->drawableCount(),
42 useBBH ? fBBH.get() : nullptr,
43 callback);
44}
45
47 int fCount = 0;
48
49 template <typename T> void operator()(const T& op) {
50 fCount += 1;
51 }
52 void operator()(const SkRecords::DrawPicture& op) {
53 fCount += op.picture->approximateOpCount(true);
54 }
55};
56
57SkRect SkBigPicture::cullRect() const { return fCullRect; }
58int SkBigPicture::approximateOpCount(bool nested) const {
59 if (nested) {
61 for (int i = 0; i < fRecord->count(); i++) {
62 fRecord->visit(i, visitor);
63 }
64 return visitor.fCount;
65 } else {
66 return fRecord->count();
67 }
68}
70 size_t bytes = sizeof(*this) + fRecord->bytesUsed() + fApproxBytesUsedBySubPictures;
71 if (fBBH) { bytes += fBBH->bytesUsed(); }
72 return bytes;
73}
74
75int SkBigPicture::drawableCount() const {
76 return fDrawablePicts ? fDrawablePicts->count() : 0;
77}
78
79SkPicture const* const* SkBigPicture::drawablePicts() const {
80 return fDrawablePicts ? fDrawablePicts->begin() : nullptr;
81}
82
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SkRecordDraw(const SkRecord &record, SkCanvas *canvas, SkPicture const *const drawablePicts[], SkDrawable *const drawables[], int drawableCount, const SkBBoxHierarchy *bbh, SkPicture::AbortCallback *callback)
virtual size_t bytesUsed() const =0
SkRect cullRect() const override
void playback(SkCanvas *, AbortCallback *) const override
size_t approximateBytesUsed() const override
int approximateOpCount(bool nested) const override
SkRect getLocalClipBounds() const
Definition: SkCanvas.cpp:1586
friend class SkBigPicture
Definition: SkPicture.h:253
auto visit(int i, F &&f) const -> decltype(f(SkRecords::NoOp()))
Definition: SkRecord.h:45
size_t bytesUsed() const
Definition: SkRecord.cpp:25
int count() const
Definition: SkRecord.h:38
T * get() const
Definition: SkRefCnt.h:303
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: ref_ptr.h:256
#define T
Definition: precompiler.cc:65
void operator()(const SkRecords::DrawPicture &op)
void operator()(const T &op)
bool contains(SkScalar x, SkScalar y) const
Definition: extension.cpp:19