Revert "Hide setDrawLooper -- deprecate loopers"

This reverts commit c877ea2657.

Reason for revert: wow, this is going to be really hard to update callers

Original change's description:
> Hide setDrawLooper -- deprecate loopers
> 
> Guarded with SK_SUPPORT_LEGACY_DRAWLOOPER
> 
> Bug: skia:4783
> Change-Id: I4a47513624bc5c09816f44e107917dc8028adb94
> Reviewed-on: https://skia-review.googlesource.com/c/189871
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
> Auto-Submit: Mike Reed <reed@google.com>

TBR=reed@google.com

Change-Id: Ia49f421c8a96a8091ab87533361fde4bf570d6e4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:4783
Reviewed-on: https://skia-review.googlesource.com/c/190303
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-02-07 19:00:28 +00:00 committed by Skia Commit-Bot
parent 2c27b65438
commit 8619a34bb8
18 changed files with 0 additions and 61 deletions

View File

@ -62,9 +62,7 @@ public:
dullPaint.setAntiAlias(true); dullPaint.setAntiAlias(true);
SkPaint loopedPaint; SkPaint loopedPaint;
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
loopedPaint.setLooper(looperBuilder.detach()); loopedPaint.setLooper(looperBuilder.detach());
#endif
loopedPaint.setAntiAlias(true); loopedPaint.setAntiAlias(true);
loopedPaint.setColor(SK_ColorCYAN); loopedPaint.setColor(SK_ColorCYAN);

View File

@ -52,9 +52,7 @@ protected:
SkScalar translate = 2.0f * size; SkScalar translate = 2.0f * size;
SkPaint paint; SkPaint paint;
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(this->createLooper(-translate, blurSigma)); paint.setLooper(this->createLooper(-translate, blurSigma));
#endif
paint.setColor(0xff000000 | Random.nextU()); paint.setColor(0xff000000 | Random.nextU());
paint.setAntiAlias(true); paint.setAntiAlias(true);

View File

@ -69,9 +69,7 @@ public:
SkPaint paint; SkPaint paint;
canvas->drawRect(fRRect.rect(), paint); canvas->drawRect(fRRect.rect(), paint);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(looperBuilder.detach()); paint.setLooper(looperBuilder.detach());
#endif
paint.setColor(SK_ColorCYAN); paint.setColor(SK_ColorCYAN);
paint.setAntiAlias(true); paint.setAntiAlias(true);

View File

@ -70,7 +70,6 @@ protected:
fPaints.push_back(p); fPaints.push_back(p);
} }
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
{ {
// AA with blur // AA with blur
SkPaint p; SkPaint p;
@ -80,7 +79,6 @@ protected:
SkIntToScalar(5), SkIntToScalar(10))); SkIntToScalar(5), SkIntToScalar(10)));
fPaints.push_back(p); fPaints.push_back(p);
} }
#endif
{ {
// AA with stroke style // AA with stroke style

View File

@ -37,9 +37,7 @@ protected:
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); paint.setAntiAlias(true);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(fLooper); paint.setLooper(fLooper);
#endif
SkFont font(sk_tool_utils::create_portable_typeface(), 72); SkFont font(sk_tool_utils::create_portable_typeface(), 72);

View File

@ -130,9 +130,7 @@ private:
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
SkPaint loopPaint; SkPaint loopPaint;
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
loopPaint.setLooper(create1Looper(-kOffsetToOutsideClip, 0, gColors[i])); loopPaint.setLooper(create1Looper(-kOffsetToOutsideClip, 0, gColors[i]));
#endif
loopPaint.setAntiAlias(true); loopPaint.setAntiAlias(true);
SkRect outerClip = { SkRect outerClip = {
@ -193,9 +191,7 @@ private:
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); paint.setAntiAlias(true);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(create4Looper(-kOffsetToOutsideClip-kHalfSquareSize, 0)); paint.setLooper(create4Looper(-kOffsetToOutsideClip-kHalfSquareSize, 0));
#endif
canvas->save(); canvas->save();
canvas->clipRect(outerClip, kIntersect_SkClipOp); canvas->clipRect(outerClip, kIntersect_SkClipOp);

View File

@ -85,7 +85,6 @@ protected:
fPaints.push_back(p); fPaints.push_back(p);
} }
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
{ {
// AA with blur // AA with blur
SkPaint p; SkPaint p;
@ -96,7 +95,6 @@ protected:
SkIntToScalar(5), SkIntToScalar(10))); SkIntToScalar(5), SkIntToScalar(10)));
fPaints.push_back(p); fPaints.push_back(p);
} }
#endif
{ {
// AA with stroke style // AA with stroke style

View File

@ -88,9 +88,7 @@ protected:
for (size_t i = 0; i < SK_ARRAY_COUNT(shadowLoopers); ++i) { for (size_t i = 0; i < SK_ARRAY_COUNT(shadowLoopers); ++i) {
SkAutoCanvasRestore acr(canvas, true); SkAutoCanvasRestore acr(canvas, true);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(shadowLoopers[i]); paint.setLooper(shadowLoopers[i]);
#endif
canvas->translate(SkIntToScalar((unsigned int)i*40), SkIntToScalar(0)); canvas->translate(SkIntToScalar((unsigned int)i*40), SkIntToScalar(0));
setup(&paint, gRec[0].fColor, gRec[0].fStrokeWidth); setup(&paint, gRec[0].fColor, gRec[0].fStrokeWidth);

View File

@ -230,9 +230,7 @@ protected:
int y = 0; int y = 0;
for (int looper = 0; looper < fLoopers.count(); looper++) { for (int looper = 0; looper < fLoopers.count(); looper++) {
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(fLoopers[looper]); paint.setLooper(fLoopers[looper]);
#endif
canvas->save(); canvas->save();
canvas->translate(0, SkIntToScalar(y)); canvas->translate(0, SkIntToScalar(y));
canvas->drawTextBlob(fBlob, 0, 0, paint); canvas->drawTextBlob(fBlob, 0, 0, paint);

View File

@ -561,7 +561,6 @@ public:
*/ */
SkDrawLooper* getLooper() const { return fDrawLooper.get(); } SkDrawLooper* getLooper() const { return fDrawLooper.get(); }
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
/** Sets SkDrawLooper to drawLooper, decreasing SkRefCnt of the previous /** Sets SkDrawLooper to drawLooper, decreasing SkRefCnt of the previous
drawLooper. Pass nullptr to clear SkDrawLooper and leave SkDrawLooper effect on drawLooper. Pass nullptr to clear SkDrawLooper and leave SkDrawLooper effect on
drawing unaltered. drawing unaltered.
@ -576,7 +575,6 @@ public:
(see skbug.com/6259) (see skbug.com/6259)
*/ */
void setLooper(sk_sp<SkDrawLooper> drawLooper); void setLooper(sk_sp<SkDrawLooper> drawLooper);
#endif
/** Returns true if SkPaint prevents all drawing; /** Returns true if SkPaint prevents all drawing;
otherwise, the SkPaint may or may not allow drawing. otherwise, the SkPaint may or may not allow drawing.

View File

@ -107,9 +107,7 @@ protected:
SkPaint p; SkPaint p;
SkString str; SkString str;
p.setDither(true); p.setDither(true);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
p.setLooper(fLooper); p.setLooper(fLooper);
#endif
str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
SkTextUtils::DrawString(textCanvas, str.c_str(), x + r.width()/2, y, SkFont(), p, SkTextUtils::DrawString(textCanvas, str.c_str(), x + r.width()/2, y, SkFont(), p,
@ -141,9 +139,7 @@ protected:
} }
if (textCanvas) { if (textCanvas) {
SkPaint p; SkPaint p;
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
p.setLooper(fLooper); p.setLooper(fLooper);
#endif
textCanvas->drawString( textCanvas->drawString(
SkStringPrintf("%s, %s", gConfigNames[i], gFilterNames[j]), SkStringPrintf("%s, %s", gConfigNames[i], gFilterNames[j]),
x, y + r.height() * 2 / 3, SkFont(), p); x, y + r.height() * 2 / 3, SkFont(), p);

View File

@ -81,9 +81,7 @@ protected:
auto looper( auto looper(
SkBlurDrawLooper::Make(SK_ColorBLUE, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2)), SkBlurDrawLooper::Make(SK_ColorBLUE, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2)),
0, 0)); 0, 0));
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(looper); paint.setLooper(looper);
#endif
SkScalar height = font.getMetrics(nullptr); SkScalar height = font.getMetrics(nullptr);
if (!fDecodeSucceeded) { if (!fDecodeSucceeded) {
SkString failure; SkString failure;

View File

@ -472,10 +472,8 @@ bool AutoDrawLooper::doNext() {
SkPaint* paint = fLazyPaintPerLooper.set(fLazyPaintInit.isValid() ? SkPaint* paint = fLazyPaintPerLooper.set(fLazyPaintInit.isValid() ?
*fLazyPaintInit.get() : fOrigPaint); *fLazyPaintInit.get() : fOrigPaint);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
// never want our downstream clients (i.e. devices) to see loopers // never want our downstream clients (i.e. devices) to see loopers
paint->setDrawLooper(nullptr); paint->setDrawLooper(nullptr);
#endif
if (fTempLayerForImageFilter) { if (fTempLayerForImageFilter) {
paint->setImageFilter(nullptr); paint->setImageFilter(nullptr);

View File

@ -169,11 +169,9 @@ SkPaint SkColorSpaceXformer::apply(const SkPaint& src) {
dst.setColorFilter(this->apply(cf)); dst.setColorFilter(this->apply(cf));
} }
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
if (auto looper = src.getDrawLooper()) { if (auto looper = src.getDrawLooper()) {
dst.setDrawLooper(looper->makeColorSpace(this)); dst.setDrawLooper(looper->makeColorSpace(this));
} }
#endif
if (auto imageFilter = src.getImageFilter()) { if (auto imageFilter = src.getImageFilter()) {
dst.setImageFilter(this->apply(imageFilter)); dst.setImageFilter(this->apply(imageFilter));

View File

@ -20,9 +20,7 @@ bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const {
for (;;) { for (;;) {
SkPaint p(paint); SkPaint p(paint);
if (context->next(&canvas, &p)) { if (context->next(&canvas, &p)) {
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
p.setLooper(nullptr); p.setLooper(nullptr);
#endif
if (!p.canComputeFastBounds()) { if (!p.canComputeFastBounds()) {
return false; return false;
} }
@ -49,9 +47,7 @@ void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& s,
if (context->next(&canvas, &p)) { if (context->next(&canvas, &p)) {
SkRect r(src); SkRect r(src);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
p.setLooper(nullptr); p.setLooper(nullptr);
#endif
p.computeFastBounds(r, &r); p.computeFastBounds(r, &r);
canvas.getTotalMatrix().mapRect(&r); canvas.getTotalMatrix().mapRect(&r);

View File

@ -243,14 +243,9 @@ MOVE_FIELD(Shader)
MOVE_FIELD(ColorFilter) MOVE_FIELD(ColorFilter)
MOVE_FIELD(PathEffect) MOVE_FIELD(PathEffect)
MOVE_FIELD(MaskFilter) MOVE_FIELD(MaskFilter)
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
MOVE_FIELD(DrawLooper) MOVE_FIELD(DrawLooper)
#endif
#undef MOVE_FIELD #undef MOVE_FIELD
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
void SkPaint::setLooper(sk_sp<SkDrawLooper> looper) { fDrawLooper = std::move(looper); } void SkPaint::setLooper(sk_sp<SkDrawLooper> looper) { fDrawLooper = std::move(looper); }
#endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -454,20 +449,14 @@ SkReadPaintResult SkPaintPriv::Unflatten_PreV68(SkPaint* paint, SkReadBuffer& bu
paint->setMaskFilter(buffer.readMaskFilter()); paint->setMaskFilter(buffer.readMaskFilter());
paint->setColorFilter(buffer.readColorFilter()); paint->setColorFilter(buffer.readColorFilter());
(void)buffer.read32(); // use to be SkRasterizer (void)buffer.read32(); // use to be SkRasterizer
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint->setLooper(buffer.readDrawLooper()); paint->setLooper(buffer.readDrawLooper());
#else
(void)buffer.readDrawLooper();
#endif
paint->setImageFilter(buffer.readImageFilter()); paint->setImageFilter(buffer.readImageFilter());
} else { } else {
paint->setPathEffect(nullptr); paint->setPathEffect(nullptr);
paint->setShader(nullptr); paint->setShader(nullptr);
paint->setMaskFilter(nullptr); paint->setMaskFilter(nullptr);
paint->setColorFilter(nullptr); paint->setColorFilter(nullptr);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint->setLooper(nullptr); paint->setLooper(nullptr);
#endif
paint->setImageFilter(nullptr); paint->setImageFilter(nullptr);
} }
@ -500,20 +489,14 @@ SkReadPaintResult SkPaintPriv::Unflatten(SkPaint* paint, SkReadBuffer& buffer, S
paint->setShader(buffer.readShader()); paint->setShader(buffer.readShader());
paint->setMaskFilter(buffer.readMaskFilter()); paint->setMaskFilter(buffer.readMaskFilter());
paint->setColorFilter(buffer.readColorFilter()); paint->setColorFilter(buffer.readColorFilter());
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint->setLooper(buffer.readDrawLooper()); paint->setLooper(buffer.readDrawLooper());
#else
(void)buffer.readDrawLooper();
#endif
paint->setImageFilter(buffer.readImageFilter()); paint->setImageFilter(buffer.readImageFilter());
} else { } else {
paint->setPathEffect(nullptr); paint->setPathEffect(nullptr);
paint->setShader(nullptr); paint->setShader(nullptr);
paint->setMaskFilter(nullptr); paint->setMaskFilter(nullptr);
paint->setColorFilter(nullptr); paint->setColorFilter(nullptr);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint->setLooper(nullptr); paint->setLooper(nullptr);
#endif
paint->setImageFilter(nullptr); paint->setImageFilter(nullptr);
} }

View File

@ -135,9 +135,7 @@ DEF_TEST(Paint_copy, reporter) {
paint.setStrokeWidth(SkIntToScalar(2)); paint.setStrokeWidth(SkIntToScalar(2));
// set a few pointers // set a few pointers
SkLayerDrawLooper::Builder looperBuilder; SkLayerDrawLooper::Builder looperBuilder;
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(looperBuilder.detach()); paint.setLooper(looperBuilder.detach());
#endif
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(1))); SkBlurMask::ConvertRadiusToSigma(1)));
@ -265,9 +263,7 @@ DEF_TEST(Paint_MoreFlattening, r) {
SkPaint paint; SkPaint paint;
paint.setColor(0x00AABBCC); paint.setColor(0x00AABBCC);
paint.setBlendMode(SkBlendMode::kModulate); paint.setBlendMode(SkBlendMode::kModulate);
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
paint.setLooper(nullptr); // Default value, ignored. paint.setLooper(nullptr); // Default value, ignored.
#endif
SkBinaryWriteBuffer writer; SkBinaryWriteBuffer writer;
SkPaintPriv::Flatten(paint, writer); SkPaintPriv::Flatten(paint, writer);

View File

@ -80,7 +80,6 @@ static void test_drawBitmap(skiatest::Reporter* reporter) {
canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint);
REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5)); REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5));
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
// now install our looper, which will draw, since it internally translates // now install our looper, which will draw, since it internally translates
// to the left. The test is to ensure that canvas' quickReject machinary // to the left. The test is to ensure that canvas' quickReject machinary
// allows us through, even though sans-looper we would look like we should // allows us through, even though sans-looper we would look like we should
@ -88,7 +87,6 @@ static void test_drawBitmap(skiatest::Reporter* reporter) {
paint.setLooper(sk_make_sp<TestLooper>()); paint.setLooper(sk_make_sp<TestLooper>());
canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint);
REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5));
#endif
} }
static void test_layers(skiatest::Reporter* reporter) { static void test_layers(skiatest::Reporter* reporter) {
@ -173,7 +171,6 @@ DEF_TEST(QuickReject_MatrixState, reporter) {
canvas.quickReject(SkRect::MakeWH(100.0f, 100.0f)); canvas.quickReject(SkRect::MakeWH(100.0f, 100.0f));
} }
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
#include "SkLayerDrawLooper.h" #include "SkLayerDrawLooper.h"
#include "SkSurface.h" #include "SkSurface.h"
DEF_TEST(looper_nothingtodraw, reporter) { DEF_TEST(looper_nothingtodraw, reporter) {
@ -199,4 +196,3 @@ DEF_TEST(looper_nothingtodraw, reporter) {
// See https://skia-review.googlesource.com/c/skia/+/121220 // See https://skia-review.googlesource.com/c/skia/+/121220
surf->getCanvas()->drawRect({1, 1, 10, 10}, paint); surf->getCanvas()->drawRect({1, 1, 10, 10}, paint);
} }
#endif