Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: src/core/SkPictureStateTree.cpp

Issue 111573002: Avoid heap allocation in SkPictureStateTree constructor (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureStateTree.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureStateTree.cpp
===================================================================
--- src/core/SkPictureStateTree.cpp (revision 12590)
+++ src/core/SkPictureStateTree.cpp (working copy)
@@ -11,19 +11,16 @@
SkPictureStateTree::SkPictureStateTree()
: fAlloc(2048)
- , fRoot(NULL)
, fLastRestoredNode(NULL)
, fStateStack(sizeof(Draw), 16) {
- SkMatrix* identity = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatrix)));
- identity->reset();
- fRoot = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node)));
- fRoot->fParent = NULL;
- fRoot->fMatrix = identity;
- fRoot->fFlags = Node::kSave_Flag;
- fRoot->fOffset = 0;
- fRoot->fLevel = 0;
- fCurrentState.fNode = fRoot;
- fCurrentState.fMatrix = identity;
+ fRootMatrix.reset();
+ fRoot.fParent = NULL;
+ fRoot.fMatrix = &fRootMatrix;
+ fRoot.fFlags = Node::kSave_Flag;
+ fRoot.fOffset = 0;
+ fRoot.fLevel = 0;
+ fCurrentState.fNode = &fRoot;
+ fCurrentState.fMatrix = &fRootMatrix;
*static_cast<Draw*>(fStateStack.push_back()) = fCurrentState;
}
@@ -78,7 +75,7 @@
SkPictureStateTree::Iterator SkPictureStateTree::getIterator(const SkTDArray<void*>& draws,
SkCanvas* canvas) {
- return Iterator(draws, canvas, fRoot);
+ return Iterator(draws, canvas, &fRoot);
}
void SkPictureStateTree::appendNode(uint32_t offset) {
« no previous file with comments | « src/core/SkPictureStateTree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698