blob: 317e395a852a6adffa1809a339aa2c8a5532f1b7 [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
Chris Craikf57776b2013-10-25 18:30:17 -070017#define ATRACE_TAG ATRACE_TAG_VIEW
18
Romain Guyc46d07a2013-03-15 19:06:39 -070019#include <SkCanvas.h>
Chris Craik9f68c092014-01-10 10:30:57 -080020#include <algorithm>
Romain Guyc46d07a2013-03-15 19:06:39 -070021
Chris Craikf57776b2013-10-25 18:30:17 -070022#include <utils/Trace.h>
23
Chris Craikc3566d02013-02-04 16:16:33 -080024#include "Debug.h"
Chris Craik0776a602013-02-14 15:36:01 -080025#include "DisplayList.h"
26#include "DisplayListOp.h"
Chris Craik0776a602013-02-14 15:36:01 -080027
28namespace android {
29namespace uirenderer {
30
Chris Craik3f0854292014-04-15 16:18:08 -070031DisplayListData::DisplayListData()
32 : projectionReceiveIndex(-1)
Chris Craik3f0854292014-04-15 16:18:08 -070033 , hasDrawOps(false) {
John Reck087bc0c2014-04-04 16:20:08 -070034}
35
36DisplayListData::~DisplayListData() {
37 cleanupResources();
38}
39
John Reck44fd8d22014-02-26 11:00:11 -080040void DisplayListData::cleanupResources() {
John Recka35778c72014-11-06 09:45:10 -080041 ResourceCache& resourceCache = ResourceCache::getInstance();
42 resourceCache.lock();
John Reck44fd8d22014-02-26 11:00:11 -080043
44 for (size_t i = 0; i < bitmapResources.size(); i++) {
John Recka35778c72014-11-06 09:45:10 -080045 resourceCache.decrementRefcountLocked(bitmapResources.itemAt(i));
John Reck44fd8d22014-02-26 11:00:11 -080046 }
47
John Reck44fd8d22014-02-26 11:00:11 -080048 for (size_t i = 0; i < patchResources.size(); i++) {
John Recka35778c72014-11-06 09:45:10 -080049 resourceCache.decrementRefcountLocked(patchResources.itemAt(i));
John Reck44fd8d22014-02-26 11:00:11 -080050 }
51
John Reck44fd8d22014-02-26 11:00:11 -080052 for (size_t i = 0; i < sourcePaths.size(); i++) {
John Recka35778c72014-11-06 09:45:10 -080053 resourceCache.decrementRefcountLocked(sourcePaths.itemAt(i));
John Reck44fd8d22014-02-26 11:00:11 -080054 }
55
John Recka35778c72014-11-06 09:45:10 -080056 resourceCache.unlock();
John Reck44fd8d22014-02-26 11:00:11 -080057
John Reck44fd8d22014-02-26 11:00:11 -080058 bitmapResources.clear();
John Reck44fd8d22014-02-26 11:00:11 -080059 patchResources.clear();
John Reck44fd8d22014-02-26 11:00:11 -080060 sourcePaths.clear();
61 paints.clear();
62 regions.clear();
63 paths.clear();
John Reck44fd8d22014-02-26 11:00:11 -080064}
65
Chris Craik8afd0f22014-08-21 17:41:57 -070066size_t DisplayListData::addChild(DrawRenderNodeOp* op) {
John Reck087bc0c2014-04-04 16:20:08 -070067 mReferenceHolders.push(op->renderNode());
Chris Craik8afd0f22014-08-21 17:41:57 -070068 return mChildren.add(op);
John Reck087bc0c2014-04-04 16:20:08 -070069}
70
Chris Craik0776a602013-02-14 15:36:01 -080071}; // namespace uirenderer
72}; // namespace android