Loading libs/hwui/hwui/AnimatedImageDrawable.cpp +10 −9 Original line number Diff line number Diff line Loading @@ -21,7 +21,8 @@ #include <SkPicture.h> #include <SkRefCnt.h> #include <SkTLazy.h> #include <optional> namespace android { Loading Loading @@ -126,13 +127,13 @@ AnimatedImageDrawable::Snapshot AnimatedImageDrawable::reset() { // Only called on the RenderThread. void AnimatedImageDrawable::onDraw(SkCanvas* canvas) { SkTLazy<SkPaint> lazyPaint; std::optional<SkPaint> lazyPaint; SkAutoCanvasRestore acr(canvas, false); if (mProperties.mAlpha != SK_AlphaOPAQUE || mProperties.mColorFilter.get()) { lazyPaint.init(); lazyPaint.get()->setAlpha(mProperties.mAlpha); lazyPaint.get()->setColorFilter(mProperties.mColorFilter); lazyPaint.get()->setFilterQuality(kLow_SkFilterQuality); lazyPaint.emplace(); lazyPaint->setAlpha(mProperties.mAlpha); lazyPaint->setColorFilter(mProperties.mColorFilter); lazyPaint->setFilterQuality(kLow_SkFilterQuality); } if (mProperties.mMirrored) { canvas->save(); Loading @@ -147,8 +148,8 @@ void AnimatedImageDrawable::onDraw(SkCanvas* canvas) { if (drawDirectly) { // The image is not animating, and never was. Draw directly from // mSkAnimatedImage. if (lazyPaint.isValid()) { canvas->saveLayer(mSkAnimatedImage->getBounds(), lazyPaint.get()); if (lazyPaint) { canvas->saveLayer(mSkAnimatedImage->getBounds(), &*lazyPaint); } std::unique_lock lock{mImageLock}; Loading Loading @@ -193,7 +194,7 @@ void AnimatedImageDrawable::onDraw(SkCanvas* canvas) { if (!drawDirectly) { // No other thread will modify mCurrentSnap so this should be safe to // use without locking. canvas->drawPicture(mSnapshot.mPic, nullptr, lazyPaint.getMaybeNull()); canvas->drawPicture(mSnapshot.mPic, nullptr, lazyPaint ? &*lazyPaint : nullptr); } if (finalFrame) { Loading libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ #include "SkiaPipeline.h" #include "utils/TraceUtils.h" #include <optional> namespace android { namespace uirenderer { namespace skiapipeline { Loading Loading @@ -171,9 +173,9 @@ public: protected: bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type t) const override { SkTLazy<SkPaint> defaultPaint; std::optional<SkPaint> defaultPaint; if (!*paint) { paint->init(*defaultPaint.init()); paint->init(defaultPaint.emplace()); } paint->writable()->setAlpha((uint8_t)(*paint)->getAlpha() * mAlpha); return true; Loading Loading
libs/hwui/hwui/AnimatedImageDrawable.cpp +10 −9 Original line number Diff line number Diff line Loading @@ -21,7 +21,8 @@ #include <SkPicture.h> #include <SkRefCnt.h> #include <SkTLazy.h> #include <optional> namespace android { Loading Loading @@ -126,13 +127,13 @@ AnimatedImageDrawable::Snapshot AnimatedImageDrawable::reset() { // Only called on the RenderThread. void AnimatedImageDrawable::onDraw(SkCanvas* canvas) { SkTLazy<SkPaint> lazyPaint; std::optional<SkPaint> lazyPaint; SkAutoCanvasRestore acr(canvas, false); if (mProperties.mAlpha != SK_AlphaOPAQUE || mProperties.mColorFilter.get()) { lazyPaint.init(); lazyPaint.get()->setAlpha(mProperties.mAlpha); lazyPaint.get()->setColorFilter(mProperties.mColorFilter); lazyPaint.get()->setFilterQuality(kLow_SkFilterQuality); lazyPaint.emplace(); lazyPaint->setAlpha(mProperties.mAlpha); lazyPaint->setColorFilter(mProperties.mColorFilter); lazyPaint->setFilterQuality(kLow_SkFilterQuality); } if (mProperties.mMirrored) { canvas->save(); Loading @@ -147,8 +148,8 @@ void AnimatedImageDrawable::onDraw(SkCanvas* canvas) { if (drawDirectly) { // The image is not animating, and never was. Draw directly from // mSkAnimatedImage. if (lazyPaint.isValid()) { canvas->saveLayer(mSkAnimatedImage->getBounds(), lazyPaint.get()); if (lazyPaint) { canvas->saveLayer(mSkAnimatedImage->getBounds(), &*lazyPaint); } std::unique_lock lock{mImageLock}; Loading Loading @@ -193,7 +194,7 @@ void AnimatedImageDrawable::onDraw(SkCanvas* canvas) { if (!drawDirectly) { // No other thread will modify mCurrentSnap so this should be safe to // use without locking. canvas->drawPicture(mSnapshot.mPic, nullptr, lazyPaint.getMaybeNull()); canvas->drawPicture(mSnapshot.mPic, nullptr, lazyPaint ? &*lazyPaint : nullptr); } if (finalFrame) { Loading
libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ #include "SkiaPipeline.h" #include "utils/TraceUtils.h" #include <optional> namespace android { namespace uirenderer { namespace skiapipeline { Loading Loading @@ -171,9 +173,9 @@ public: protected: bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type t) const override { SkTLazy<SkPaint> defaultPaint; std::optional<SkPaint> defaultPaint; if (!*paint) { paint->init(*defaultPaint.init()); paint->init(defaultPaint.emplace()); } paint->writable()->setAlpha((uint8_t)(*paint)->getAlpha() * mAlpha); return true; Loading