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

Commit 3d58c03d authored by Romain Guy's avatar Romain Guy
Browse files

Do not apply transforms when using drawColor().

This fixes an issue in the way the clip transformations were applied.

Change-Id: I91e7b5d15baf244d1280e48938282bb33609081d
parent 75608848
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ public:
    void copyTo(float* v) const;
    void copyTo(SkMatrix& v) const;

    /**
     * Does not apply rotations!
     */
    void mapRect(Rect& r) const;

    float getTranslateX();
+10 −5
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ bool OpenGLRenderer::quickReject(float left, float top, float right, float botto
}

bool OpenGLRenderer::clipRect(float left, float top, float right, float bottom) {
    bool clipped = mSnapshot->clipRect.intersect(left, top, right, bottom);
    bool clipped = mSnapshot->clip(left, top, right, bottom);
    if (clipped) {
        mSnapshot->flags |= Snapshot::kFlagClipSet;
        setScissorFromClip();
@@ -492,8 +492,8 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, Res_png_9patch* patch,
}

void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) {
    const Rect& clip = mSnapshot->clipRect;
    drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color, mode);
    const Rect& clip = mSnapshot->getMappedClip();
    drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color, mode, true);
}

void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, const SkPaint* p) {
@@ -524,7 +524,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom,
///////////////////////////////////////////////////////////////////////////////

void OpenGLRenderer::drawColorRect(float left, float top, float right, float bottom,
        int color, SkXfermode::Mode mode) {
        int color, SkXfermode::Mode mode, bool ignoreTransform) {
    const int alpha = (color >> 24) & 0xFF;
    const GLfloat a = alpha                  / 255.0f;
    const GLfloat r = ((color >> 16) & 0xFF) / 255.0f;
@@ -538,7 +538,12 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot
    mModelView.scale(right - left, bottom - top, 1.0f);

    const bool inUse = useShader(mDrawColorShader);
    if (!ignoreTransform) {
        mDrawColorShader->set(mOrthoMatrix, mModelView, mSnapshot->transform);
    } else {
        mat4 identity;
        mDrawColorShader->set(mOrthoMatrix, mModelView, identity);
    }

    if (!inUse) {
        const GLvoid* p = &gDrawColorVertices[0].position[0];
+2 −1
Original line number Diff line number Diff line
@@ -160,9 +160,10 @@ private:
     * @param bottom The bottom coordinate of the rectangle
     * @param color The rectangle's ARGB color, defined as a packed 32 bits word
     * @param mode The Skia xfermode to use
     * @param ignoreTransform True if the current transform should be ignored
     */
    void drawColorRect(float left, float top, float right, float bottom,
    		int color, SkXfermode::Mode mode);
    		int color, SkXfermode::Mode mode, bool ignoreTransform = false);

    /**
     * Draws a textured rectangle with the specified texture. The specified coordinates
+11 −1
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ public:
            previous(s),
            layer(NULL),
            fbo(s->fbo) {
        mappedClip.set(s->clipRect);
        transform.mapRect(mappedClip);
    }

    /**
@@ -87,12 +89,20 @@ public:
     * Returns the current clip region mapped by the current transform.
     */
    const Rect& getMappedClip() {
        return mappedClip;
    }

    /**
     * Intersects the current clip with the new clip rectangle.
     */
    bool clip(float left, float top, float right, float bottom) {
        bool clipped = clipRect.intersect(left, top, right, bottom);
        if (flags & kFlagDirtyTransform) {
            flags &= ~kFlagDirtyTransform;
            mappedClip.set(clipRect);
            transform.mapRect(mappedClip);
        }
        return mappedClip;
        return clipped;
    }

    /**
+9 −0
Original line number Diff line number Diff line
@@ -88,5 +88,14 @@
            </intent-filter>
        </activity>
        
        <activity
                android:name="RotationActivity"
                android:label="_Rotation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
                
    </application>
</manifest>
Loading