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

Commit 5b6591c1 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

fix issue when replacement bitmap is larger than original.

getTotalClip() returns the canvas bounds even if no explicit clip
was set. This CL fixes that issue by only transfering clips that
were explicitly set to the new canvas.

bug: 8255582
Change-Id: I0144d430e7718151ad93d988fcf20b412f74b256
parent c732976e
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -54,6 +54,21 @@ static uint32_t get_thread_msec() {

namespace android {

class ClipCopier : public SkCanvas::ClipVisitor {
public:
    ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {}

    virtual void clipRect(const SkRect& rect, SkRegion::Op op, bool antialias) {
        m_dstCanvas->clipRect(rect, op, antialias);
    }
    virtual void clipPath(const SkPath& path, SkRegion::Op op, bool antialias) {
        m_dstCanvas->clipPath(path, op, antialias);
    }

private:
    SkCanvas* m_dstCanvas;
};

class SkCanvasGlue {
public:

@@ -68,13 +83,15 @@ public:
    static void copyCanvasState(JNIEnv* env, jobject clazz,
                                SkCanvas* srcCanvas, SkCanvas* dstCanvas) {
        if (srcCanvas && dstCanvas) {
            dstCanvas->setMatrix(srcCanvas->getTotalMatrix());
            if (NULL != srcCanvas->getDevice() && NULL != dstCanvas->getDevice()) {
                dstCanvas->clipRegion(srcCanvas->getTotalClip());
                ClipCopier copier(dstCanvas);
                srcCanvas->replayClips(&copier);
            }
            dstCanvas->setMatrix(srcCanvas->getTotalMatrix());
        }
    }


    static void freeCaches(JNIEnv* env, jobject) {
        // these are called in no particular order
        SkImageRef_GlobalPool::SetRAMUsed(0);