blob: ece8498b7e736caff7f288abe43637f4665a0c95 [file] [log] [blame]
Chris Craik8c271ca2014-03-25 10:33:01 -07001/*
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 REVEALCLIP_H
17#define REVEALCLIP_H
18
19#include <SkPath.h>
20
21#include "Rect.h"
22
23namespace android {
24namespace uirenderer {
25
26class RevealClip {
27public:
28 RevealClip()
29 : mShouldClip(false)
30 , mInverseClip(false)
31 , mX(0)
32 , mY(0)
33 , mRadius(0) {}
34
35 void set(bool shouldClip, bool inverseClip, float x, float y, float radius) {
36 mShouldClip = shouldClip;
37 mInverseClip = inverseClip;
38 mX = x;
39 mY = y;
40 mRadius = radius;
41
42 mPath.rewind();
43 if (mShouldClip) {
44 mPath.addCircle(x, y, radius);
45 }
46 }
47
48 bool hasConvexClip() const {
49 return mShouldClip && !mInverseClip;
50 }
51
52 bool isInverseClip() const {
53 return mInverseClip;
54 }
55
56 bool willClip() const {
57 return mShouldClip;
58 }
59
60 const SkPath* getPath() const {
61 if (!mShouldClip) return NULL;
62
63 return &mPath;
64 }
65
66private:
67 bool mShouldClip;
68 bool mInverseClip;
69 float mX;
70 float mY;
71 float mRadius;
72 SkPath mPath;
73};
74
75} /* namespace uirenderer */
76} /* namespace android */
77
78#endif /* REVEALCLIP_H */