bug 908232 - step 1 - Refactor the WebGL state tracking - r=jgilbert

This commit is contained in:
Guillaume Abadie 2013-08-22 20:11:27 -04:00
Родитель 798009694e
Коммит e2f8566e17
2 изменённых файлов: 28 добавлений и 16 удалений

Просмотреть файл

@ -780,7 +780,12 @@ public:
bool IsEnabled(WebGLenum cap);
private:
// State tracking slots
realGLboolean mDitherEnabled;
realGLboolean mScissorTestEnabled;
bool ValidateCapabilityEnum(WebGLenum cap, const char* info);
realGLboolean* GetStateTrackingSlot(WebGLenum cap);
// -----------------------------------------------------------------------------
// Vertices Feature (WebGLContextVertices.cpp)
@ -1166,8 +1171,6 @@ protected:
mStencilWriteMaskFront, mStencilWriteMaskBack;
realGLboolean mColorWriteMask[4];
realGLboolean mDepthWriteMask;
realGLboolean mScissorTestEnabled;
realGLboolean mDitherEnabled;
WebGLfloat mColorClearValue[4];
WebGLint mStencilClearValue;
WebGLfloat mDepthClearValue;

Просмотреть файл

@ -25,13 +25,11 @@ WebGLContext::Disable(WebGLenum cap)
if (!ValidateCapabilityEnum(cap, "disable"))
return;
switch(cap) {
case LOCAL_GL_SCISSOR_TEST:
mScissorTestEnabled = 0;
break;
case LOCAL_GL_DITHER:
mDitherEnabled = 0;
break;
realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
if (trackingSlot)
{
*trackingSlot = 0;
}
MakeContextCurrent();
@ -47,13 +45,11 @@ WebGLContext::Enable(WebGLenum cap)
if (!ValidateCapabilityEnum(cap, "enable"))
return;
switch(cap) {
case LOCAL_GL_SCISSOR_TEST:
mScissorTestEnabled = 1;
break;
case LOCAL_GL_DITHER:
mDitherEnabled = 1;
break;
realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
if (trackingSlot)
{
*trackingSlot = 1;
}
MakeContextCurrent();
@ -547,3 +543,16 @@ WebGLContext::ValidateCapabilityEnum(WebGLenum cap, const char* info)
return false;
}
}
realGLboolean*
WebGLContext::GetStateTrackingSlot(WebGLenum cap)
{
switch (cap) {
case LOCAL_GL_SCISSOR_TEST:
return &mScissorTestEnabled;
case LOCAL_GL_DITHER:
return &mDitherEnabled;
}
return nullptr;
}