DamageAccumulator.h revision e4267ea4f20740c37c01bfb6aefcf61fddc4566a
1/* 2 * Copyright (C) 2014 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#ifndef DAMAGEACCUMULATOR_H 17#define DAMAGEACCUMULATOR_H 18 19#include <utils/LinearAllocator.h> 20 21#include <SkMatrix.h> 22#include <SkRect.h> 23 24#include "utils/Macros.h" 25 26namespace android { 27namespace uirenderer { 28 29struct DirtyStack; 30class RenderNode; 31 32class DamageAccumulator { 33 PREVENT_COPY_AND_ASSIGN(DamageAccumulator); 34public: 35 DamageAccumulator(); 36 // mAllocator will clean everything up for us, no need for a dtor 37 38 // Push a transform node onto the stack. This should be called prior 39 // to any dirty() calls. Subsequent calls to dirty() 40 // will be affected by the node's transform when popNode() is called. 41 void pushNode(const RenderNode* node); 42 // Pops a transform node from the stack, propagating the dirty rect 43 // up to the parent node. 44 void popNode(); 45 void dirty(float left, float top, float right, float bottom); 46 47 void finish(SkRect* totalDirty); 48 49private: 50 LinearAllocator mAllocator; 51 DirtyStack* mHead; 52}; 53 54} /* namespace uirenderer */ 55} /* namespace android */ 56 57#endif /* DAMAGEACCUMULATOR_H */ 58