| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#ifndef REVEALCLIP_H |
| 17 |
#define REVEALCLIP_H |
| 18 |
|
| 19 |
#include <SkPath.h> |
| 20 |
|
| 21 |
#include "Rect.h" |
| 22 |
|
| 23 |
namespace android { |
| 24 |
namespace uirenderer { |
| 25 |
|
| 26 |
class RevealClip { |
| 27 |
public: |
| 28 |
RevealClip() : mShouldClip(false), mX(0), mY(0), mRadius(0) {} |
| 29 |
|
| 30 |
void set(bool shouldClip, float x, float y, float radius) { |
| 31 |
mShouldClip = shouldClip; |
| 32 |
mX = x; |
| 33 |
mY = y; |
| 34 |
mRadius = radius; |
| 35 |
|
| 36 |
mPath.rewind(); |
| 37 |
if (mShouldClip) { |
| 38 |
mPath.addCircle(x, y, radius); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
bool willClip() const { return mShouldClip; } |
| 43 |
|
| 44 |
void getBounds(Rect* outBounds) const { |
| 45 |
outBounds->set(mX - mRadius, mY - mRadius, mX + mRadius, mY + mRadius); |
| 46 |
} |
| 47 |
|
| 48 |
float getRadius() const { return mRadius; } |
| 49 |
float getX() const { return mX; } |
| 50 |
float getY() const { return mY; } |
| 51 |
|
| 52 |
const SkPath* getPath() const { |
| 53 |
if (!mShouldClip) return nullptr; |
| 54 |
|
| 55 |
return &mPath; |
| 56 |
} |
| 57 |
|
| 58 |
private: |
| 59 |
bool mShouldClip; |
| 60 |
float mX; |
| 61 |
float mY; |
| 62 |
float mRadius; |
| 63 |
SkPath mPath; |
| 64 |
}; |
| 65 |
|
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
#endif |