1487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk/*
2487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * Copyright (C) 2015 The Android Open Source Project
3487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk *
4487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * Licensed under the Apache License, Version 2.0 (the "License");
5487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * you may not use this file except in compliance with the License.
6487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * You may obtain a copy of the License at
7487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk *
8487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk *      http://www.apache.org/licenses/LICENSE-2.0
9487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk *
10487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * Unless required by applicable law or agreed to in writing, software
11487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * distributed under the License is distributed on an "AS IS" BASIS,
12487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * See the License for the specific language governing permissions and
14487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk * limitations under the License.
15487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk */
16487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk#ifndef CLIPAREA_H
17487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk#define CLIPAREA_H
18487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
19487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk#include "Matrix.h"
20487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk#include "Rect.h"
21487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk#include "utils/Pair.h"
22487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
23e4db79de127cfe961195f52907af8451026eaa20Chris Craik#include <SkRegion.h>
24e4db79de127cfe961195f52907af8451026eaa20Chris Craik
25487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuknamespace android {
26487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuknamespace uirenderer {
27487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
28e4db79de127cfe961195f52907af8451026eaa20Chris Craikclass LinearAllocator;
29e4db79de127cfe961195f52907af8451026eaa20Chris Craik
30487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob TsukRect transformAndCalculateBounds(const Rect& r, const Matrix4& transform);
31487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
32487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsukclass TransformedRectangle {
33487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsukpublic:
34487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    TransformedRectangle();
35487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    TransformedRectangle(const Rect& bounds, const Matrix4& transform);
36487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
37487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool canSimplyIntersectWith(const TransformedRectangle& other) const;
38ac02eb9035a13a3d09c2def9ed63d04225eb2509Chris Craik    void intersectWith(const TransformedRectangle& other);
39487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
40487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool isEmpty() const;
41487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
42487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    const Rect& getBounds() const {
43487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return mBounds;
44487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
45487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
46487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    Rect transformedBounds() const {
47487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        Rect transformedBounds(transformAndCalculateBounds(mBounds, mTransform));
48487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return transformedBounds;
49487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
50487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
51487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    const Matrix4& getTransform() const {
52487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return mTransform;
53487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
54487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
55e4db79de127cfe961195f52907af8451026eaa20Chris Craik    void transform(const Matrix4& transform) {
56e4db79de127cfe961195f52907af8451026eaa20Chris Craik        Matrix4 t;
57e4db79de127cfe961195f52907af8451026eaa20Chris Craik        t.loadMultiply(transform, mTransform);
58e4db79de127cfe961195f52907af8451026eaa20Chris Craik        mTransform = t;
59e4db79de127cfe961195f52907af8451026eaa20Chris Craik    }
60e4db79de127cfe961195f52907af8451026eaa20Chris Craik
61487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsukprivate:
62487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    Rect mBounds;
63487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    Matrix4 mTransform;
64487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk};
65487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
66487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsukclass RectangleList {
67487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsukpublic:
68487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    RectangleList();
69487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
70487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool isEmpty() const;
71487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    int getTransformedRectanglesCount() const;
72487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    const TransformedRectangle& getTransformedRectangle(int i) const;
73487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
74487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void setEmpty();
75487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void set(const Rect& bounds, const Matrix4& transform);
76487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool intersectWith(const Rect& bounds, const Matrix4& transform);
77e4db79de127cfe961195f52907af8451026eaa20Chris Craik    void transform(const Matrix4& transform);
78487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
79487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    SkRegion convertToRegion(const SkRegion& clip) const;
80487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    Rect calculateBounds() const;
81487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
82487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    enum {
83487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        kMaxTransformedRectangles = 5
84487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    };
85487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
86e4db79de127cfe961195f52907af8451026eaa20Chris Craikprivate:
87487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    int mTransformedRectanglesCount;
88487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    TransformedRectangle mTransformedRectangles[kMaxTransformedRectangles];
89487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk};
90487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
91e4db79de127cfe961195f52907af8451026eaa20Chris Craikenum class ClipMode {
92e4db79de127cfe961195f52907af8451026eaa20Chris Craik    Rectangle,
93e4db79de127cfe961195f52907af8451026eaa20Chris Craik    RectangleList,
944d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik
95e4db79de127cfe961195f52907af8451026eaa20Chris Craik    // region and path - intersected. if either is empty, don't use
96e4db79de127cfe961195f52907af8451026eaa20Chris Craik    Region
97e4db79de127cfe961195f52907af8451026eaa20Chris Craik};
98e4db79de127cfe961195f52907af8451026eaa20Chris Craik
99e4db79de127cfe961195f52907af8451026eaa20Chris Craikstruct ClipBase {
100e4db79de127cfe961195f52907af8451026eaa20Chris Craik    ClipBase(ClipMode mode)
101e4db79de127cfe961195f52907af8451026eaa20Chris Craik            : mode(mode) {}
102e4db79de127cfe961195f52907af8451026eaa20Chris Craik    ClipBase(const Rect& rect)
103e4db79de127cfe961195f52907af8451026eaa20Chris Craik            : mode(ClipMode::Rectangle)
104e4db79de127cfe961195f52907af8451026eaa20Chris Craik            , rect(rect) {}
105e4db79de127cfe961195f52907af8451026eaa20Chris Craik    const ClipMode mode;
10604d46eb69fb4f4c4c332c36c6ae845da3b2ae848Chris Craik    bool intersectWithRoot = false;
107e4db79de127cfe961195f52907af8451026eaa20Chris Craik    // Bounds of the clipping area, used to define the scissor, and define which
108e4db79de127cfe961195f52907af8451026eaa20Chris Craik    // portion of the stencil is updated/used
109e4db79de127cfe961195f52907af8451026eaa20Chris Craik    Rect rect;
11002806288d1c56475413888a934c796e6e4eb11c5Chris Craik
11102806288d1c56475413888a934c796e6e4eb11c5Chris Craik    void dump() const;
112e4db79de127cfe961195f52907af8451026eaa20Chris Craik};
113e4db79de127cfe961195f52907af8451026eaa20Chris Craik
114e4db79de127cfe961195f52907af8451026eaa20Chris Craikstruct ClipRect : ClipBase {
115e4db79de127cfe961195f52907af8451026eaa20Chris Craik    ClipRect(const Rect& rect)
116e4db79de127cfe961195f52907af8451026eaa20Chris Craik            : ClipBase(rect) {}
117e4db79de127cfe961195f52907af8451026eaa20Chris Craik};
118e4db79de127cfe961195f52907af8451026eaa20Chris Craik
119e4db79de127cfe961195f52907af8451026eaa20Chris Craikstruct ClipRectList : ClipBase {
120e4db79de127cfe961195f52907af8451026eaa20Chris Craik    ClipRectList(const RectangleList& rectList)
121e4db79de127cfe961195f52907af8451026eaa20Chris Craik            : ClipBase(ClipMode::RectangleList)
122e4db79de127cfe961195f52907af8451026eaa20Chris Craik            , rectList(rectList) {}
123e4db79de127cfe961195f52907af8451026eaa20Chris Craik    RectangleList rectList;
124e4db79de127cfe961195f52907af8451026eaa20Chris Craik};
125e4db79de127cfe961195f52907af8451026eaa20Chris Craik
126e4db79de127cfe961195f52907af8451026eaa20Chris Craikstruct ClipRegion : ClipBase {
127e4db79de127cfe961195f52907af8451026eaa20Chris Craik    ClipRegion(const SkRegion& region)
128e4db79de127cfe961195f52907af8451026eaa20Chris Craik            : ClipBase(ClipMode::Region)
129e4db79de127cfe961195f52907af8451026eaa20Chris Craik            , region(region) {}
130e4db79de127cfe961195f52907af8451026eaa20Chris Craik    ClipRegion()
131e4db79de127cfe961195f52907af8451026eaa20Chris Craik            : ClipBase(ClipMode::Region) {}
132e4db79de127cfe961195f52907af8451026eaa20Chris Craik    SkRegion region;
133e4db79de127cfe961195f52907af8451026eaa20Chris Craik};
134e4db79de127cfe961195f52907af8451026eaa20Chris Craik
135e4db79de127cfe961195f52907af8451026eaa20Chris Craikclass ClipArea {
136487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsukpublic:
137487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    ClipArea();
138487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
139487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void setViewportDimensions(int width, int height);
140487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
141487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool isEmpty() const {
142487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return mClipRect.isEmpty();
143487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
144487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
145487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void setEmpty();
146487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void setClip(float left, float top, float right, float bottom);
1474d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik    void clipRectWithTransform(const Rect& r, const mat4* transform,
1484d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik            SkRegion::Op op);
1494d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik    void clipRegion(const SkRegion& region, SkRegion::Op op);
1504d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik    void clipPathWithTransform(const SkPath& path, const mat4* transform,
151487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk            SkRegion::Op op);
152487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
153487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    const Rect& getClipRect() const {
154487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return mClipRect;
155487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
156487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
157487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    const SkRegion& getClipRegion() const {
158487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return mClipRegion;
159487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
160487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
161487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    const RectangleList& getRectangleList() const {
162487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return mRectangleList;
163487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
164487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
165487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool isRegion() const {
166e4db79de127cfe961195f52907af8451026eaa20Chris Craik        return ClipMode::Region == mMode;
167487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
168487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
169487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool isSimple() const {
170e4db79de127cfe961195f52907af8451026eaa20Chris Craik        return mMode == ClipMode::Rectangle;
171487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
172487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
173487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    bool isRectangleList() const {
174e4db79de127cfe961195f52907af8451026eaa20Chris Craik        return mMode == ClipMode::RectangleList;
175487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
176487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
17704d46eb69fb4f4c4c332c36c6ae845da3b2ae848Chris Craik    WARN_UNUSED_RESULT const ClipBase* serializeClip(LinearAllocator& allocator);
17804d46eb69fb4f4c4c332c36c6ae845da3b2ae848Chris Craik    WARN_UNUSED_RESULT const ClipBase* serializeIntersectedClip(LinearAllocator& allocator,
179e4db79de127cfe961195f52907af8451026eaa20Chris Craik            const ClipBase* recordedClip, const Matrix4& recordedClipTransform);
180e4db79de127cfe961195f52907af8451026eaa20Chris Craik    void applyClip(const ClipBase* recordedClip, const Matrix4& recordedClipTransform);
181e4db79de127cfe961195f52907af8451026eaa20Chris Craik
182487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsukprivate:
183487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void enterRectangleMode();
1844d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik    void rectangleModeClipRectWithTransform(const Rect& r, const mat4* transform, SkRegion::Op op);
185487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
186487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void enterRectangleListMode();
1874d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik    void rectangleListModeClipRectWithTransform(const Rect& r,
188487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk            const mat4* transform, SkRegion::Op op);
189487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
190487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void enterRegionModeFromRectangleMode();
191487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void enterRegionModeFromRectangleListMode();
192487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void enterRegionMode();
1934d3e704b04c6abd7995df640d12662b0271f6c7bChris Craik    void regionModeClipRectWithTransform(const Rect& r, const mat4* transform,
194487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk            SkRegion::Op op);
195487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
196487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void ensureClipRegion();
197e30b53cec5eb6eaa5d24231feb3207b917c1baabTom Hudson    void onClipRegionUpdated();
198487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
199e4db79de127cfe961195f52907af8451026eaa20Chris Craik    // Called by every state modifying public method.
200e4db79de127cfe961195f52907af8451026eaa20Chris Craik    void onClipUpdated() {
201e4db79de127cfe961195f52907af8451026eaa20Chris Craik        mPostViewportClipObserved = true;
202e4db79de127cfe961195f52907af8451026eaa20Chris Craik        mLastSerialization = nullptr;
203e4db79de127cfe961195f52907af8451026eaa20Chris Craik        mLastResolutionResult = nullptr;
204e4db79de127cfe961195f52907af8451026eaa20Chris Craik    }
205e4db79de127cfe961195f52907af8451026eaa20Chris Craik
206487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    SkRegion createViewportRegion() {
207487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        return SkRegion(mViewportBounds.toSkIRect());
208487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
209487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
210487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    void regionFromPath(const SkPath& path, SkRegion& pathAsRegion) {
2118ce8f3f4d68a7750bc02b5254ebbd8658281e675Chris Craik        // TODO: this should not mask every path to the viewport - this makes it impossible to use
2128ce8f3f4d68a7750bc02b5254ebbd8658281e675Chris Craik        // paths to clip to larger areas (which is valid e.g. with SkRegion::kReplace_Op)
213487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk        pathAsRegion.setPath(path, createViewportRegion());
214487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    }
215487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
216e4db79de127cfe961195f52907af8451026eaa20Chris Craik    ClipMode mMode;
217e4db79de127cfe961195f52907af8451026eaa20Chris Craik    bool mPostViewportClipObserved = false;
21804d46eb69fb4f4c4c332c36c6ae845da3b2ae848Chris Craik    bool mReplaceOpObserved = false;
219e4db79de127cfe961195f52907af8451026eaa20Chris Craik
220e4db79de127cfe961195f52907af8451026eaa20Chris Craik    /**
221e4db79de127cfe961195f52907af8451026eaa20Chris Craik     * If mLastSerialization is non-null, it represents an already serialized copy
222e4db79de127cfe961195f52907af8451026eaa20Chris Craik     * of the current clip state. If null, it has not been computed.
223e4db79de127cfe961195f52907af8451026eaa20Chris Craik     */
224e4db79de127cfe961195f52907af8451026eaa20Chris Craik    const ClipBase* mLastSerialization = nullptr;
225e4db79de127cfe961195f52907af8451026eaa20Chris Craik
226e4db79de127cfe961195f52907af8451026eaa20Chris Craik    /**
227e4db79de127cfe961195f52907af8451026eaa20Chris Craik     * This pair of pointers is a single entry cache of most recently seen
228e4db79de127cfe961195f52907af8451026eaa20Chris Craik     */
229e4db79de127cfe961195f52907af8451026eaa20Chris Craik    const ClipBase* mLastResolutionResult = nullptr;
230e4db79de127cfe961195f52907af8451026eaa20Chris Craik    const ClipBase* mLastResolutionClip = nullptr;
231e4db79de127cfe961195f52907af8451026eaa20Chris Craik    Matrix4 mLastResolutionTransform;
232e4db79de127cfe961195f52907af8451026eaa20Chris Craik
233487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    Rect mViewportBounds;
234487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    Rect mClipRect;
235487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    SkRegion mClipRegion;
236487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk    RectangleList mRectangleList;
237487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk};
238487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
239487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk} /* namespace uirenderer */
240487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk} /* namespace android */
241487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk
242487a92caef2eb90a62e8f8d7a6fe6315f1c1d8d8Rob Tsuk#endif /* CLIPAREA_H_ */
243