示例#1
0
文件: GL.cpp 项目: vvuk/mc-nvpr
void
GL::EnableStencilTest(BinaryStencilTest aTest,
                      GLint aComparand, GLuint aTestMask,
                      StencilOperation aOp, GLuint aWriteMask)
{
  MOZ_ASSERT(IsCurrent());

  if (!mStencilTestEnabled) {
    Enable(GL_STENCIL_TEST);
    mStencilTestEnabled = true;
  }

  if (mStencilTest != aTest || mStencilComparand != aComparand
      || mStencilTestMask != aTestMask) {
    GLenum func;
    switch (aTest) {
      default:
        MOZ_ASSERT(!"Invalid stencil test");
      case ALWAYS_PASS:
        func = GL_ALWAYS;
        break;
      case PASS_IF_EQUAL:
        func = GL_EQUAL;
        break;
      case PASS_IF_NOT_EQUAL:
        func = GL_NOTEQUAL;
        break;
    }

    StencilFunc(func, aComparand, aTestMask);

    mStencilTest = aTest;
    mStencilComparand = aComparand;
    mStencilTestMask = aTestMask;
  }

  if (mStencilOp != aOp) {
    switch (aOp) {
      case LEAVE_UNCHANGED:
        StencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
        break;
      case CLEAR_PASSING_VALUES:
        StencilOp(GL_KEEP, GL_ZERO, GL_ZERO);
        break;
      case REPLACE_PASSING_WITH_COMPARAND:
        StencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
        break;
      case REPLACE_PASSING_CLEAR_FAILING:
        StencilOp(GL_ZERO, GL_REPLACE, GL_REPLACE);
        break;
    }

    mStencilOp = aOp;
  }

  if (mStencilWriteMask != aWriteMask) {
    StencilMask(aWriteMask);
    mStencilWriteMask = aWriteMask;
  }
}
示例#2
0
bool SkOSWindow::attachANGLE(int msaaSampleCount, AttachmentInfo* info) {
    if (EGL_NO_DISPLAY == fDisplay) {
        bool bResult = create_ANGLE((HWND)fHWND,
                                    msaaSampleCount,
                                    &fDisplay,
                                    &fContext,
                                    &fSurface,
                                    &fConfig);
        if (false == bResult) {
            return false;
        }
        SkAutoTUnref<const GrGLInterface> intf(GrGLCreateANGLEInterface());

        if (intf) {
            ANGLE_GL_CALL(intf, ClearStencil(0));
            ANGLE_GL_CALL(intf, ClearColor(0, 0, 0, 0));
            ANGLE_GL_CALL(intf, StencilMask(0xffffffff));
            ANGLE_GL_CALL(intf, Clear(GL_STENCIL_BUFFER_BIT |GL_COLOR_BUFFER_BIT));
        }
    }
    if (eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
        eglGetConfigAttrib(fDisplay, fConfig, EGL_STENCIL_SIZE, &info->fStencilBits);
        eglGetConfigAttrib(fDisplay, fConfig, EGL_SAMPLES, &info->fSampleCount);

        SkAutoTUnref<const GrGLInterface> intf(GrGLCreateANGLEInterface());

        if (intf ) {
            ANGLE_GL_CALL(intf, Viewport(0, 0,
                                         SkScalarRoundToInt(this->width()),
                                         SkScalarRoundToInt(this->height())));
        }
        return true;
    }
    return false;
}
示例#3
0
bool SkOSWindow::attachANGLE(int msaaSampleCount, AttachmentInfo* info) {
    if (EGL_NO_DISPLAY == fDisplay) {
        bool bResult = create_ANGLE((HWND)fHWND,
                                    msaaSampleCount,
                                    &fDisplay,
                                    &fContext,
                                    &fSurface,
                                    &fConfig);
        if (false == bResult) {
            return false;
        }
        fANGLEInterface.reset(get_angle_gl_interface());
        if (!fANGLEInterface) {
            this->detachANGLE();
            return false;
        }
        GL_CALL(fANGLEInterface, ClearStencil(0));
        GL_CALL(fANGLEInterface, ClearColor(0, 0, 0, 0));
        GL_CALL(fANGLEInterface, StencilMask(0xffffffff));
        GL_CALL(fANGLEInterface, Clear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT));
    }
    if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
        this->detachANGLE();
        return false;
    }
    eglGetConfigAttrib(fDisplay, fConfig, EGL_STENCIL_SIZE, &info->fStencilBits);
    eglGetConfigAttrib(fDisplay, fConfig, EGL_SAMPLES, &info->fSampleCount);

    GL_CALL(fANGLEInterface, Viewport(0, 0, SkScalarRoundToInt(this->width()),
                                      SkScalarRoundToInt(this->height())));
    return true;
}
示例#4
0
bool SkOSWindow::attachCommandBuffer(int msaaSampleCount, AttachmentInfo* info) {
    if (!fCommandBuffer) {
        fCommandBuffer = SkCommandBufferGLContext::Create((HWND)fHWND, msaaSampleCount);
        if (!fCommandBuffer)
            return false;

        SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface());
        if (intf) {
            GL_CALL(intf, ClearStencil(0));
            GL_CALL(intf, ClearColor(0, 0, 0, 0));
            GL_CALL(intf, StencilMask(0xffffffff));
            GL_CALL(intf, Clear(GL_STENCIL_BUFFER_BIT |GL_COLOR_BUFFER_BIT));
        }
    }

    if (fCommandBuffer->makeCurrent()) {
        info->fStencilBits = fCommandBuffer->getStencilBits();
        info->fSampleCount = fCommandBuffer->getSampleCount();

        SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface());

        if (intf ) {
            GL_CALL(intf, Viewport(0, 0, SkScalarRoundToInt(this->width()),
                                         SkScalarRoundToInt(this->height())));
        }
        return true;
    }
    return false;
}
示例#5
0
StencilMask *StencilMask::getOrCreate(uint frontMask, uint backMask)
{
    return getOrCreateImpl(StencilMask(frontMask, backMask));
}