DisplayList.cpp revision d1ad5e62fda248c6d185cde3cb6d9f01a223066c
1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#define ATRACE_TAG ATRACE_TAG_VIEW 18 19#include <SkCanvas.h> 20#include <algorithm> 21 22#include <utils/Trace.h> 23 24#include "Debug.h" 25#include "DisplayList.h" 26#include "DisplayListOp.h" 27#include "DisplayListLogBuffer.h" 28 29namespace android { 30namespace uirenderer { 31 32DisplayListData::DisplayListData() 33 : projectionReceiveIndex(-1) 34 , functorCount(0) 35 , hasDrawOps(false) { 36} 37 38DisplayListData::~DisplayListData() { 39 cleanupResources(); 40} 41 42void DisplayListData::cleanupResources() { 43 Caches& caches = Caches::getInstance(); 44 caches.unregisterFunctors(functorCount); 45 caches.resourceCache.lock(); 46 47 for (size_t i = 0; i < bitmapResources.size(); i++) { 48 caches.resourceCache.decrementRefcountLocked(bitmapResources.itemAt(i)); 49 } 50 51 for (size_t i = 0; i < ownedBitmapResources.size(); i++) { 52 const SkBitmap* bitmap = ownedBitmapResources.itemAt(i); 53 caches.resourceCache.decrementRefcountLocked(bitmap); 54 caches.resourceCache.destructorLocked(bitmap); 55 } 56 57 for (size_t i = 0; i < patchResources.size(); i++) { 58 caches.resourceCache.decrementRefcountLocked(patchResources.itemAt(i)); 59 } 60 61 for (size_t i = 0; i < sourcePaths.size(); i++) { 62 caches.resourceCache.decrementRefcountLocked(sourcePaths.itemAt(i)); 63 } 64 65 for (size_t i = 0; i < layers.size(); i++) { 66 caches.resourceCache.decrementRefcountLocked(layers.itemAt(i)); 67 } 68 69 caches.resourceCache.unlock(); 70 71 for (size_t i = 0; i < paints.size(); i++) { 72 delete paints.itemAt(i); 73 } 74 75 for (size_t i = 0; i < regions.size(); i++) { 76 delete regions.itemAt(i); 77 } 78 79 for (size_t i = 0; i < paths.size(); i++) { 80 delete paths.itemAt(i); 81 } 82 83 for (size_t i = 0; i < matrices.size(); i++) { 84 delete matrices.itemAt(i); 85 } 86 87 bitmapResources.clear(); 88 ownedBitmapResources.clear(); 89 patchResources.clear(); 90 sourcePaths.clear(); 91 paints.clear(); 92 regions.clear(); 93 paths.clear(); 94 matrices.clear(); 95 layers.clear(); 96} 97 98void DisplayListData::addChild(DrawDisplayListOp* op) { 99 LOG_ALWAYS_FATAL_IF(!op->renderNode(), "DrawDisplayListOp with no render node!"); 100 101 mChildren.push(op); 102 mReferenceHolders.push(op->renderNode()); 103} 104 105}; // namespace uirenderer 106}; // namespace android 107