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

Commit 18ca25be authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Generate even fewer GL commands"

parents 51a0e745 8f85e80b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1889,8 +1889,7 @@ public class Resources {
        if (cs != null) {
            dr = cs.newDrawable(this);
        } else {
            if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT &&
                    value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
            if (isColorDrawable) {
                dr = new ColorDrawable(value.data);
            }

+13 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ void Caches::init() {

    mTexCoordsArrayEnabled = false;

    mScissorX = mScissorY = mScissorWidth = mScissorHeight = 0;

    glActiveTexture(gTextureUnits[0]);
    mTextureUnit = 0;

@@ -312,6 +314,17 @@ void Caches::activeTexture(GLuint textureUnit) {
    }
}

void Caches::setScissor(GLint x, GLint y, GLint width, GLint height) {
    if (x != mScissorX || y != mScissorY || width != mScissorWidth || height != mScissorHeight) {
        glScissor(x, y, width, height);

        mScissorX = x;
        mScissorY = y;
        mScissorWidth = width;
        mScissorHeight = height;
    }
}

TextureVertex* Caches::getRegionMesh() {
    // Create the mesh, 2 triangles and 4 vertices per rectangle in the region
    if (!mRegionMesh) {
+10 −0
Original line number Diff line number Diff line
@@ -187,6 +187,11 @@ public:
     */
    void activeTexture(GLuint textureUnit);

    /**
     * Sets the scissor for the current surface.
     */
    void setScissor(GLint x, GLint y, GLint width, GLint height);

    /**
     * Returns the mesh used to draw regions. Calling this method will
     * bind a VBO of type GL_ELEMENT_ARRAY_BUFFER that contains the
@@ -240,6 +245,11 @@ private:

    GLuint mTextureUnit;

    GLint mScissorX;
    GLint mScissorY;
    GLint mScissorWidth;
    GLint mScissorHeight;

    // Used to render layers
    TextureVertex* mRegionMesh;
    GLuint mRegionMeshIndices;
+6 −3
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ void OpenGLRenderer::prepareDirty(float left, float top, float right, float bott
    mSaveCount = 1;

    glViewport(0, 0, mWidth, mHeight);
    glScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
    mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top);

    mSnapshot->setClip(left, top, right, bottom);
    mDirtyClip = false;
@@ -550,7 +550,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, sp<Snapshot> sna
#endif

    // Clear the FBO, expand the clear region by 1 to get nice bilinear filtering
    glScissor(clip.left - 1.0f, bounds.getHeight() - clip.bottom - 1.0f,
    mCaches.setScissor(clip.left - 1.0f, bounds.getHeight() - clip.bottom - 1.0f,
            clip.getWidth() + 2.0f, clip.getHeight() + 2.0f);
    glClear(GL_COLOR_BUFFER_BIT);

@@ -965,7 +965,10 @@ void OpenGLRenderer::concatMatrix(SkMatrix* matrix) {
void OpenGLRenderer::setScissorFromClip() {
    Rect clip(*mSnapshot->clipRect);
    clip.snapToPixelBoundaries();
    glScissor(clip.left, mSnapshot->height - clip.bottom, clip.getWidth(), clip.getHeight());

    mCaches.setScissor(clip.left, mSnapshot->height - clip.bottom,
            clip.getWidth(), clip.getHeight());

    mDirtyClip = false;
}

+9 −1
Original line number Diff line number Diff line
@@ -112,7 +112,8 @@ public:
    }

    bool intersect(float l, float t, float r, float b) {
        Rect tmp(intersectWith(l, t, r, b));
        Rect tmp(l, t, r, b);
        intersectWith(tmp);
        if (!tmp.isEmpty()) {
            set(tmp);
            return true;
@@ -173,6 +174,13 @@ private:
    static inline float min(float a, float b) { return (a < b) ? a : b; }
    static inline float max(float a, float b) { return (a > b) ? a : b; }

    void intersectWith(Rect& tmp) const {
        tmp.left = max(left, tmp.left);
        tmp.top = max(top, tmp.top);
        tmp.right = min(right, tmp.right);
        tmp.bottom = min(bottom, tmp.bottom);
    }

    Rect intersectWith(float l, float t, float r, float b) const {
        Rect tmp;
        tmp.left = max(left, l);