Пример #1
0
void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &pt,
		bool flipped, int overrideColor) {
	Common::Rect drawRect(0, 0, src.w, src.h);
	Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h);

	// Clip the display area to on-screen
	if (!clip(drawRect, destRect))
		// It's completely off-screen
		return;

	if (flipped)
		drawRect = Common::Rect(src.w - drawRect.right, src.h - drawRect.bottom,
			src.w - drawRect.left, src.h - drawRect.top);

	Common::Point destPt(destRect.left, destRect.top);
	addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(),
		destPt.y + drawRect.height()));

	// Draw loop
	const int TRANSPARENCY = 0xFF;
	for (int yp = 0; yp < drawRect.height(); ++yp) {
		const byte *srcP = (const byte *)src.getBasePtr(
			flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp);
		byte *destP = (byte *)getBasePtr(destPt.x, destPt.y + yp);

		for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) {
			if (*srcP != TRANSPARENCY)
				*destP = overrideColor ? overrideColor : *srcP;

			srcP = flipped ? srcP - 1 : srcP + 1;
		}
	}
}
Пример #2
0
void Surface::transBlitFromUnscaled(const Graphics::Surface &src, const Common::Point &pt,
		bool flipped, int overrideColor) {
	Common::Rect drawRect(0, 0, src.w, src.h);
	Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h);

	// Clip the display area to on-screen
	if (!clip(drawRect, destRect))
		// It's completely off-screen
		return;

	if (flipped)
		drawRect = Common::Rect(src.w - drawRect.right, src.h - drawRect.bottom,
			src.w - drawRect.left, src.h - drawRect.top);

	Common::Point destPt(destRect.left, destRect.top);
	addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(),
		destPt.y + drawRect.height()));

	switch (src.format.bytesPerPixel) {
	case 1:
		// 8-bit palettized: Draw loop
		assert(_surface.format.bytesPerPixel == 1); // Security check
		for (int yp = 0; yp < drawRect.height(); ++yp) {
			const byte *srcP = (const byte *)src.getBasePtr(
				flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp);
			byte *destP = (byte *)getBasePtr(destPt.x, destPt.y + yp);

			for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) {
				if (*srcP != TRANSPARENCY)
					*destP = overrideColor ? overrideColor : *srcP;

				srcP = flipped ? srcP - 1 : srcP + 1;
			}
		}
		break;
	case 2:
		// 3DO 15-bit RGB565: Draw loop
		assert(_surface.format.bytesPerPixel == 2); // Security check
		for (int yp = 0; yp < drawRect.height(); ++yp) {
			const uint16 *srcP = (const uint16 *)src.getBasePtr(
				flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp);
			uint16 *destP = (uint16 *)getBasePtr(destPt.x, destPt.y + yp);

			for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) {
				if (*srcP) // RGB 0, 0, 0 -> transparent on 3DO
					*destP = *srcP; // overrideColor ? overrideColor : *srcP;

				srcP = flipped ? srcP - 1 : srcP + 1;
			}
		}
		break;
	default:
		error("Surface: unsupported bytesperpixel");
		break;
	}
}
Пример #3
0
void Scalpel3DOScreen::transBlitFromUnscaled(const Graphics::Surface &src, const Common::Point &pt,
		bool flipped, int overrideColor) {
	error("TODO: Refactor");
#if 0
	if (!_vm->_isScreenDoubled) {
		ScalpelScreen::transBlitFromUnscaled(src, pt, flipped, overrideColor);
		return;
	}

	Common::Rect drawRect(0, 0, src.w, src.h);
	Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h);

	// Clip the display area to on-screen
	if (!clip(drawRect, destRect))
		// It's completely off-screen
		return;

	if (flipped)
		drawRect = Common::Rect(src.w - drawRect.right, src.h - drawRect.bottom,
		src.w - drawRect.left, src.h - drawRect.top);

	Common::Point destPt(destRect.left, destRect.top);
	addDirtyRect(Common::Rect(destPt.x * 2, destPt.y * 2, (destPt.x + drawRect.width()) * 2,
		(destPt.y + drawRect.height()) * 2));

	assert(src.format.bytesPerPixel == 2 && _surface.format.bytesPerPixel == 2);

	for (int yp = 0; yp < drawRect.height(); ++yp) {
		const uint16 *srcP = (const uint16 *)src.getBasePtr(
			flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp);
		uint16 *destP = (uint16 *)getBasePtr(destPt.x * 2, (destPt.y + yp) * 2);

		for (int xp = 0; xp < drawRect.width(); ++xp, destP += 2) {
			// RGB 0, 0, 0 -> transparent on 3DO
			if (*srcP) {
				*destP = *srcP;
				*(destP + 1) = *srcP;
				*(destP + 640) = *srcP;
				*(destP + 640 + 1) = *srcP;
			}

			srcP = flipped ? srcP - 1 : srcP + 1;
		}
	}
#endif
}
Пример #4
0
void RenderRadio::paintObject(PaintInfo& i, int _tx, int _ty)
{
    ASSERT(node());
    Element* element = static_cast<Element*>(node());
    InputElement* inputElement = toInputElement(element);
    bool isEnabled = element->isEnabledFormControl();
    bool isChecked = inputElement->isChecked();
    
    i.context->save();

	RefPtr<Image> image = Image::loadPlatformResource( "radioButtonStates" ).get();
	IntPoint destPt( _tx, _ty );
	IntRect srcRect( 0, 0, 14, 16 );

    if (isEnabled)
	{
		if (node()->active())
		{
			if (isChecked)
			{
				srcRect.move( 75, 0 );
			}
			else
			{
				srcRect.move( 60, 0 );
			}
		}
		else if (node()->hovered())
		{
			if (isChecked)
			{
				srcRect.move( 45, 0 );
			}
			else
			{
				srcRect.move( 30, 0 );
			}
		}
		else
		{
			if (isChecked)
			{
				srcRect.move( 15, 0 );
			}
			else
			{
			}
		}
	}
	else 
	{
	    if (isChecked)
		{
			srcRect.move( 105, 0 );
		}
		else
		{
			srcRect.move( 90, 0 );
		}
	}

	i.context->drawImage( image.get(), DeviceColorSpace, destPt, srcRect ); 

    // draw the focus ring.
    //
    if (node()->focused())
    {
        IntRect focusRingSrcRect( 120, 0, 15, 17 );
        i.context->drawImage( image.get(), DeviceColorSpace, destPt, focusRingSrcRect ); 
    }

#if 0 
	// this is the old "moveto - lineto" drawing code

	IntRect checkRect(_tx + borderLeft()
                     , _ty + borderTop()
                     , width() - borderLeft() - borderRight()
                     , height() - borderBottom() - borderTop());
    Color fillColor(0xff, 0xff, 0xff, 0x00);
    Color rectColor(0x18, 0x52, 0x84);
    Color checkColor(0x21, 0xa5, 0x21);
    if (!node()->isEnabled()) {
        rectColor = Color(0xce, 0xce, 0xdb);
        checkColor = Color(0xce, 0xce, 0xdb);
    }
    i.context->setStrokeThickness(1);
    i.context->setStrokeStyle(SolidStroke);
    i.context->setStrokeColor(rectColor);
    i.context->setFillColor(fillColor);
    i.context->drawEllipse(checkRect);

    if(node()->isEnabled() && node()->hovered()) {
        i.context->setStrokeColor(Color(0xff, 0xb5, 0x31));
        
        IntRect hoverRect = checkRect;
        hoverRect.inflateX(-1);
        hoverRect.inflateY(-1);
        i.context->drawEllipse( hoverRect );
        hoverRect.inflateX(-1);
        hoverRect.inflateY(-1);
        i.context->drawEllipse( hoverRect );

    }

    if (isChecked) {
        i.context->setStrokeThickness(2);
        i.context->setStrokeColor(checkColor);
        i.context->setFillColor(checkColor);

        IntRect fillRect = checkRect;
        fillRect.inflateX(-2);
        fillRect.inflateY(-2);
        i.context->drawEllipse(fillRect);

    }
#endif

    i.context->restore();
}