summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/DisplayListRenderer.cpp80
-rw-r--r--libs/hwui/DisplayListRenderer.h10
2 files changed, 53 insertions, 37 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 77d628a..afb82bf 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -82,6 +82,43 @@ void PathHeap::flatten(SkFlattenableWriteBuffer& buffer) const {
///////////////////////////////////////////////////////////////////////////////
DisplayList::DisplayList(const DisplayListRenderer& recorder) {
+ initFromDisplayListRenderer(recorder);
+}
+
+DisplayList::~DisplayList() {
+ sk_free((void*) mReader.base());
+
+ Caches& caches = Caches::getInstance();
+
+ for (size_t i = 0; i < mBitmapResources.size(); i++) {
+ caches.resourceCache.decrementRefcount(mBitmapResources.itemAt(i));
+ }
+ mBitmapResources.clear();
+
+ for (size_t i = 0; i < mShaderResources.size(); i++) {
+ caches.resourceCache.decrementRefcount(mShaderResources.itemAt(i));
+ }
+ mShaderResources.clear();
+
+ for (size_t i = 0; i < mPaints.size(); i++) {
+ delete mPaints.itemAt(i);
+ }
+ mPaints.clear();
+
+ for (size_t i = 0; i < mMatrices.size(); i++) {
+ delete mMatrices.itemAt(i);
+ }
+ mMatrices.clear();
+
+ if (mPathHeap) {
+ for (int i = 0; i < mPathHeap->count(); i++) {
+ caches.pathCache.removeDeferred(&(*mPathHeap)[i]);
+ }
+ mPathHeap->safeUnref();
+ }
+}
+
+void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder) {
const SkWriter32& writer = recorder.writeStream();
init();
@@ -132,39 +169,6 @@ DisplayList::DisplayList(const DisplayListRenderer& recorder) {
}
}
-DisplayList::~DisplayList() {
- sk_free((void*) mReader.base());
-
- Caches& caches = Caches::getInstance();
-
- for (size_t i = 0; i < mBitmapResources.size(); i++) {
- caches.resourceCache.decrementRefcount(mBitmapResources.itemAt(i));
- }
- mBitmapResources.clear();
-
- for (size_t i = 0; i < mShaderResources.size(); i++) {
- caches.resourceCache.decrementRefcount(mShaderResources.itemAt(i));
- }
- mShaderResources.clear();
-
- for (size_t i = 0; i < mPaints.size(); i++) {
- delete mPaints.itemAt(i);
- }
- mPaints.clear();
-
- for (size_t i = 0; i < mMatrices.size(); i++) {
- delete mMatrices.itemAt(i);
- }
- mMatrices.clear();
-
- if (mPathHeap) {
- for (int i = 0; i < mPathHeap->count(); i++) {
- caches.pathCache.removeDeferred(&(*mPathHeap)[i]);
- }
- mPathHeap->safeUnref();
- }
-}
-
void DisplayList::init() {
mPathHeap = NULL;
}
@@ -327,6 +331,7 @@ void DisplayList::replay(OpenGLRenderer& renderer) {
DisplayListRenderer::DisplayListRenderer():
mHeap(HEAP_BLOCK_SIZE), mWriter(MIN_WRITER_SIZE) {
mPathHeap = NULL;
+ mDisplayList = NULL;
}
DisplayListRenderer::~DisplayListRenderer() {
@@ -367,6 +372,15 @@ void DisplayListRenderer::reset() {
// Operations
///////////////////////////////////////////////////////////////////////////////
+DisplayList* DisplayListRenderer::getDisplayList() {
+ if (mDisplayList == NULL) {
+ mDisplayList = new DisplayList(*this);
+ } else {
+ mDisplayList->initFromDisplayListRenderer(*this);
+ }
+ return mDisplayList;
+}
+
void DisplayListRenderer::setViewport(int width, int height) {
mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index b608381..fedb174 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -110,6 +110,8 @@ public:
SetupShadow
};
+ void initFromDisplayListRenderer(const DisplayListRenderer& recorder);
+
void replay(OpenGLRenderer& renderer);
private:
@@ -216,6 +218,8 @@ public:
DisplayListRenderer();
~DisplayListRenderer();
+ DisplayList* getDisplayList();
+
void setViewport(int width, int height);
void prepare(bool opaque);
@@ -266,10 +270,6 @@ public:
void reset();
- DisplayList* getDisplayList() const {
- return new DisplayList(*this);
- }
-
const SkWriter32& writeStream() const {
return mWriter;
}
@@ -422,6 +422,8 @@ private:
SkRefCntRecorder mRCRecorder;
SkRefCntRecorder mTFRecorder;
+ DisplayList *mDisplayList;
+
friend class DisplayList;
}; // class DisplayListRenderer