Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 956401 - 9/9 - Optimization: cache the scissor rect in GLContext …
Browse files Browse the repository at this point in the history
…- r=vladv
  • Loading branch information
Benoit Jacob committed Jan 7, 2014
1 parent a84b743 commit 18faf22
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions gfx/gl/GLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)

if (mInitialized) {
raw_fGetIntegerv(LOCAL_GL_VIEWPORT, mViewportRect);
raw_fGetIntegerv(LOCAL_GL_SCISSOR_BOX, mScissorRect);
raw_fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
raw_fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mMaxCubeMapTextureSize);
raw_fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mMaxRenderbufferSize);
Expand Down
18 changes: 18 additions & 0 deletions gfx/gl/GLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,12 @@ class GLContext
}
break;

case LOCAL_GL_SCISSOR_BOX:
for (size_t i = 0; i < 4; i++) {
params[i] = mScissorRect[i];
}
break;

default:
raw_fGetIntegerv(pname, params);
break;
Expand Down Expand Up @@ -1403,6 +1409,17 @@ class GLContext
}

void fScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
if (mScissorRect[0] == x &&
mScissorRect[1] == y &&
mScissorRect[2] == width &&
mScissorRect[3] == height)
{
return;
}
mScissorRect[0] = x;
mScissorRect[1] = y;
mScissorRect[2] = width;
mScissorRect[3] = height;
BEFORE_GL_CALL;
mSymbols.fScissor(x, y, width, height);
AFTER_GL_CALL;
Expand Down Expand Up @@ -2789,6 +2806,7 @@ class GLContext
void InitExtensions();

GLint mViewportRect[4];
GLint mScissorRect[4];

GLint mMaxTextureSize;
GLint mMaxCubeMapTextureSize;
Expand Down

0 comments on commit 18faf22

Please sign in to comment.