@@ -162,6 +162,13 @@ void DisplayList::clearResources() {
162162 }
163163 mBitmapResources .clear ();
164164
165+ for (size_t i = 0 ; i < mOwnedBitmapResources .size (); i++) {
166+ SkBitmap* bitmap = mOwnedBitmapResources .itemAt (i);
167+ caches.resourceCache .decrementRefcount (bitmap);
168+ caches.resourceCache .destructor (bitmap);
169+ }
170+ mOwnedBitmapResources .clear ();
171+
165172 for (size_t i = 0 ; i < mFilterResources .size (); i++) {
166173 caches.resourceCache .decrementRefcount (mFilterResources .itemAt (i));
167174 }
@@ -217,44 +224,51 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde
217224
218225 Caches& caches = Caches::getInstance ();
219226
220- const Vector<SkBitmap*> & bitmapResources = recorder.getBitmapResources ();
227+ const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources ();
221228 for (size_t i = 0 ; i < bitmapResources.size (); i++) {
222229 SkBitmap* resource = bitmapResources.itemAt (i);
223230 mBitmapResources .add (resource);
224231 caches.resourceCache .incrementRefcount (resource);
225232 }
226233
227- const Vector<SkiaColorFilter*> &filterResources = recorder.getFilterResources ();
234+ const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources ();
235+ for (size_t i = 0 ; i < ownedBitmapResources.size (); i++) {
236+ SkBitmap* resource = ownedBitmapResources.itemAt (i);
237+ mOwnedBitmapResources .add (resource);
238+ caches.resourceCache .incrementRefcount (resource);
239+ }
240+
241+ const Vector<SkiaColorFilter*>& filterResources = recorder.getFilterResources ();
228242 for (size_t i = 0 ; i < filterResources.size (); i++) {
229243 SkiaColorFilter* resource = filterResources.itemAt (i);
230244 mFilterResources .add (resource);
231245 caches.resourceCache .incrementRefcount (resource);
232246 }
233247
234- const Vector<SkiaShader*> & shaders = recorder.getShaders ();
248+ const Vector<SkiaShader*>& shaders = recorder.getShaders ();
235249 for (size_t i = 0 ; i < shaders.size (); i++) {
236250 SkiaShader* resource = shaders.itemAt (i);
237251 mShaders .add (resource);
238252 caches.resourceCache .incrementRefcount (resource);
239253 }
240254
241- const Vector<SkPaint*> & paints = recorder.getPaints ();
255+ const Vector<SkPaint*>& paints = recorder.getPaints ();
242256 for (size_t i = 0 ; i < paints.size (); i++) {
243257 mPaints .add (paints.itemAt (i));
244258 }
245259
246- const Vector<SkPath*> & paths = recorder.getPaths ();
260+ const Vector<SkPath*>& paths = recorder.getPaths ();
247261 for (size_t i = 0 ; i < paths.size (); i++) {
248262 mPaths .add (paths.itemAt (i));
249263 }
250264
251- const SortedVector<SkPath*> & sourcePaths = recorder.getSourcePaths ();
265+ const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths ();
252266 for (size_t i = 0 ; i < sourcePaths.size (); i++) {
253267 mSourcePaths .add (sourcePaths.itemAt (i));
254268 caches.resourceCache .incrementRefcount (sourcePaths.itemAt (i));
255269 }
256270
257- const Vector<SkMatrix*> & matrices = recorder.getMatrices ();
271+ const Vector<SkMatrix*>& matrices = recorder.getMatrices ();
258272 for (size_t i = 0 ; i < matrices.size (); i++) {
259273 mMatrices .add (matrices.itemAt (i));
260274 }
@@ -1036,10 +1050,7 @@ status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flag
10361050 SkPaint* paint = getPaint (renderer);
10371051 DISPLAY_LIST_LOGD (" %s%s %p, %.2f, %.2f, %p" , (char *) indent, OP_NAMES[op],
10381052 bitmap, x, y, paint);
1039- if (bitmap) {
1040- renderer.drawBitmap (bitmap, x, y, paint);
1041- delete bitmap;
1042- }
1053+ renderer.drawBitmap (bitmap, x, y, paint);
10431054 }
10441055 break ;
10451056 case DrawBitmapMesh: {
@@ -1295,6 +1306,12 @@ void DisplayListRenderer::reset() {
12951306 }
12961307 mBitmapResources .clear ();
12971308
1309+ for (size_t i = 0 ; i < mOwnedBitmapResources .size (); i++) {
1310+ SkBitmap* bitmap = mOwnedBitmapResources .itemAt (i);
1311+ caches.resourceCache .decrementRefcount (bitmap);
1312+ }
1313+ mOwnedBitmapResources .clear ();
1314+
12981315 for (size_t i = 0 ; i < mFilterResources .size (); i++) {
12991316 caches.resourceCache .decrementRefcount (mFilterResources .itemAt (i));
13001317 }
@@ -1336,6 +1353,10 @@ DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
13361353 return displayList;
13371354}
13381355
1356+ bool DisplayListRenderer::isDeferred () {
1357+ return true ;
1358+ }
1359+
13391360void DisplayListRenderer::setViewport (int width, int height) {
13401361 mOrthoMatrix .loadOrtho (0 , width, height, 0 , -1 , 1 );
13411362
0 commit comments