10b7e8245db728d127ada698be63d78b33fc6e4daChris Craik/*
20b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * Copyright (C) 2015 The Android Open Source Project
30b7e8245db728d127ada698be63d78b33fc6e4daChris Craik *
40b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * Licensed under the Apache License, Version 2.0 (the "License");
50b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * you may not use this file except in compliance with the License.
60b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * You may obtain a copy of the License at
70b7e8245db728d127ada698be63d78b33fc6e4daChris Craik *
80b7e8245db728d127ada698be63d78b33fc6e4daChris Craik *      http://www.apache.org/licenses/LICENSE-2.0
90b7e8245db728d127ada698be63d78b33fc6e4daChris Craik *
100b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * Unless required by applicable law or agreed to in writing, software
110b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * distributed under the License is distributed on an "AS IS" BASIS,
120b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * See the License for the specific language governing permissions and
140b7e8245db728d127ada698be63d78b33fc6e4daChris Craik * limitations under the License.
150b7e8245db728d127ada698be63d78b33fc6e4daChris Craik */
160b7e8245db728d127ada698be63d78b33fc6e4daChris Craik
170b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#include "LayerUpdateQueue.h"
180b7e8245db728d127ada698be63d78b33fc6e4daChris Craik
190b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#include "RenderNode.h"
200b7e8245db728d127ada698be63d78b33fc6e4daChris Craik
210b7e8245db728d127ada698be63d78b33fc6e4daChris Craiknamespace android {
220b7e8245db728d127ada698be63d78b33fc6e4daChris Craiknamespace uirenderer {
230b7e8245db728d127ada698be63d78b33fc6e4daChris Craik
240b7e8245db728d127ada698be63d78b33fc6e4daChris Craikvoid LayerUpdateQueue::clear() {
250b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    mEntries.clear();
260b7e8245db728d127ada698be63d78b33fc6e4daChris Craik}
270b7e8245db728d127ada698be63d78b33fc6e4daChris Craik
280b7e8245db728d127ada698be63d78b33fc6e4daChris Craikvoid LayerUpdateQueue::enqueueLayerWithDamage(RenderNode* renderNode, Rect damage) {
29ac046387be01e586ab29519adb6d865381efa37fJohn Reck    damage.roundOut();
300b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    damage.doIntersect(0, 0, renderNode->getWidth(), renderNode->getHeight());
310b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    if (!damage.isEmpty()) {
320b7e8245db728d127ada698be63d78b33fc6e4daChris Craik        for (Entry& entry : mEntries) {
330b7e8245db728d127ada698be63d78b33fc6e4daChris Craik            if (CC_UNLIKELY(entry.renderNode == renderNode)) {
340b7e8245db728d127ada698be63d78b33fc6e4daChris Craik                entry.damage.unionWith(damage);
350b7e8245db728d127ada698be63d78b33fc6e4daChris Craik                return;
360b7e8245db728d127ada698be63d78b33fc6e4daChris Craik            }
370b7e8245db728d127ada698be63d78b33fc6e4daChris Craik        }
380b7e8245db728d127ada698be63d78b33fc6e4daChris Craik        mEntries.emplace_back(renderNode, damage);
390b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    }
400b7e8245db728d127ada698be63d78b33fc6e4daChris Craik}
410b7e8245db728d127ada698be63d78b33fc6e4daChris Craik
420b7e8245db728d127ada698be63d78b33fc6e4daChris Craik} // namespace uirenderer
430b7e8245db728d127ada698be63d78b33fc6e4daChris Craik} // namespace android
44