void TileRenderer::startTileRendering(OpenGLRenderer* renderer,
                                      int left, int top,
                                      int right, int bottom) {
    int width = 0;
    int height = 0;
    GLenum status = GL_NO_ERROR;

    if (renderer != NULL) {
        renderer->getViewport(width, height);
    }

    if (!left && !right && !top && !bottom) {
        left = 0;
        top = 0;
        right = width;
        bottom = height;
    }

    if (!left && !right && !top && !bottom) {
        //can't do tile rendering
        LOGE("can't tile render; drity region, width, height not available");
        return;
    }

    int l = left, t = (height - bottom), w = (right - left), h = (bottom - top), preserve = 0;

    if (l < 0 || t < 0) {
        l = (l < 0) ? 0 : l;
        t = (t < 0) ? 0 : t;
        preserve = 1;
    }

    if (w > width || h > height) {
        w = (w > width) ? width : w;
        h = (h > height) ? height : h;
        preserve = 1;
    }

    //clear off all errors before tiling, if any
    while ((status = glGetError()) != GL_NO_ERROR);

    if (preserve)
        glStartTilingQCOM(l, t, w, h, GL_COLOR_BUFFER_BIT0_QCOM);
    else
        glStartTilingQCOM(l, t, w, h, GL_NONE);

    status = glGetError();
    if (status == GL_NO_ERROR)
        mIsTiled = true;
}
Esempio n. 2
0
void Caches::startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool opaque) {
    if (extensions.hasTiledRendering() && !debugOverdraw) {
        glStartTilingQCOM(x, y, width, height, (opaque ? GL_NONE : GL_COLOR_BUFFER_BIT0_QCOM));
    }
}