DisplayList.cpp revision 51d6a3db97bdd5315f1a17a4b447d10a92217b98
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 , hasDrawOps(false) { 35} 36 37DisplayListData::~DisplayListData() { 38 cleanupResources(); 39} 40 41void DisplayListData::cleanupResources() { 42 ResourceCache& resourceCache = ResourceCache::getInstance(); 43 resourceCache.lock(); 44 45 for (size_t i = 0; i < bitmapResources.size(); i++) { 46 resourceCache.decrementRefcountLocked(bitmapResources.itemAt(i)); 47 } 48 49 for (size_t i = 0; i < ownedBitmapResources.size(); i++) { 50 const SkBitmap* bitmap = ownedBitmapResources.itemAt(i); 51 resourceCache.decrementRefcountLocked(bitmap); 52 resourceCache.destructorLocked(bitmap); 53 } 54 55 for (size_t i = 0; i < patchResources.size(); i++) { 56 resourceCache.decrementRefcountLocked(patchResources.itemAt(i)); 57 } 58 59 for (size_t i = 0; i < sourcePaths.size(); i++) { 60 resourceCache.decrementRefcountLocked(sourcePaths.itemAt(i)); 61 } 62 63 resourceCache.unlock(); 64 65 bitmapResources.clear(); 66 ownedBitmapResources.clear(); 67 patchResources.clear(); 68 sourcePaths.clear(); 69 paints.clear(); 70 regions.clear(); 71 paths.clear(); 72} 73 74size_t DisplayListData::addChild(DrawRenderNodeOp* op) { 75 mReferenceHolders.push(op->renderNode()); 76 return mChildren.add(op); 77} 78 79}; // namespace uirenderer 80}; // namespace android 81