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-10-25 18:30:17 -07:00
|
|
|
#define ATRACE_TAG ATRACE_TAG_VIEW
|
|
|
|
|
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"
|
|
|
|
#include "DisplayListOp.h"
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2014-04-15 16:18:08 -07:00
|
|
|
DisplayListData::DisplayListData()
|
|
|
|
: projectionReceiveIndex(-1)
|
|
|
|
, hasDrawOps(false) {
|
2014-04-04 16:20:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayListData::~DisplayListData() {
|
|
|
|
cleanupResources();
|
|
|
|
}
|
|
|
|
|
2014-02-26 11:00:11 -08:00
|
|
|
void DisplayListData::cleanupResources() {
|
2014-11-06 09:45:10 -08:00
|
|
|
ResourceCache& resourceCache = ResourceCache::getInstance();
|
|
|
|
resourceCache.lock();
|
2014-02-26 11:00:11 -08:00
|
|
|
|
|
|
|
for (size_t i = 0; i < bitmapResources.size(); i++) {
|
2014-11-06 09:45:10 -08:00
|
|
|
resourceCache.decrementRefcountLocked(bitmapResources.itemAt(i));
|
2014-02-26 11:00:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < patchResources.size(); i++) {
|
2014-11-06 09:45:10 -08:00
|
|
|
resourceCache.decrementRefcountLocked(patchResources.itemAt(i));
|
2014-02-26 11:00:11 -08:00
|
|
|
}
|
|
|
|
|
2014-11-06 09:45:10 -08: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++) {
|
|
|
|
const SkPath* path = pathResources.itemAt(i);
|
|
|
|
if (path->unique() && Caches::hasInstance()) {
|
|
|
|
Caches::getInstance().pathCache.removeDeferred(path);
|
|
|
|
}
|
|
|
|
delete path;
|
|
|
|
}
|
|
|
|
|
2014-02-26 11:00:11 -08:00
|
|
|
bitmapResources.clear();
|
|
|
|
patchResources.clear();
|
2015-02-12 14:10:21 -05:00
|
|
|
pathResources.clear();
|
2014-02-26 11:00:11 -08:00
|
|
|
paints.clear();
|
|
|
|
regions.clear();
|
|
|
|
}
|
|
|
|
|
2014-08-21 17:41:57 -07:00
|
|
|
size_t DisplayListData::addChild(DrawRenderNodeOp* op) {
|
2014-04-04 16:20:08 -07:00
|
|
|
mReferenceHolders.push(op->renderNode());
|
2014-08-21 17:41:57 -07:00
|
|
|
return mChildren.add(op);
|
2014-04-04 16:20:08 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:36:01 -08:00
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|