add flag to hide deprecated clipops
needs this to land first
https://codereview.chromium.org/2877493002/#
Bug: skia:3191
Change-Id: Iff5271064877c4e96353d3564464f513eaad0bb5
Reviewed-on: https://skia-review.googlesource.com/16365
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/gn/android_framework_defines.gni b/gn/android_framework_defines.gni
index 67c6a2d..ed49000 100644
--- a/gn/android_framework_defines.gni
+++ b/gn/android_framework_defines.gni
@@ -12,4 +12,5 @@
"SK_IGNORE_GPU_DITHER",
"SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
"SK_SUPPORT_LEGACY_EMBOSSMASKFILTER",
+ "SK_SUPPORT_DEPRECATED_CLIPOPS",
]
diff --git a/include/core/SkClipOp.h b/include/core/SkClipOp.h
index f230654..6ae16a8 100644
--- a/include/core/SkClipOp.h
+++ b/include/core/SkClipOp.h
@@ -10,20 +10,24 @@
#include "SkTypes.h"
-// SkClipOp enum values always match the corresponding values in SkRegion::Op
-
enum class SkClipOp {
kDifference = 0,
kIntersect = 1,
- // Goal: remove these, since they can grow the current clip
-
+#ifdef SK_SUPPORT_DEPRECATED_CLIPOPS
kUnion_deprecated = 2,
kXOR_deprecated = 3,
kReverseDifference_deprecated = 4,
kReplace_deprecated = 5,
+#else
+ kExtraEnumNeedInternallyPleaseIgnoreWillGoAway2 = 2,
+ kExtraEnumNeedInternallyPleaseIgnoreWillGoAway3 = 3,
+ kExtraEnumNeedInternallyPleaseIgnoreWillGoAway4 = 4,
+ kExtraEnumNeedInternallyPleaseIgnoreWillGoAway5 = 5,
+#endif
- kMax_EnumValue = kReplace_deprecated,
+ // Used internally for validation, can only shrink to 1 when the deprecated flag is gone
+ kMax_EnumValue = 5,
};
#endif
diff --git a/public.bzl b/public.bzl
index 1813af0..e798809 100644
--- a/public.bzl
+++ b/public.bzl
@@ -661,6 +661,7 @@
# Staging flags for API changes
# Temporarily Disable analytic AA for Google3
"SK_NO_ANALYTIC_AA",
+ "SK_SUPPORT_DEPRECATED_CLIPOPS",
]
################################################################################
diff --git a/src/core/SkClipOpPriv.h b/src/core/SkClipOpPriv.h
index 21695b9..a90f59d 100644
--- a/src/core/SkClipOpPriv.h
+++ b/src/core/SkClipOpPriv.h
@@ -13,9 +13,9 @@
const SkClipOp kDifference_SkClipOp = SkClipOp::kDifference;
const SkClipOp kIntersect_SkClipOp = SkClipOp::kIntersect;
-const SkClipOp kUnion_SkClipOp = SkClipOp::kUnion_deprecated;
-const SkClipOp kXOR_SkClipOp = SkClipOp::kXOR_deprecated;
-const SkClipOp kReverseDifference_SkClipOp = SkClipOp::kReverseDifference_deprecated;
-const SkClipOp kReplace_SkClipOp = SkClipOp::kReplace_deprecated;
+const SkClipOp kUnion_SkClipOp = (SkClipOp)2;
+const SkClipOp kXOR_SkClipOp = (SkClipOp)3;
+const SkClipOp kReverseDifference_SkClipOp = (SkClipOp)4;
+const SkClipOp kReplace_SkClipOp = (SkClipOp)5;
#endif
diff --git a/src/core/SkClipStack.h b/src/core/SkClipStack.h
index 98cec07..4502ecd 100644
--- a/src/core/SkClipStack.h
+++ b/src/core/SkClipStack.h
@@ -10,6 +10,7 @@
#include "../private/SkMessageBus.h"
#include "SkCanvas.h"
+#include "SkClipOpPriv.h"
#include "SkDeque.h"
#include "SkPath.h"
#include "SkRRect.h"
@@ -57,7 +58,7 @@
static const int kTypeCnt = kLastType + 1;
Element() {
- this->initCommon(0, SkClipOp::kReplace_deprecated, false);
+ this->initCommon(0, kReplace_SkClipOp, false);
this->setEmpty();
}
@@ -245,7 +246,7 @@
mutable SkTArray<std::unique_ptr<GrUniqueKeyInvalidatedMessage>> fMessages;
#endif
Element(int saveCount) {
- this->initCommon(saveCount, SkClipOp::kReplace_deprecated, false);
+ this->initCommon(saveCount, kReplace_SkClipOp, false);
this->setEmpty();
}
@@ -560,7 +561,7 @@
void restoreTo(int saveCount);
inline bool hasClipRestriction(SkClipOp op) {
- return op >= SkClipOp::kUnion_deprecated && !fClipRestrictionRect.isEmpty();
+ return op >= kUnion_SkClipOp && !fClipRestrictionRect.isEmpty();
}
/**
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 781e2c7..4014101 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -209,6 +209,7 @@
return Op(u, v, kDifference_SkPathOp, r);
case SkClipOp::kIntersect:
return Op(u, v, kIntersect_SkPathOp, r);
+#ifdef SK_SUPPORT_DEPRECATED_CLIPOPS
case SkClipOp::kUnion_deprecated:
return Op(u, v, kUnion_SkPathOp, r);
case SkClipOp::kXOR_deprecated:
@@ -218,6 +219,7 @@
case SkClipOp::kReplace_deprecated:
*r = v;
return true;
+#endif
default:
return false;
}
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index b304a0d..e64f5e9 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -130,6 +130,7 @@
canvas->clipRect(SkRect::Make(clipR), SkClipOp::kIntersect);
REPORTER_ASSERT(reporter, canvas->getDeviceClipBounds() == clipR);
+#ifdef SK_SUPPORT_DEPRECATED_CLIPOPS
// now test that expanding clipops can't exceed the restriction
const SkClipOp expanders[] = {
SkClipOp::kUnion_deprecated,
@@ -147,6 +148,7 @@
REPORTER_ASSERT(reporter, gBaseRestrictedR.contains(canvas->getDeviceClipBounds()));
canvas->restore();
}
+#endif
}
/**