Ejemplo n.º 1
0
void QNanoPainter::enableHighQualityRendering(bool enable)
{
    GLNVGcontext *gl = static_cast<GLNVGcontext*>(nvgInternalParams(nvgCtx())->userPtr);
    if (gl) {
        if (enable) {
            gl->flags |= NVG_STENCIL_STROKES;
        } else {
            gl->flags &= ~NVG_STENCIL_STROKES;
        }
    }
}
Ejemplo n.º 2
0
void nvgluDeleteFramebuffer(NVGLUframebuffer* _framebuffer)
{
	if (_framebuffer == NULL)
	{
		return;
	}

	if (bgfx::isValid(_framebuffer->handle))
	{
		bgfx::destroy(_framebuffer->handle);
	}

	struct NVGparams* params = nvgInternalParams(_framebuffer->ctx);
	struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
	glnvg__deleteTexture(gl, _framebuffer->image);
	BX_DELETE(gl->allocator, _framebuffer);
}
Ejemplo n.º 3
0
// andrewmac:
int nvgCreateImageBGFX(struct NVGcontext* ctx, int w, int h, int imageFlags, bgfx::TextureHandle texture)
{
   struct NVGparams* params = nvgInternalParams(ctx);
   struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
   struct GLNVGtexture* tex = glnvg__allocTexture(gl);

   if (tex == NULL)
   {
      return 0;
   }

   tex->width = w;
   tex->height = h;
   tex->type = NVG_TEXTURE_RGBA;
   tex->flags = imageFlags;
   tex->id = texture;
   return tex->id.idx;
}
void QNanoQuickItemPainter::render()
{
    m_painter->reset(); // reset context data as painter is shared.
    // Update antialiasing if needed
    nvgInternalParams(m_painter->nvgCtx())->edgeAntiAlias = m_antialiasing;

    m_painter->setPixelAlign(static_cast<QNanoPainter::PixelAlign>(m_pixelAlign));
    m_painter->setPixelAlignText(static_cast<QNanoPainter::PixelAlign>(m_pixelAlignText));
    m_painter->m_devicePixelRatio = m_devicePixelRatio;

    // Draw only when item has visible size. This way setup and painting is
    // not called until size has been properly set.
    if ((m_itemWidth > 0 && m_itemHeight > 0) || m_setupDone) {
        m_setupDone = true;
        prepaint();
        paint(m_painter.data());
        postpaint();
    }
}
Ejemplo n.º 5
0
NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags)
{
	BX_UNUSED(_imageFlags);
	bgfx::TextureHandle textures[] =
	{
		bgfx::createTexture2D(_width, _height, false, 1, bgfx::TextureFormat::RGBA8, BGFX_TEXTURE_RT),
		bgfx::createTexture2D(_width, _height, false, 1, bgfx::TextureFormat::D24S8, BGFX_TEXTURE_RT | BGFX_TEXTURE_RT_WRITE_ONLY)
	};
	bgfx::FrameBufferHandle fbh = bgfx::createFrameBuffer(
		  BX_COUNTOF(textures)
		, textures
		, true
		);

	if (!bgfx::isValid(fbh) )
	{
		return NULL;
	}

	struct NVGparams* params = nvgInternalParams(_ctx);
	struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
	struct GLNVGtexture* tex = glnvg__allocTexture(gl);

	if (NULL == tex)
	{
		bgfx::destroy(fbh);
		return NULL;
	}

	tex->width  = _width;
	tex->height = _height;
	tex->type   = NVG_TEXTURE_RGBA;
	tex->flags  = _imageFlags | NVG_IMAGE_PREMULTIPLIED;
	tex->id     = bgfx::getTexture(fbh);

	NVGLUframebuffer* framebuffer = BX_NEW(gl->allocator, NVGLUframebuffer);
	framebuffer->ctx    = _ctx;
	framebuffer->image  = tex->id.idx;
	framebuffer->handle = fbh;

	return framebuffer;
}
Ejemplo n.º 6
0
void nvgViewId(struct NVGcontext* ctx, unsigned char viewid)
{
	struct NVGparams* params = nvgInternalParams(ctx);
	struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
	gl->viewid = uint8_t(viewid);
}
Ejemplo n.º 7
0
bgfx::TextureHandle nvglImageHandle(NVGcontext* _ctx, int32_t _image)
{
	GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(_ctx)->userPtr;
	GLNVGtexture* tex = glnvg__findTexture(gl, _image);
	return tex->id;
}
Ejemplo n.º 8
0
uint16_t nvgGetViewId(struct NVGcontext* _ctx)
{
	struct NVGparams* params = nvgInternalParams(_ctx);
	struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
	return gl->viewId;
}
Ejemplo n.º 9
0
void nvgSetViewId(struct NVGcontext* _ctx, bgfx::ViewId _viewId)
{
	struct NVGparams* params = nvgInternalParams(_ctx);
	struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
	gl->viewId = _viewId;
}