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>
This commit is contained in:
Mike Reed 2017-05-10 14:13:20 -04:00 committed by Skia Commit-Bot
parent 6f9f2591c1
commit 14113bcc4e
7 changed files with 23 additions and 12 deletions

View File

@ -12,4 +12,5 @@ android_framework_defines = [
"SK_IGNORE_GPU_DITHER",
"SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
"SK_SUPPORT_LEGACY_EMBOSSMASKFILTER",
"SK_SUPPORT_DEPRECATED_CLIPOPS",
]

View File

@ -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

View File

@ -661,6 +661,7 @@ DEFINES_ALL = [
# Staging flags for API changes
# Temporarily Disable analytic AA for Google3
"SK_NO_ANALYTIC_AA",
"SK_SUPPORT_DEPRECATED_CLIPOPS",
]
################################################################################

View File

@ -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

View File

@ -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 @@ public:
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 @@ public:
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 @@ private:
void restoreTo(int saveCount);
inline bool hasClipRestriction(SkClipOp op) {
return op >= SkClipOp::kUnion_deprecated && !fClipRestrictionRect.isEmpty();
return op >= kUnion_SkClipOp && !fClipRestrictionRect.isEmpty();
}
/**

View File

@ -209,6 +209,7 @@ bool apply_clip(SkClipOp op, const SkPath& u, const SkPath& v, SkPath* r) {
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 @@ bool apply_clip(SkClipOp op, const SkPath& u, const SkPath& v, SkPath* r) {
case SkClipOp::kReplace_deprecated:
*r = v;
return true;
#endif
default:
return false;
}

View File

@ -130,6 +130,7 @@ static void test_restriction(skiatest::Reporter* reporter, SkCanvas* canvas) {
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 @@ static void test_restriction(skiatest::Reporter* reporter, SkCanvas* canvas) {
REPORTER_ASSERT(reporter, gBaseRestrictedR.contains(canvas->getDeviceClipBounds()));
canvas->restore();
}
#endif
}
/**