2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <utils/Trace.h>
23 #include "DisplayList.h"
24 #include "RenderNode.h"
27 #include "RecordedOp.h"
29 #include "DisplayListOp.h"
33 namespace uirenderer {
35 DisplayList::DisplayList()
36 : projectionReceiveIndex(-1)
37 , stdAllocator(allocator)
38 , chunks(stdAllocator)
40 , children(stdAllocator)
41 , bitmapResources(stdAllocator)
42 , pathResources(stdAllocator)
43 , patchResources(stdAllocator)
44 , paints(stdAllocator)
45 , regions(stdAllocator)
46 , referenceHolders(stdAllocator)
47 , functors(stdAllocator)
48 , vectorDrawables(stdAllocator)
52 DisplayList::~DisplayList() {
56 void DisplayList::cleanupResources() {
57 if (CC_UNLIKELY(patchResources.size())) {
58 ResourceCache& resourceCache = ResourceCache::getInstance();
61 for (size_t i = 0; i < patchResources.size(); i++) {
62 resourceCache.decrementRefcountLocked(patchResources[i]);
65 resourceCache.unlock();
68 for (size_t i = 0; i < pathResources.size(); i++) {
69 const SkPath* path = pathResources[i];
70 if (path->unique() && Caches::hasInstance()) {
71 Caches::getInstance().pathCache.removeDeferred(path);
76 for (auto& iter : functors) {
78 iter.listener->onGlFunctorReleased(iter.functor);
82 patchResources.clear();
83 pathResources.clear();
88 size_t DisplayList::addChild(NodeOpType* op) {
89 referenceHolders.push_back(op->renderNode);
90 size_t index = children.size();
91 children.push_back(op);
95 }; // namespace uirenderer
96 }; // namespace android