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

Commit a3193677 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Change setScissor() to take in Vulkan coordinate convention."

parents 4298ea30 05483a0c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ cc_defaults {
        "libhwbinder",
        "liblayers_proto",
        "liblog",
    	"libnativewindow",
        "libpdx_default_transport",
        "libprotobuf-cpp-lite",
        "libsync",
+2 −2
Original line number Diff line number Diff line
@@ -543,8 +543,8 @@ void DisplayDevice::setDisplaySize(const int newWidth, const int newHeight) {

    ANativeWindow* const window = mNativeWindow.get();
    mSurface->setNativeWindow(window);
    mDisplayWidth = mSurface->queryWidth();
    mDisplayHeight = mSurface->queryHeight();
    mDisplayWidth = mSurface->getWidth();
    mDisplayHeight = mSurface->getHeight();

    LOG_FATAL_IF(mDisplayWidth != newWidth,
                "Unable to set new width to %d", newWidth);
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ cc_defaults {
        "libGLESv2",
        "libgui",
        "liblog",
    	"libnativewindow",
        "libui",
        "libutils",
    ],
+14 −3
Original line number Diff line number Diff line
@@ -444,12 +444,17 @@ bool GLES20RenderEngine::setCurrentSurface(const Surface& surface) {
        if (success && glSurface.getAsync()) {
            eglSwapInterval(mEGLDisplay, 0);
        }
        if (success) {
            mSurfaceHeight = glSurface.getHeight();
        }
    }

    return success;
}

void GLES20RenderEngine::resetCurrentSurface() {
    eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    mSurfaceHeight = 0;
}

base::unique_fd GLES20RenderEngine::flush() {
@@ -563,8 +568,12 @@ void GLES20RenderEngine::fillRegionWithColor(const Region& region, float red, fl
    drawMesh(mesh);
}

void GLES20RenderEngine::setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) {
    glScissor(left, bottom, right, top);
void GLES20RenderEngine::setScissor(const Rect& region) {
    // Invert y-coordinate to map to GL-space.
    int32_t canvasHeight = mRenderToFbo ? mFboHeight : mSurfaceHeight;
    int32_t glBottom = canvasHeight - region.bottom;

    glScissor(region.left, glBottom, region.getWidth(), region.getHeight());
    glEnable(GL_SCISSOR_TEST);
}

@@ -612,6 +621,7 @@ status_t GLES20RenderEngine::bindFrameBuffer(Framebuffer* framebuffer) {
                           GL_TEXTURE_2D, textureName, 0);

    mRenderToFbo = true;
    mFboHeight = glFramebuffer->getBufferHeight();

    uint32_t glStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);

@@ -623,13 +633,14 @@ status_t GLES20RenderEngine::bindFrameBuffer(Framebuffer* framebuffer) {

void GLES20RenderEngine::unbindFrameBuffer(Framebuffer* /* framebuffer */) {
    mRenderToFbo = false;
    mFboHeight = 0;

    // back to main framebuffer
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    // Workaround for b/77935566 to force the EGL driver to release the
    // screenshot buffer
    setScissor(0, 0, 0, 0);
    setScissor(Rect::EMPTY_RECT);
    clearWithColor(0.0, 0.0, 0.0, 0.0);
    disableScissor();
}
+3 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public:
    void clearWithColor(float red, float green, float blue, float alpha) override;
    void fillRegionWithColor(const Region& region, float red, float green, float blue,
                             float alpha) override;
    void setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) override;
    void setScissor(const Rect& region) override;
    void disableScissor() override;
    void genTextures(size_t count, uint32_t* names) override;
    void deleteTextures(size_t count, uint32_t const* names) override;
@@ -139,6 +139,8 @@ private:
    mat4 mXyzToBt2020;

    bool mRenderToFbo = false;
    int32_t mSurfaceHeight = 0;
    int32_t mFboHeight = 0;

    // Current dataspace of layer being rendered
    ui::Dataspace mDataSpace = ui::Dataspace::UNKNOWN;
Loading