2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef DAMAGEACCUMULATOR_H
17 #define DAMAGEACCUMULATOR_H
19 #include <cutils/compiler.h>
20 #include <utils/LinearAllocator.h>
25 #include "utils/Macros.h"
27 // Smaller than INT_MIN/INT_MAX because we offset these values
28 // and thus don't want to be adding offsets to INT_MAX, that's bad
29 #define DIRTY_MIN (-0x7ffffff-1)
30 #define DIRTY_MAX (0x7ffffff)
33 namespace uirenderer {
39 class DamageAccumulator {
40 PREVENT_COPY_AND_ASSIGN(DamageAccumulator);
43 // mAllocator will clean everything up for us, no need for a dtor
45 // Push a transform node onto the stack. This should be called prior
46 // to any dirty() calls. Subsequent calls to dirty()
47 // will be affected by the transform when popTransform() is called.
48 void pushTransform(const RenderNode* transform);
49 void pushTransform(const Matrix4* transform);
51 // Pops a transform node from the stack, propagating the dirty rect
52 // up to the parent node. Returns the IDamageTransform that was just applied
55 void dirty(float left, float top, float right, float bottom);
57 // Returns the current dirty area, *NOT* transformed by pushed transforms
58 void peekAtDirty(SkRect* dest) const;
60 ANDROID_API void computeCurrentTransform(Matrix4* outMatrix) const;
62 void finish(SkRect* totalDirty);
66 void applyMatrix4Transform(DirtyStack* frame);
67 void applyRenderNodeTransform(DirtyStack* frame);
69 LinearAllocator mAllocator;
73 } /* namespace uirenderer */
74 } /* namespace android */
76 #endif /* DAMAGEACCUMULATOR_H */