Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 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 | |
Romain Guy | c46d07a | 2013-03-15 19:06:39 -0700 | [diff] [blame] | 17 | #include <SkCanvas.h> |
Chris Craik | 9f68c09 | 2014-01-10 10:30:57 -0800 | [diff] [blame] | 18 | #include <algorithm> |
Romain Guy | c46d07a | 2013-03-15 19:06:39 -0700 | [diff] [blame] | 19 | |
Chris Craik | f57776b | 2013-10-25 18:30:17 -0700 | [diff] [blame] | 20 | #include <utils/Trace.h> |
| 21 | |
Chris Craik | c3566d0 | 2013-02-04 16:16:33 -0800 | [diff] [blame] | 22 | #include "Debug.h" |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 23 | #include "DisplayList.h" |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 24 | #include "RenderNode.h" |
| 25 | |
| 26 | #if HWUI_NEW_OPS |
| 27 | #include "RecordedOp.h" |
| 28 | #else |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 29 | #include "DisplayListOp.h" |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 30 | #endif |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 31 | |
| 32 | namespace android { |
| 33 | namespace uirenderer { |
| 34 | |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 35 | DisplayListData::DisplayListData() |
| 36 | : projectionReceiveIndex(-1) |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 37 | , hasDrawOps(false) { |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | DisplayListData::~DisplayListData() { |
| 41 | cleanupResources(); |
| 42 | } |
| 43 | |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 44 | void DisplayListData::cleanupResources() { |
John Reck | 4a4bc89 | 2015-10-12 07:38:22 -0700 | [diff] [blame] | 45 | if (CC_UNLIKELY(patchResources.size())) { |
| 46 | ResourceCache& resourceCache = ResourceCache::getInstance(); |
| 47 | resourceCache.lock(); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 48 | |
John Reck | 4a4bc89 | 2015-10-12 07:38:22 -0700 | [diff] [blame] | 49 | for (size_t i = 0; i < patchResources.size(); i++) { |
| 50 | resourceCache.decrementRefcountLocked(patchResources[i]); |
| 51 | } |
| 52 | |
| 53 | resourceCache.unlock(); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Derek Sollenberger | ee24859 | 2015-02-12 14:10:21 -0500 | [diff] [blame] | 56 | for (size_t i = 0; i < pathResources.size(); i++) { |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 57 | const SkPath* path = pathResources[i]; |
Derek Sollenberger | ee24859 | 2015-02-12 14:10:21 -0500 | [diff] [blame] | 58 | if (path->unique() && Caches::hasInstance()) { |
| 59 | Caches::getInstance().pathCache.removeDeferred(path); |
| 60 | } |
| 61 | delete path; |
| 62 | } |
| 63 | |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 64 | patchResources.clear(); |
Derek Sollenberger | ee24859 | 2015-02-12 14:10:21 -0500 | [diff] [blame] | 65 | pathResources.clear(); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 66 | paints.clear(); |
| 67 | regions.clear(); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 68 | } |
| 69 | |
Chris Craik | 10ed692 | 2015-10-15 10:55:15 -0700 | [diff] [blame] | 70 | size_t DisplayListData::addChild(NodeOpType* op) { |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 71 | mReferenceHolders.push_back(op->renderNode); |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 72 | size_t index = mChildren.size(); |
| 73 | mChildren.push_back(op); |
| 74 | return index; |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 77 | }; // namespace uirenderer |
| 78 | }; // namespace android |