Esempio n. 1
0
void GraphicsContext::fillRect(const FloatRect& rect)
{
    if (paintingDisabled())
        return;

    CGContextRef context = platformContext();

    if (m_state.fillGradient) {
        CGContextSaveGState(context);
        CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
        if (hasShadow()) {
            CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(rect.width(), rect.height()), 0);
            CGContextRef layerContext = CGLayerGetContext(layer);
            m_state.fillGradient->paint(layerContext);
            CGContextDrawLayerAtPoint(context, CGPointMake(rect.left(), rect.top()), layer);
            CGLayerRelease(layer);
        } else {
            CGContextClipToRect(context, rect);
            m_state.fillGradient->paint(this);
        }
        CGContextRestoreGState(context);
        return;
    }

    if (m_state.fillPattern)
        applyFillPattern();
    CGContextFillRect(context, rect);
}
Esempio n. 2
0
bool GraphicsContext::getShadow(FloatSize& offset, float& blur, Color& color) const
{
    offset = m_state.shadowOffset;
    blur = m_state.shadowBlur;
    color = m_state.shadowColor;

    return hasShadow();
}
Esempio n. 3
0
QRect Toplevel::visibleRect() const
{
    QRect r = decorationRect();
    if (hasShadow() && !shadow()->shadowRegion().isEmpty()) {
        r |= shadow()->shadowRegion().boundingRect();
    }
    return r.translated(geometry().topLeft());
}
void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace)
{
    if (paintingDisabled())
        return;

    if (hasShadow())
        platformContext()->shadowBlur().drawRectShadow(this, rect, RoundedRect::Radii());

    fillRectWithColor(platformContext()->cr(), rect, color);
}
void GraphicsContext::restorePlatformState()
{
    if (paintingDisabled())
        return;

    platformContext()->restore();
    platformContext()->setFillColor(m_state.fillColor.rgb());
    if (hasShadow())
        setPlatformShadow(m_state.shadowOffset, m_state.shadowBlur, m_state.shadowColor, m_state.shadowColorSpace);
    else
        clearPlatformShadow();
    platformContext()->setStrokeColor(m_state.strokeColor.rgb());
    platformContext()->setStrokeStyle(static_cast<BlackBerry::Platform::Graphics::StrokeStyle>(m_state.strokeStyle));
    platformContext()->setStrokeThickness(m_state.strokeThickness);
    platformContext()->setTextDrawingMode(m_state.textDrawingMode);
}
void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace)
{
    if (paintingDisabled())
        return;

    if (hasShadow())
        platformContext()->shadowBlur().drawRectShadow(this, r, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));

    cairo_t* cr = platformContext()->cr();
    cairo_save(cr);
    Path path;
    path.addRoundedRect(r, topLeft, topRight, bottomLeft, bottomRight);
    appendWebCorePathToCairoContext(cr, path);
    setSourceRGBAFromColor(cr, color);
    cairo_fill(cr);
    cairo_restore(cr);
}
Esempio n. 7
0
void GraphicsContext::platformFillRoundedRect(const FloatRoundedRect& rect, const Color& color, ColorSpace)
{
    if (paintingDisabled())
        return;

    if (hasShadow())
        platformContext()->shadowBlur().drawRectShadow(this, rect);

    cairo_t* cr = platformContext()->cr();
    cairo_save(cr);
    Path path;
    path.addRoundedRect(rect);
    appendWebCorePathToCairoContext(cr, path);
    setSourceRGBAFromColor(cr, color);
    cairo_fill(cr);
    cairo_restore(cr);
}
Esempio n. 8
0
void MGui2d::draw(void)
{
	MRenderingContext * render = MGui::getInstance()->getRenderingContext();

	if(! isVisible())
		return;

	if(isPressed()) // pressed
	{  
		render->setColor4(getPressedColor());

		if(hasPressedTexture())
		{
			render->enableTexture();
			drawTexturedQuad(getPressedTexture());
		}
		else
		{
			render->disableTexture();
			drawQuad();
		} 
	}
	else if(isHighLight()) // highLight
	{
		render->setColor4(getHighLightColor());

		if(hasHighLightTexture()){
			render->enableTexture();
			drawTexturedQuad(getHighLightTexture());
		}
		else
		{
			render->disableTexture();
			drawQuad();
		}
	}
	else // normal	
	{
		render->setColor4(getNormalColor());

		if(hasNormalTexture())
		{
			render->enableTexture();
			drawTexturedQuad(getNormalTexture());
		}	  
		else
		{
			render->disableTexture();
			drawQuad();
		}
	}

	if(isDrawingText() && (getText() != NULL))
	{
		render->enableTexture();
		render->setColor4(getTextColor());
		getFont()->draw(getText(), getPosition(), getTextSize());
	}

	// draw shadows
	if(hasShadow())
	{
		render->pushMatrix();
		render->translate(MVector3(getPosition().x, getPosition().y, 0));

		drawShadow();

		render->popMatrix();
	}
}
Esempio n. 9
0
void MGuiWindow::draw(void)
{
	MRenderingContext * render = MGui::getInstance()->getRenderingContext();

	if(! isVisible())
		return;
	
	MWindow * window = MWindow::getInstance();

	rescaleScrollingBar();
	render->enableScissorTest();
	render->setScissor((int)getPosition().x, window->getHeight() - (int)getPosition().y - (unsigned int)getScale().y, (unsigned int)getScale().x, (unsigned int)getScale().y);

	// normal clear
	if((getNormalColor().w >= 1.0f) && (! hasNormalTexture()))
	{
		render->setClearColor(getNormalColor());
		render->clear(M_BUFFER_COLOR);

		MGuiEvent guiEvent;
		guiEvent.type = MGUI_EVENT_DRAW;

		if(m_pointerEvent)
			m_pointerEvent(this, &guiEvent);

		// 2d mode
		set2dMode(render);
		render->disableDepthTest();
		render->disableCullFace();
		render->disableLighting();
		render->enableBlending();
		render->setBlendingMode(M_BLENDING_ALPHA);
		render->enableTexture();
	}
	else
	{
		// background
		set2dMode(render);
		render->disableDepthTest();
		render->disableCullFace();
		render->disableLighting();
		render->enableBlending();
		render->setBlendingMode(M_BLENDING_ALPHA);

		if(hasNormalTexture()) // texture clear
		{
			render->enableTexture();
			render->setColor4(getNormalColor());
			drawTexturedQuad(getNormalTexture());
		}
		else if(getNormalColor().w < 1.0f)
		{
			render->disableTexture();
			render->setColor4(getNormalColor());
			drawQuad();
		}

		if(m_pointerEvent)
		{
			MGuiEvent guiEvent;
			guiEvent.type = MGUI_EVENT_DRAW;
			m_pointerEvent(this, &guiEvent);

			// 2d mode
			set2dMode(render);
			render->disableDepthTest();
			render->disableCullFace();
			render->disableLighting();
			render->enableBlending();
			render->setBlendingMode(M_BLENDING_ALPHA);
			render->enableTexture();
		}
	}

	// gui
	render->pushMatrix();
	render->translate(MVector3(getPosition().x, getPosition().y, 0));

	render->pushMatrix();
	render->translate(MVector3(getScroll().x, getScroll().y, 0));

	// drawing
	unsigned int i;
	unsigned int oSize = m_objects.size();
	for(i=0; i<oSize; i++)
		m_objects[i]->draw();

	render->popMatrix();

	// draw shadows
	if(hasShadow())
	{
		render->disableScissorTest();
		drawShadow();
		render->enableScissorTest();
	}

	// scolling slides
	if(isHorizontalScroll())
		m_hScrollSlide.draw();

	if(isVerticalScroll())
		m_vScrollSlide.draw();

	render->popMatrix();
}