2013-02-14 15:36:01 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-03-15 19:06:39 -07:00
|
|
|
#include <SkCanvas.h>
|
2014-01-10 10:30:57 -08:00
|
|
|
#include <algorithm>
|
2013-03-15 19:06:39 -07:00
|
|
|
|
2013-10-25 18:30:17 -07:00
|
|
|
#include <utils/Trace.h>
|
|
|
|
|
2013-02-04 16:16:33 -08:00
|
|
|
#include "Debug.h"
|
2013-02-14 15:36:01 -08:00
|
|
|
#include "DisplayList.h"
|
2015-10-05 13:00:52 -07:00
|
|
|
#include "RenderNode.h"
|
|
|
|
|
|
|
|
#if HWUI_NEW_OPS
|
|
|
|
#include "RecordedOp.h"
|
|
|
|
#else
|
2013-02-14 15:36:01 -08:00
|
|
|
#include "DisplayListOp.h"
|
2015-10-05 13:00:52 -07:00
|
|
|
#endif
|
2013-02-14 15:36:01 -08:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2015-10-16 10:24:55 -07:00
|
|
|
DisplayList::DisplayList()
|
2014-04-15 16:18:08 -07:00
|
|
|
: projectionReceiveIndex(-1)
|
2015-10-16 14:23:12 -07:00
|
|
|
, stdAllocator(allocator)
|
|
|
|
, chunks(stdAllocator)
|
|
|
|
, ops(stdAllocator)
|
|
|
|
, children(stdAllocator)
|
|
|
|
, bitmapResources(stdAllocator)
|
|
|
|
, pathResources(stdAllocator)
|
|
|
|
, patchResources(stdAllocator)
|
|
|
|
, paints(stdAllocator)
|
|
|
|
, regions(stdAllocator)
|
|
|
|
, referenceHolders(stdAllocator)
|
|
|
|
, functors(stdAllocator)
|
2014-04-15 16:18:08 -07:00
|
|
|
, hasDrawOps(false) {
|
2014-04-04 16:20:08 -07:00
|
|
|
}
|
|
|
|
|
2015-10-16 10:24:55 -07:00
|
|
|
DisplayList::~DisplayList() {
|
2014-04-04 16:20:08 -07:00
|
|
|
cleanupResources();
|
|
|
|
}
|
|
|
|
|
2015-10-16 10:24:55 -07:00
|
|
|
void DisplayList::cleanupResources() {
|
2015-10-12 07:38:22 -07:00
|
|
|
if (CC_UNLIKELY(patchResources.size())) {
|
|
|
|
ResourceCache& resourceCache = ResourceCache::getInstance();
|
|
|
|
resourceCache.lock();
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-10-12 07:38:22 -07:00
|
|
|
for (size_t i = 0; i < patchResources.size(); i++) {
|
|
|
|
resourceCache.decrementRefcountLocked(patchResources[i]);
|
|
|
|
}
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-10-12 07:38:22 -07:00
|
|
|
resourceCache.unlock();
|
|
|
|
}
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-02-12 14:10:21 -05:00
|
|
|
for (size_t i = 0; i < pathResources.size(); i++) {
|
2015-07-29 16:48:58 -07:00
|
|
|
const SkPath* path = pathResources[i];
|
2015-02-12 14:10:21 -05:00
|
|
|
if (path->unique() && Caches::hasInstance()) {
|
|
|
|
Caches::getInstance().pathCache.removeDeferred(path);
|
|
|
|
}
|
|
|
|
delete path;
|
|
|
|
}
|
|
|
|
|
2014-02-26 11:00:11 -08:00
|
|
|
patchResources.clear();
|
2015-02-12 14:10:21 -05:00
|
|
|
pathResources.clear();
|
2014-02-26 11:00:11 -08:00
|
|
|
paints.clear();
|
|
|
|
regions.clear();
|
|
|
|
}
|
|
|
|
|
2015-10-16 10:24:55 -07:00
|
|
|
size_t DisplayList::addChild(NodeOpType* op) {
|
2015-10-16 14:23:12 -07:00
|
|
|
referenceHolders.push_back(op->renderNode);
|
|
|
|
size_t index = children.size();
|
|
|
|
children.push_back(op);
|
2015-07-29 16:48:58 -07:00
|
|
|
return index;
|
2014-04-04 16:20:08 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:36:01 -08:00
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|