summaryrefslogtreecommitdiff
path: root/libs/hwui/SkiaCanvas.cpp
diff options
context:
space:
mode:
author Ryan Prichard <rprichard@google.com> 2022-08-26 20:53:33 -0700
committer Ryan Prichard <rprichard@google.com> 2022-08-26 20:55:52 -0700
commit3997155120f3313cc58f953ef15f8dfbe1f9ee9f (patch)
tree9fc26cd7900eabbf814f686b71c63cc84ef9da24 /libs/hwui/SkiaCanvas.cpp
parente648d3cb91f9a0156c729ca18ec27e71f59f9ce2 (diff)
Move SkiaCanvas::Clip above SkiaCanvas::SkiaCanvas
After upgrading libc++, there are errors complaining about the the incomplete Clip type in the "std::vector<Clip> mClipStack" member of SkiaCanvas. The "SkiaCanvas::SkiaCanvas() {}" ctor can call ~vector (maybe when an exception is thrown), and ~vector needs to know the size of Clip. (I'm not sure why this wasn't a problem before, but this seems to fix the problem.) Bug: http://b/175635923 Test: treehugger Change-Id: I1d689c91be3b0530272836eeb727709ff1084545
Diffstat (limited to 'libs/hwui/SkiaCanvas.cpp')
-rw-r--r--libs/hwui/SkiaCanvas.cpp86
1 files changed, 43 insertions, 43 deletions
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 53c6db0cdf3a..f9b3a8c12b2e 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -51,6 +51,49 @@ namespace android {
using uirenderer::PaintUtils;
+class SkiaCanvas::Clip {
+public:
+ Clip(const SkRect& rect, SkClipOp op, const SkMatrix& m)
+ : mType(Type::Rect), mOp(op), mMatrix(m), mRRect(SkRRect::MakeRect(rect)) {}
+ Clip(const SkRRect& rrect, SkClipOp op, const SkMatrix& m)
+ : mType(Type::RRect), mOp(op), mMatrix(m), mRRect(rrect) {}
+ Clip(const SkPath& path, SkClipOp op, const SkMatrix& m)
+ : mType(Type::Path), mOp(op), mMatrix(m), mPath(std::in_place, path) {}
+
+ void apply(SkCanvas* canvas) const {
+ canvas->setMatrix(mMatrix);
+ switch (mType) {
+ case Type::Rect:
+ // Don't anti-alias rectangular clips
+ canvas->clipRect(mRRect.rect(), mOp, false);
+ break;
+ case Type::RRect:
+ // Ensure rounded rectangular clips are anti-aliased
+ canvas->clipRRect(mRRect, mOp, true);
+ break;
+ case Type::Path:
+ // Ensure path clips are anti-aliased
+ canvas->clipPath(mPath.value(), mOp, true);
+ break;
+ }
+ }
+
+private:
+ enum class Type {
+ Rect,
+ RRect,
+ Path,
+ };
+
+ Type mType;
+ SkClipOp mOp;
+ SkMatrix mMatrix;
+
+ // These are logically a union (tracked separately due to non-POD path).
+ std::optional<SkPath> mPath;
+ SkRRect mRRect;
+};
+
Canvas* Canvas::create_canvas(const SkBitmap& bitmap) {
return new SkiaCanvas(bitmap);
}
@@ -194,49 +237,6 @@ void SkiaCanvas::restoreUnclippedLayer(int restoreCount, const Paint& paint) {
}
}
-class SkiaCanvas::Clip {
-public:
- Clip(const SkRect& rect, SkClipOp op, const SkMatrix& m)
- : mType(Type::Rect), mOp(op), mMatrix(m), mRRect(SkRRect::MakeRect(rect)) {}
- Clip(const SkRRect& rrect, SkClipOp op, const SkMatrix& m)
- : mType(Type::RRect), mOp(op), mMatrix(m), mRRect(rrect) {}
- Clip(const SkPath& path, SkClipOp op, const SkMatrix& m)
- : mType(Type::Path), mOp(op), mMatrix(m), mPath(std::in_place, path) {}
-
- void apply(SkCanvas* canvas) const {
- canvas->setMatrix(mMatrix);
- switch (mType) {
- case Type::Rect:
- // Don't anti-alias rectangular clips
- canvas->clipRect(mRRect.rect(), mOp, false);
- break;
- case Type::RRect:
- // Ensure rounded rectangular clips are anti-aliased
- canvas->clipRRect(mRRect, mOp, true);
- break;
- case Type::Path:
- // Ensure path clips are anti-aliased
- canvas->clipPath(mPath.value(), mOp, true);
- break;
- }
- }
-
-private:
- enum class Type {
- Rect,
- RRect,
- Path,
- };
-
- Type mType;
- SkClipOp mOp;
- SkMatrix mMatrix;
-
- // These are logically a union (tracked separately due to non-POD path).
- std::optional<SkPath> mPath;
- SkRRect mRRect;
-};
-
const SkiaCanvas::SaveRec* SkiaCanvas::currentSaveRec() const {
const SaveRec* rec = mSaveStack ? static_cast<const SaveRec*>(mSaveStack->back()) : nullptr;
int currentSaveCount = mCanvas->getSaveCount();