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

Commit 71c10ee8 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Switch several enums to enum classes"

parents d7ba5795 b9ce116d
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@ BaseRenderNodeAnimator::BaseRenderNodeAnimator(float finalValue)
        , mFinalValue(finalValue)
        , mDeltaValue(0)
        , mFromValue(0)
        , mStagingPlayState(NOT_STARTED)
        , mPlayState(NOT_STARTED)
        , mStagingPlayState(PlayState::NotStarted)
        , mPlayState(PlayState::NotStarted)
        , mHasStartValue(false)
        , mStartTime(0)
        , mDuration(300)
@@ -50,7 +50,7 @@ BaseRenderNodeAnimator::~BaseRenderNodeAnimator() {

void BaseRenderNodeAnimator::checkMutable() {
    // Should be impossible to hit as the Java-side also has guards for this
    LOG_ALWAYS_FATAL_IF(mStagingPlayState != NOT_STARTED,
    LOG_ALWAYS_FATAL_IF(mStagingPlayState != PlayState::NotStarted,
            "Animator has already been started!");
}

@@ -92,9 +92,9 @@ void BaseRenderNodeAnimator::pushStaging(AnimationContext& context) {
    if (mStagingPlayState > mPlayState) {
        mPlayState = mStagingPlayState;
        // Oh boy, we're starting! Man the battle stations!
        if (mPlayState == RUNNING) {
        if (mPlayState == PlayState::Running) {
            transitionToRunning(context);
        } else if (mPlayState == FINISHED) {
        } else if (mPlayState == PlayState::Finished) {
            callOnFinishedListener(context);
        }
    }
@@ -124,10 +124,10 @@ void BaseRenderNodeAnimator::transitionToRunning(AnimationContext& context) {
}

bool BaseRenderNodeAnimator::animate(AnimationContext& context) {
    if (mPlayState < RUNNING) {
    if (mPlayState < PlayState::Running) {
        return false;
    }
    if (mPlayState == FINISHED) {
    if (mPlayState == PlayState::Finished) {
        return true;
    }

@@ -141,18 +141,18 @@ bool BaseRenderNodeAnimator::animate(AnimationContext& context) {
    }

    float fraction = 1.0f;
    if (mPlayState == RUNNING && mDuration > 0) {
    if (mPlayState == PlayState::Running && mDuration > 0) {
        fraction = (float)(context.frameTimeMs() - mStartTime) / mDuration;
    }
    if (fraction >= 1.0f) {
        fraction = 1.0f;
        mPlayState = FINISHED;
        mPlayState = PlayState::Finished;
    }

    fraction = mInterpolator->interpolate(fraction);
    setValue(mTarget, mFromValue + (mDeltaValue * fraction));

    if (mPlayState == FINISHED) {
    if (mPlayState == PlayState::Finished) {
        callOnFinishedListener(context);
        return true;
    }
@@ -161,8 +161,8 @@ bool BaseRenderNodeAnimator::animate(AnimationContext& context) {
}

void BaseRenderNodeAnimator::forceEndNow(AnimationContext& context) {
    if (mPlayState < FINISHED) {
        mPlayState = FINISHED;
    if (mPlayState < PlayState::Finished) {
        mPlayState = PlayState::Finished;
        callOnFinishedListener(context);
    }
}
@@ -212,9 +212,9 @@ void RenderPropertyAnimator::onAttached() {
}

void RenderPropertyAnimator::onStagingPlayStateChanged() {
    if (mStagingPlayState == RUNNING) {
    if (mStagingPlayState == PlayState::Running) {
        (mTarget->mutateStagingProperties().*mPropertyAccess->setter)(finalValue());
    } else if (mStagingPlayState == FINISHED) {
    } else if (mStagingPlayState == PlayState::Finished) {
        // We're being canceled, so make sure that whatever values the UI thread
        // is observing for us is pushed over
        mTarget->setPropertyFieldsDirty(dirtyMask());
+10 −10
Original line number Diff line number Diff line
@@ -59,8 +59,8 @@ public:
        mMayRunAsync = mayRunAsync;
    }
    bool mayRunAsync() { return mMayRunAsync; }
    ANDROID_API void start() { mStagingPlayState = RUNNING; onStagingPlayStateChanged(); }
    ANDROID_API void end() { mStagingPlayState = FINISHED; onStagingPlayStateChanged(); }
    ANDROID_API void start() { mStagingPlayState = PlayState::Running; onStagingPlayStateChanged(); }
    ANDROID_API void end() { mStagingPlayState = PlayState::Finished; onStagingPlayStateChanged(); }

    void attach(RenderNode* target);
    virtual void onAttached() {}
@@ -68,8 +68,8 @@ public:
    void pushStaging(AnimationContext& context);
    bool animate(AnimationContext& context);

    bool isRunning() { return mPlayState == RUNNING; }
    bool isFinished() { return mPlayState == FINISHED; }
    bool isRunning() { return mPlayState == PlayState::Running; }
    bool isFinished() { return mPlayState == PlayState::Finished; }
    float finalValue() { return mFinalValue; }

    ANDROID_API virtual uint32_t dirtyMask() = 0;
@@ -77,6 +77,12 @@ public:
    void forceEndNow(AnimationContext& context);

protected:
    enum class PlayState {
        NotStarted,
        Running,
        Finished,
    };

    BaseRenderNodeAnimator(float finalValue);
    virtual ~BaseRenderNodeAnimator();

@@ -88,12 +94,6 @@ protected:

    virtual void onStagingPlayStateChanged() {}

    enum PlayState {
        NOT_STARTED,
        RUNNING,
        FINISHED,
    };

    RenderNode* mTarget;

    float mFinalValue;
+3 −3
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ void Caches::flush(FlushMode mode) {
    FLUSH_LOGD("Flushing caches (mode %d)", mode);

    switch (mode) {
        case kFlushMode_Full:
        case FlushMode::Full:
            textureCache.clear();
            patchCache.clear();
            dropShadowCache.clear();
@@ -254,13 +254,13 @@ void Caches::flush(FlushMode mode) {
            fboCache.clear();
            dither.clear();
            // fall through
        case kFlushMode_Moderate:
        case FlushMode::Moderate:
            fontRenderer->flush();
            textureCache.flush();
            pathCache.clear();
            tessellationCache.clear();
            // fall through
        case kFlushMode_Layers:
        case FlushMode::Layers:
            layerCache.clear();
            renderBufferCache.clear();
            break;
+5 −5
Original line number Diff line number Diff line
@@ -83,10 +83,10 @@ private:
    static Caches* sInstance;

public:
    enum FlushMode {
        kFlushMode_Layers = 0,
        kFlushMode_Moderate,
        kFlushMode_Full
    enum class FlushMode {
        Layers = 0,
        Moderate,
        Full
    };

    /**
@@ -103,7 +103,7 @@ public:

    /**
     * Destroys all resources associated with this cache. This should
     * be called after a flush(kFlushMode_Full).
     * be called after a flush(FlushMode::Full).
     */
    void terminate();

+3 −3
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ void GlopBuilder::setFill(int color, float alphaScale,
        SkXfermode::Mode mode;
        SkScalar srcColorMatrix[20];
        if (colorFilter->asColorMode(&color, &mode)) {
            mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::kColorBlend;
            mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Blend;
            mDescription.colorMode = mode;

            const float alpha = SkColorGetA(color) / 255.0f;
@@ -286,7 +286,7 @@ void GlopBuilder::setFill(int color, float alphaScale,
                    alpha,
            };
        } else if (colorFilter->asColorMatrix(srcColorMatrix)) {
            mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::kColorMatrix;
            mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Matrix;

            float* colorMatrix = mOutGlop->fill.filter.matrix.matrix;
            memcpy(colorMatrix, srcColorMatrix, 4 * sizeof(float));
@@ -305,7 +305,7 @@ void GlopBuilder::setFill(int color, float alphaScale,
            LOG_ALWAYS_FATAL("unsupported ColorFilter");
        }
    } else {
        mOutGlop->fill.filterMode = ProgramDescription::kColorNone;
        mOutGlop->fill.filterMode = ProgramDescription::ColorFilterMode::None;
    }
}

Loading