blob: 2337299da145e175953115c273f6e82632bc0568 [file] [log] [blame]
Chris Craik0776a602013-02-14 15:36:01 -08001/*
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
Romain Guyc46d07a2013-03-15 19:06:39 -070017#include <SkCanvas.h>
Chris Craik9f68c092014-01-10 10:30:57 -080018#include <algorithm>
Romain Guyc46d07a2013-03-15 19:06:39 -070019
Chris Craikf57776b2013-10-25 18:30:17 -070020#include <utils/Trace.h>
21
Chris Craikc3566d02013-02-04 16:16:33 -080022#include "Debug.h"
Chris Craik0776a602013-02-14 15:36:01 -080023#include "DisplayList.h"
Chris Craikb565df12015-10-05 13:00:52 -070024#include "RenderNode.h"
25
26#if HWUI_NEW_OPS
27#include "RecordedOp.h"
28#else
Chris Craik0776a602013-02-14 15:36:01 -080029#include "DisplayListOp.h"
Chris Craikb565df12015-10-05 13:00:52 -070030#endif
Chris Craik0776a602013-02-14 15:36:01 -080031
32namespace android {
33namespace uirenderer {
34
Chris Craik3f0854292014-04-15 16:18:08 -070035DisplayListData::DisplayListData()
36 : projectionReceiveIndex(-1)
Chris Craik3f0854292014-04-15 16:18:08 -070037 , hasDrawOps(false) {
John Reck087bc0c2014-04-04 16:20:08 -070038}
39
40DisplayListData::~DisplayListData() {
41 cleanupResources();
42}
43
John Reck44fd8d22014-02-26 11:00:11 -080044void DisplayListData::cleanupResources() {
John Reck4a4bc892015-10-12 07:38:22 -070045 if (CC_UNLIKELY(patchResources.size())) {
46 ResourceCache& resourceCache = ResourceCache::getInstance();
47 resourceCache.lock();
John Reck44fd8d22014-02-26 11:00:11 -080048
John Reck4a4bc892015-10-12 07:38:22 -070049 for (size_t i = 0; i < patchResources.size(); i++) {
50 resourceCache.decrementRefcountLocked(patchResources[i]);
51 }
52
53 resourceCache.unlock();
John Reck44fd8d22014-02-26 11:00:11 -080054 }
55
Derek Sollenbergeree248592015-02-12 14:10:21 -050056 for (size_t i = 0; i < pathResources.size(); i++) {
John Reck272a6852015-07-29 16:48:58 -070057 const SkPath* path = pathResources[i];
Derek Sollenbergeree248592015-02-12 14:10:21 -050058 if (path->unique() && Caches::hasInstance()) {
59 Caches::getInstance().pathCache.removeDeferred(path);
60 }
61 delete path;
62 }
63
John Reck44fd8d22014-02-26 11:00:11 -080064 patchResources.clear();
Derek Sollenbergeree248592015-02-12 14:10:21 -050065 pathResources.clear();
John Reck44fd8d22014-02-26 11:00:11 -080066 paints.clear();
67 regions.clear();
John Reck44fd8d22014-02-26 11:00:11 -080068}
69
Chris Craikb565df12015-10-05 13:00:52 -070070#if HWUI_NEW_OPS
71size_t DisplayListData::addChild(RenderNodeOp* op) {
72 mReferenceHolders.push_back(op->renderNode);
73#else
Chris Craik8afd0f22014-08-21 17:41:57 -070074size_t DisplayListData::addChild(DrawRenderNodeOp* op) {
Chris Craikb565df12015-10-05 13:00:52 -070075 mReferenceHolders.push_back(op->renderNode);
76#endif
John Reck272a6852015-07-29 16:48:58 -070077 size_t index = mChildren.size();
78 mChildren.push_back(op);
79 return index;
John Reck087bc0c2014-04-04 16:20:08 -070080}
81
Chris Craik0776a602013-02-14 15:36:01 -080082}; // namespace uirenderer
83}; // namespace android