Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkRecord.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
8#include "src/core/SkRecord.h"
9
10#include <algorithm>
11
13 Destroyer destroyer;
14 for (int i = 0; i < this->count(); i++) {
15 this->mutate(i, destroyer);
16 }
17}
18
19void SkRecord::grow() {
20 SkASSERT(fCount == fReserved);
21 fReserved = fReserved ? fReserved * 2 : 4;
22 fRecords.realloc(fReserved);
23}
24
25size_t SkRecord::bytesUsed() const {
26 size_t bytes = fApproxBytesAllocated + sizeof(SkRecord);
27 return bytes;
28}
29
31 // Remove all the NoOps, preserving the order of other ops, e.g.
32 // Save, ClipRect, NoOp, DrawRect, NoOp, NoOp, Restore
33 // -> Save, ClipRect, DrawRect, Restore
34 Record* noops = std::remove_if(fRecords.get(), fRecords.get() + fCount,
35 [](Record op) { return op.type() == SkRecords::NoOp_Type; });
36 fCount = noops - fRecords.get();
37}
#define SkASSERT(cond)
Definition SkAssert.h:116
size_t bytesUsed() const
Definition SkRecord.cpp:25
auto mutate(int i, F &&f) -> decltype(f((SkRecords::NoOp *) nullptr))
Definition SkRecord.h:54
int count() const
Definition SkRecord.h:38
void defrag()
Definition SkRecord.cpp:30
SkRecord()=default
~SkRecord() override
Definition SkRecord.cpp:12
void realloc(size_t count)