From: reed@google.com Date: Thu, 27 Feb 2014 14:27:44 +0000 (+0000) Subject: try to deprecate fFlagsMask from SkLayerDrawLooper X-Git-Tag: submit/tizen/20180928.044319~8853 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48f31bdbb3346e3003581229395022bf44828b13;p=platform%2Fupstream%2FlibSkiaSharp.git try to deprecate fFlagsMask from SkLayerDrawLooper We think we want to move around how flags/fields like linearText and strikeThru are specified. SkPaint has helpers for nearly all of these, but LayerInfo in the draw looper just exposes the raw bitfield. On survey of chrome/android, it appears that no one uses those, so it may be safe to just remove the feature entirely from the looper. R=bungeman@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/181433009 git-svn-id: http://skia.googlecode.com/svn/trunk@13607 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp index 2c8ea95f17..29c0080594 100644 --- a/bench/BlurRoundRectBench.cpp +++ b/bench/BlurRoundRectBench.cpp @@ -43,7 +43,6 @@ public: SkLayerDrawLooper* looper = new SkLayerDrawLooper; { SkLayerDrawLooper::LayerInfo info; - info.fFlagsMask = 0; info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit | SkLayerDrawLooper::kColorFilter_Bit; info.fColorMode = SkXfermode::kSrc_Mode; diff --git a/bench/RectoriBench.cpp b/bench/RectoriBench.cpp index e3bf41b78e..ee79ca9964 100644 --- a/bench/RectoriBench.cpp +++ b/bench/RectoriBench.cpp @@ -76,7 +76,6 @@ private: //----------------------------------------------- SkLayerDrawLooper::LayerInfo info; - info.fFlagsMask = 0; // TODO: add a color filter to better match what is seen in the wild info.fPaintBits = /* SkLayerDrawLooper::kColorFilter_Bit |*/ SkLayerDrawLooper::kMaskFilter_Bit; diff --git a/gm/blurroundrect.cpp b/gm/blurroundrect.cpp index 6a466c9c87..6c3903fd40 100644 --- a/gm/blurroundrect.cpp +++ b/gm/blurroundrect.cpp @@ -56,7 +56,6 @@ public: SkLayerDrawLooper* looper = new SkLayerDrawLooper; { SkLayerDrawLooper::LayerInfo info; - info.fFlagsMask = 0; info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit | SkLayerDrawLooper::kColorFilter_Bit; info.fColorMode = SkXfermode::kSrc_Mode; diff --git a/gm/drawlooper.cpp b/gm/drawlooper.cpp index 4cc6e8e369..678d2ad35f 100644 --- a/gm/drawlooper.cpp +++ b/gm/drawlooper.cpp @@ -39,6 +39,7 @@ protected: this->init(); SkPaint paint; + paint.setAntiAlias(true); paint.setTextSize(SkIntToScalar(72)); paint.setLooper(fLooper); @@ -74,14 +75,12 @@ private: fLooper = new SkLayerDrawLooper; SkLayerDrawLooper::LayerInfo info; - info.fFlagsMask = SkPaint::kAntiAlias_Flag; info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMaskFilter_Bit; info.fColorMode = SkXfermode::kSrc_Mode; for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); SkPaint* paint = fLooper->addLayer(info); - paint->setAntiAlias(true); paint->setColor(gParams[i].fColor); paint->setStyle(gParams[i].fStyle); paint->setStrokeWidth(gParams[i].fWidth); diff --git a/gm/megalooper.cpp b/gm/megalooper.cpp index 9a1de70dfa..12ccf2db5f 100644 --- a/gm/megalooper.cpp +++ b/gm/megalooper.cpp @@ -166,7 +166,6 @@ private: SkLayerDrawLooper* looper = new SkLayerDrawLooper; SkLayerDrawLooper::LayerInfo info; - info.fFlagsMask = 0; info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit | SkLayerDrawLooper::kMaskFilter_Bit; info.fColorMode = SkXfermode::kSrc_Mode; @@ -211,7 +210,6 @@ private: SkLayerDrawLooper* looper = new SkLayerDrawLooper; SkLayerDrawLooper::LayerInfo info; - info.fFlagsMask = 0; info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit | SkLayerDrawLooper::kMaskFilter_Bit; info.fColorMode = SkXfermode::kSrc_Mode; diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h index e1fae57cb8..c3ab241607 100644 --- a/include/effects/SkLayerDrawLooper.h +++ b/include/effects/SkLayerDrawLooper.h @@ -66,7 +66,9 @@ public: * kDst_Mode: to just keep the draw's color, ignoring the layer's */ struct SK_API LayerInfo { +#ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS uint32_t fFlagsMask; // SkPaint::Flags +#endif BitFlags fPaintBits; SkXfermode::Mode fColorMode; SkVector fOffset; diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index 49263fbbb5..cb60ff1e97 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -15,7 +15,9 @@ #include "SkUnPreMultiply.h" SkLayerDrawLooper::LayerInfo::LayerInfo() { - fFlagsMask = 0; // ignore our paint flags +#ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS + fFlagsMask = 0; // ignore layerinfo's paint flags +#endif fPaintBits = 0; // ignore our paint fields fColorMode = SkXfermode::kDst_Mode; // ignore our color fOffset.set(0, 0); @@ -102,8 +104,10 @@ static SkColor xferColor(SkColor src, SkColor dst, SkXfermode::Mode mode) { void SkLayerDrawLooper::ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo& info) { +#ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS uint32_t mask = info.fFlagsMask; dst->setFlags((dst->getFlags() & ~mask) | (src.getFlags() & mask)); +#endif dst->setColor(xferColor(src.getColor(), dst->getColor(), info.fColorMode)); BitFlags bits = info.fPaintBits; @@ -211,7 +215,11 @@ void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const { Rec* rec = fRecs; for (int i = 0; i < fCount; i++) { +#ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS buffer.writeInt(rec->fInfo.fFlagsMask); +#else + buffer.writeInt(0); // remove eventually, when we can bump the version +#endif buffer.writeInt(rec->fInfo.fPaintBits); buffer.writeInt(rec->fInfo.fColorMode); buffer.writePoint(rec->fInfo.fOffset); @@ -227,7 +235,11 @@ SkFlattenable* SkLayerDrawLooper::CreateProc(SkReadBuffer& buffer) { Builder builder; for (int i = 0; i < count; i++) { LayerInfo info; +#ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS info.fFlagsMask = buffer.readInt(); +#else + (void)buffer.readInt(); +#endif info.fPaintBits = buffer.readInt(); info.fColorMode = (SkXfermode::Mode)buffer.readInt(); buffer.readPoint(&info.fOffset); @@ -260,6 +272,7 @@ void SkLayerDrawLooper::toString(SkString* str) const { for (int i = 0; i < fCount; i++) { str->appendf("%d: ", i); +#ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS str->append("flagsMask: ("); if (0 == rec->fInfo.fFlagsMask) { str->append("None"); @@ -293,6 +306,7 @@ void SkLayerDrawLooper::toString(SkString* str) const { SkAddFlagToString(str, SkToBool(SkPaint::kGenA8FromLCD_Flag & rec->fInfo.fFlagsMask), "GenA8FromLCD", &needSeparator); } +#endif str->append(") "); str->append("paintBits: (");