Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc305269 authored by Ben Wagner's avatar Ben Wagner Committed by Android (Google) Code Review
Browse files

Merge "Remove use of SkTLazy."

parents b3d3dd21 1d155336
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@

#include <SkPicture.h>
#include <SkRefCnt.h>
#include <SkTLazy.h>

#include <optional>

namespace android {

@@ -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();
@@ -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};
@@ -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) {
+4 −2
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@
#include "SkiaPipeline.h"
#include "utils/TraceUtils.h"

#include <optional>

namespace android {
namespace uirenderer {
namespace skiapipeline {
@@ -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;