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

Commit c1469f39 authored by John Reck's avatar John Reck
Browse files

DO NOT MERGE Copy shaders

 Bug: 16733996

Change-Id: I84afc1b24a23dd6ddf5ab48fb2bfcbe779f8d3e3
parent 0db4f35e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ static void Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle, jl
        } else {
            shader->resetLocalMatrix();
        }
        shader->setGenerationID(shader->getGenerationID() + 1);
    }
}

+17 −4
Original line number Diff line number Diff line
@@ -205,11 +205,17 @@ private:
        if (!paint) return NULL;

        const SkPaint* paintCopy = mPaintMap.valueFor(paint);
        if (paintCopy == NULL || paintCopy->getGenerationID() != paint->getGenerationID()) {
            paintCopy = new SkPaint(*paint);
        if (paintCopy == NULL
                || paintCopy->getGenerationID() != paint->getGenerationID()
                // We can't compare shader pointers because that will always
                // change as we do partial copying via wrapping. However, if the
                // shader changes the paint generationID will have changed and
                // so we don't hit this comparison anyway
                || !(paint->getShader() && paintCopy->getShader()
                        && paint->getShader()->getGenerationID() == paintCopy->getShader()->getGenerationID())) {
            paintCopy = copyPaint(paint);
            // replaceValueFor() performs an add if the entry doesn't exist
            mPaintMap.replaceValueFor(paint, paintCopy);
            mDisplayListData->paints.add(paintCopy);
        }

        return paintCopy;
@@ -218,8 +224,15 @@ private:
    inline SkPaint* copyPaint(const SkPaint* paint) {
        if (!paint) return NULL;
        SkPaint* paintCopy = new SkPaint(*paint);
        if (paint->getShader()) {
            SkShader* shaderCopy = SkShader::CreateLocalMatrixShader(
                    paint->getShader(), paint->getShader()->getLocalMatrix());
            paintCopy->setShader(shaderCopy);
            paintCopy->setGenerationID(paint->getGenerationID());
            shaderCopy->setGenerationID(paint->getShader()->getGenerationID());
            shaderCopy->unref();
        }
        mDisplayListData->paints.add(paintCopy);

        return paintCopy;
    }