}
DisplayList::~DisplayList() {
+ clearResources();
+}
+
+void DisplayList::clearResources() {
sk_free((void*) mReader.base());
Caches& caches = Caches::getInstance();
mMatrices.clear();
}
-void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder) {
+void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
const SkWriter32& writer = recorder.writeStream();
init();
return;
}
+ if (reusing) {
+ // re-using display list - clear out previous allocations
+ clearResources();
+ }
+
size_t size = writer.size();
void* buffer = sk_malloc_throw(size);
writer.flatten(buffer);
if (mDisplayList == NULL) {
mDisplayList = new DisplayList(*this);
} else {
- mDisplayList->initFromDisplayListRenderer(*this);
+ mDisplayList->initFromDisplayListRenderer(*this, true);
}
return mDisplayList;
}
static const char* OP_NAMES[];
- void initFromDisplayListRenderer(const DisplayListRenderer& recorder);
+ void initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing = false);
bool replay(OpenGLRenderer& renderer, uint32_t level = 0);
private:
void init();
+ void clearResources();
+
class TextContainer {
public:
size_t length() const {