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 <cutils/compiler.h> 20 #include <utils/LinearAllocator.h> 21 22 #include <SkMatrix.h> 23 #include <SkRect.h> 24 25 #include "utils/Macros.h" 26 27 namespace android { 28 namespace uirenderer { 29 30 struct DirtyStack; 31 class RenderNode; 32 class Matrix4; 33 34 class DamageAccumulator { 35 PREVENT_COPY_AND_ASSIGN(DamageAccumulator); 36 public: 37 DamageAccumulator(); 38 // mAllocator will clean everything up for us, no need for a dtor 39 40 // Push a transform node onto the stack. This should be called prior 41 // to any dirty() calls. Subsequent calls to dirty() 42 // will be affected by the transform when popTransform() is called. 43 void pushTransform(const RenderNode* transform); 44 void pushTransform(const Matrix4* transform); 45 46 // Pops a transform node from the stack, propagating the dirty rect 47 // up to the parent node. Returns the IDamageTransform that was just applied 48 void popTransform(); 49 50 void dirty(float left, float top, float right, float bottom); 51 52 // Returns the current dirty area, *NOT* transformed by pushed transforms 53 void peekAtDirty(SkRect* dest) const; 54 55 void computeCurrentTransform(Matrix4* outMatrix) const; 56 57 void finish(SkRect* totalDirty); 58 59 private: 60 void pushCommon(); 61 void applyMatrix4Transform(DirtyStack* frame); 62 void applyRenderNodeTransform(DirtyStack* frame); 63 64 LinearAllocator mAllocator; 65 DirtyStack* mHead; 66 }; 67 68 } /* namespace uirenderer */ 69 } /* namespace android */ 70 71 #endif /* DAMAGEACCUMULATOR_H */ 72