Ejemplo n.º 1
0
void DrasculaEngine::reduce_hare_chico(int xx1, int yy1, int xx2, int yy2, int width, int height, int factor, byte *dir_inicio, byte *dir_fin) {
	float totalX, totalY;
	int n, m;
	float pixelX, pixelY;

	newWidth = (width * factor) / 100;
	newHeight = (height * factor) / 100;

	totalX = width / newWidth;
	totalY = height / newHeight;

	pixelX = xx1;
	pixelY = yy1;

	for (n = 0; n < newHeight; n++) {
		for (m = 0; m < newWidth; m++) {
			copyRect((int)pixelX, (int)pixelY, xx2 + m, yy2 + n,
					 1, 1, dir_inicio, dir_fin);

			pixelX += totalX;
		}
		pixelX = xx1;
		pixelY += totalY;
	}
}
Ejemplo n.º 2
0
int OzUIWidgetDrawRectangle(struct OzUIWidget *widget, struct Rect *rect,
        struct LineStyle *lineStyle, struct FillStyle *fillStyle)
{
    struct Rect baseRect;
    copyRect(&baseRect, rect);
    translateRect(&baseRect, widget->rect.x, widget->rect.y);
    return OzUIWindowDrawRectangle(widget->window, &widget->dirtyRect, &baseRect, lineStyle, fillStyle);
}
Ejemplo n.º 3
0
void DynamicAnimation_init(DynamicAnimation* self, const SDL_Rect* dest, SDL_Texture* texture, const SDL_Rect** rectAnimation, uint32_t maxN, uint32_t currentN, uint32_t nbFrame)
{
	Animation_init((Animation*)self, dest, texture, maxN, currentN, nbFrame);
	self->rect = (SDL_Rect*)malloc(maxN * sizeof(SDL_Rect));
	uint32_t i;
	for(i=0; i < maxN; i++)
		copyRect(&(self->rect[i]), rectAnimation[i]);
    ((Animation*)self)->setSubNSpriteRect = &DynamicAnimation_setSubNSpriteRect;
	((Animation*)self)->setSubNSpriteRect((Animation*)self, currentN);
}
Ejemplo n.º 4
0
void DrasculaEngine::placeBJ() {
	int bX = 0;

	if (trackBJ == 3)
		bX = 10;
	else if (trackBJ == 0)
		bX = 37;

	copyRect(bX, 99, bjX, bjY, 26, 76, drawSurface3, screenSurface);
}
Ejemplo n.º 5
0
IplImage* LibFaceUtils::scaledSection(const IplImage* src, const CvRect& sourceRect, double scaleFactor)
{
    if (scaleFactor == 1.0)
        return copyRect(src, sourceRect);

    return scaledSection(src, sourceRect, cvSize(
                         lround(double(sourceRect.width) * scaleFactor),
                         lround(double(sourceRect.height) * scaleFactor) )
                        );
}
Ejemplo n.º 6
0
void DrasculaEngine::clearMenu() {
	int n, verbActivated = 1;

	for (n = 0; n < 7; n++) {
		if (mouseX > _verbBarX[n] && mouseX < _verbBarX[n + 1])
			verbActivated = 0;
		copyRect(OBJWIDTH * n, OBJHEIGHT * verbActivated, _verbBarX[n], 2,
						OBJWIDTH, OBJHEIGHT, cursorSurface, screenSurface);
		verbActivated = 1;
	}
}
Ejemplo n.º 7
0
void DrasculaEngine::placeIgor() {
	int igY = 0;

	if (currentChapter == 4) {
		igY = 138;
	} else {
		if (trackIgor == 3)
			igY = 138;
		else if (trackIgor == 1)
			igY = 76;
	}

	copyRect(1, igY, igorX, igorY, 54, 61, frontSurface, screenSurface);
}
void SkFlipPixelRef::CopyBitsFromAddr(const SkBitmap& dst, const SkRegion& clip,
                                      const void* srcAddr) {
    const int shift = getShift(dst.config());
    if (shift < 0) {
        return;
    }
    
    const SkIRect bounds = {0, 0, dst.width(), dst.height()};
    SkRegion::Cliperator iter(clip, bounds);
    
    while (!iter.done()) {
        copyRect(dst, iter.rect(), srcAddr, shift);
        iter.next();
    }
}
Ejemplo n.º 9
0
void Piece::render(SDL_Rect location)
{
	if(context == NULL)
	{
		#if DEBUG > 1
		std::cerr << "Warning: Could not render piece, problem establishing game context\n";
		#endif
		return;
	}
	if(locationChanged(location,currentLocation))
	{
		copyRect(&currentLocation,location);
		SDL_BlitSurface(image,NULL,context->getRenderContext(),&currentLocation);
		context->screenUpdated = true;
	}
}
Ejemplo n.º 10
0
IplImage* LibFaceUtils::scaledSection(const IplImage* src, const CvRect& sourceRect, const CvSize& destSize)
{
    if (destSize.width == sourceRect.width && destSize.height == sourceRect.height)
        return copyRect(src, sourceRect);

    // Create a non-const header to set the ROI
    IplImage* srcHeader  = cvCreateImageHeader(cvSize(src->width, src->height), src->depth, src->nChannels);
    srcHeader->imageData = const_cast<char*>(src->imageData);
    cvSetImageROI(srcHeader, sourceRect);

    IplImage* result = cvCreateImage(cvSize(destSize.width, destSize.height), src->depth, src->nChannels);
    cvResize(srcHeader, result);

    cvReleaseImageHeader(&srcHeader);
    return result;
}
Ejemplo n.º 11
0
struct OzUIWidget *OzUICreateWidget(struct OzUIWindow *window, int type, int flags, struct Rect *rect, struct OzUIWidgetOperation *ops, void *userData)
{
    struct OzUIWidget *widget;
    widget = (struct OzUIWidget*)malloc(sizeof(struct OzUIWidget));
    memset(widget, 0, sizeof(struct OzUIWidget));
    widget->window = window;
    widget->type = type;
    widget->flags = flags;
    copyRect(&widget->rect, rect);
    translateRect(&widget->rect, widget->window->clientRect.x, widget->window->clientRect.y);
    initRect(&widget->dirtyRect, 0, 0, 0, 0);
    widget->ops = ops;
    widget->d = userData;
    listAdd(&widget->link, &window->widgetList);
    if (widget->ops && widget->ops->onCreate)
        widget->ops->onCreate(widget);
    return widget;
}
Ejemplo n.º 12
0
void CalcProxyScaleFactor (const VRect *filterRect, Rect *proxyRect, float *scaleFactor)
{

	short filterHeight;
	short filterWidth;
	short itemHeight;
	short itemWidth;
	Point fraction;

	shrinkRect (proxyRect, kGutter, kGutter); 		 // for the border

	filterHeight = (short)(filterRect->bottom - filterRect->top);
	filterWidth  = (short)(filterRect->right  - filterRect->left);
	
	itemHeight = proxyRect->bottom - proxyRect->top;
	itemWidth  = proxyRect->right  - proxyRect->left;
	
	if (itemHeight > filterHeight)
		itemHeight = filterHeight;
		
	if (itemWidth > filterWidth)
		itemWidth = filterWidth;
	
	fraction.h = (short)((filterWidth + itemWidth) / itemWidth);
	fraction.v = (short)((filterHeight + itemHeight) / itemHeight);

	// compute a scale factor now
	if (fraction.h > fraction.v) 
		*scaleFactor = ((float)filterWidth + (float)itemWidth) / (float)itemWidth;
	else
		*scaleFactor = ((float)filterHeight + (float)itemHeight) / (float)itemHeight;

	// resize the proxy rectangle
	copyRect (proxyRect, filterRect);	
	scaleRect (proxyRect, 1, (short)*scaleFactor);

	// now get a more precise scale factor from the resulting rectangle
	if (fraction.h > fraction.v) 
		*scaleFactor = (float)filterWidth / (float)(proxyRect->right  - proxyRect->left);
	else
		*scaleFactor = (float)filterHeight / (float)(proxyRect->bottom - proxyRect->top);

}
Ejemplo n.º 13
0
void DrasculaEngine::showMenu() {
	int h, n, x;
	char textIcon[13];
	byte *srcSurface = (currentChapter == 6) ? tableSurface : frontSurface;
	x = whichObject();
	strcpy(textIcon, iconName[x]);

	for (n = 1; n < ARRAYSIZE(inventoryObjects); n++) {
		h = inventoryObjects[n];

		if (h != 0) {
			copyBackground(_polX[n], _polY[n], _itemLocations[n].x, _itemLocations[n].y,
							OBJWIDTH, OBJHEIGHT, srcSurface, screenSurface);
		}
		copyRect(_x1d_menu[h], _y1d_menu[h], _itemLocations[n].x, _itemLocations[n].y,
				OBJWIDTH, OBJHEIGHT, cursorSurface, screenSurface);
	}

	if (x < 7)
		print_abc(textIcon, _itemLocations[x].x - 2, _itemLocations[x].y - 7);
}
Ejemplo n.º 14
0
static void textEditPaint(struct OzUIWidget *widget)
{
    struct Rect rect, cursorRect;
    struct OzUITextEdit *textEdit;
    struct Point p1, p2;
    int dx, dy;

    textEdit = (struct OzUITextEdit*)widget->d;
    initRect(&rect, 0, 0, widget->rect.w, widget->rect.h);
    //initRect(&tlc.rect, 0, 0, 100000, 100000);
    OzUIWidgetDrawRectangle(widget, &rect, &blackLS, &whiteFS);
    if (textEdit && textEdit->layout) {
        copyRect(&cursorRect, &textEdit->layout->charLayout[textEdit->cursorPos].rect);
        cursorRect.w = textEdit->fontSize/2;

        dx = dy = 0;
        if (rectLeft(&cursorRect) < rectLeft(&rect))
            dx =  rectLeft(&rect) - rectLeft(&cursorRect);
        if (rectRight(&cursorRect) > rectRight(&rect))
            dx =  rectRight(&rect) - rectRight(&cursorRect);
        if (rectTop(&cursorRect) < rectTop(&rect))
            dy =  rectTop(&rect) - rectTop(&cursorRect);
        if (rectBottom(&cursorRect) > rectBottom(&rect))
            dy =  rectBottom(&rect) - rectBottom(&cursorRect);

        OzUITextLayoutTransform(textEdit->layout, dx, dy);
        translateRect(&cursorRect, dx, dy);
        OzUIWidgetDrawTextLayout(widget, &tlc, &blackLS, textEdit->layout);
        if (widget->window->focusWidget == widget) {
            p1.x = rectLeft(&cursorRect);
            p1.y = rectBottom(&cursorRect);
            p2.x = rectRight(&cursorRect);
            p2.y = rectBottom(&cursorRect);
            OzUIWidgetDrawLine(widget, &p1, &p2, &blackLS);
        }
    }
}
Ejemplo n.º 15
0
void DrasculaEngine::print_abc(const char *said, int screenX, int screenY) {
	int letterY = 0, letterX = 0, i;
	uint len = strlen(said);
	byte c;

	for (uint h = 0; h < len; h++) {
		c = toupper(said[h]);

		for (i = 0; i < _charMapSize; i++) {
			if (c == _charMap[i].inChar) {
				letterX = _charMap[i].mappedChar;

				switch (_charMap[i].charType) {
				case 0:		// letters
					letterY = (_lang == kSpanish) ? 149 : 158;
					break;
				case 1:		// signs
					letterY = (_lang == kSpanish) ? 160 : 169;
					break;
				case 2:		// accented
					letterY = 180;
					break;
				}	// switch
				break;
			}	// if
		}	// for

		copyRect(letterX, letterY, screenX, screenY,
				 CHAR_WIDTH, CHAR_HEIGHT, tableSurface, screenSurface);

		screenX = screenX + CHAR_WIDTH;
		if (screenX > 317) {
			screenX = 0;
			screenY = screenY + CHAR_HEIGHT + 2;
		}
	}	// for
}
Ejemplo n.º 16
0
void AVISurface::copyMovieFrame(const Graphics::Surface &src, Graphics::ManagedSurface &dest) {
	// WORKAROUND: Handle rare cases where frame sizes don't match the video size
	Common::Rect copyRect(0, 0, MIN(src.w, dest.w), MIN(src.h, dest.h));

	if (src.format.bytesPerPixel == 1) {
		// Paletted 8-bit, so convert to 16-bit and copy over
		const byte *palette = _decoder->getPalette();
		if (palette) {
			Graphics::Surface *s = src.convertTo(dest.format, palette);
			dest.blitFrom(*s, copyRect, Common::Point(0, 0));
			s->free();
			delete s;
		}
	} else if (src.format.bytesPerPixel == 2) {
		// Source is already 16-bit, with no alpha, so do a straight copy
		dest.blitFrom(src, copyRect, Common::Point(0, 0));
	} else {
		// Source is 32-bit which may have transparent pixels. Copy over each
		// pixel, replacing transparent pixels with the special transparency color
		byte a, r, g, b;
		assert(src.format.bytesPerPixel == 4 && dest.format.bytesPerPixel == 2);
		uint16 transPixel = _videoSurface->getTransparencyColor();

		for (uint y = 0; y < MIN(src.h, dest.h); ++y) {
			const uint32 *pSrc = (const uint32 *)src.getBasePtr(0, y);
			uint16 *pDest = (uint16 *)dest.getBasePtr(0, y);

			for (uint x = 0; x < MIN(src.w, dest.w); ++x, ++pSrc, ++pDest) {
				src.format.colorToARGB(*pSrc, a, r, g, b);
				assert(a == 0 || a == 0xff);

				*pDest = (a == 0) ? transPixel : dest.format.RGBToColor(r, g, b);
			}
		}
	}
}
int main(int argc, char *argv[])
{
    std::vector<std::string> inputFiles;
    int globalRadius = -1;
    int globalBorder = -1;
    bool gridOverlay = false;

    ExPop::CommandlineParser cmdParser(argv[0]);

    cmdParser.addHandler<std::string>(
        "", [&inputFiles](const std::string &filename) {
            inputFiles.push_back(filename);
        });
    cmdParser.addVariableHandler("radius", &globalRadius);
    cmdParser.addVariableHandler("border", &globalBorder);
    cmdParser.addFlagHandler("grid", &gridOverlay);

    if(!cmdParser.handleCommandline(argc, argv)) {
        return cmdParser.getErrorFlag();
    }

    for(size_t i = 0; i < inputFiles.size(); i++) {

        ExPop::Gfx::Image *img = ExPop::Gfx::loadTGAFromFile(inputFiles[i]);
        if(!img) {
            std::cerr << "Could not load TGA: " << inputFiles[i] << std::endl;
            return 1;
        }

        if(img->getWidth() != img->getHeight()) {
            std::cerr << "Image not square: " << inputFiles[i] << std::endl;
            return 1;
        }

        std::string filename;
        std::string extension;
        ExPop::stringSplit(inputFiles[i], ".", filename, extension, true);

        int radius = globalRadius;
        if(globalRadius == -1) {
            radius = img->getWidth() / 2;
        }
        int border = globalBorder;
        if(globalBorder == -1) {
            border = img->getWidth() / 8;
        }

        if(radius < border) {
            radius = border;
        }

        ExPop::Gfx::Image *dstImg = new ExPop::Gfx::Image(img->getWidth() * 5, img->getHeight() * 3);

        // '#' shaped thing on the left. One inner tile, four outer
        // angle tiles, and four edge tiles.
        copyRect(
            img, dstImg,
            -radius, -border,
            img->getWidth() - radius, img->getHeight() - border,
            radius * 2 + img->getWidth(), border * 2);

        copyRect(
            img, dstImg,
            -radius, -border,
            img->getWidth() - radius, img->getHeight() * 2 - border,
            radius * 2 + img->getWidth(), border * 2);

        copyRect(
            img, dstImg,
            -border, -radius,
            img->getWidth() - border, img->getHeight() - radius,
            border * 2, radius * 2 + img->getHeight());

        copyRect(
            img, dstImg,
            -border, -radius,
            img->getWidth() - border + img->getWidth(), img->getHeight() - radius,
            border * 2, radius * 2 + img->getHeight());

        // 'o' on the right. Four inner angle tiles.
        copyRect(
            img, dstImg,
            0, 0,
            img->getWidth() * 3, 0,
            img->getWidth() * 2, img->getHeight() * 2);

        clearRect(dstImg,
            img->getWidth() * 3 + border, border,
            img->getWidth() * 2 - 2 * border,
            img->getHeight() * 2 - 2 * border);

        copyRect(
            img, dstImg,
            0, -border,
            img->getWidth() * 3, img->getHeight() + -border,
            img->getWidth() * 2, border * 2);

        copyRect(
            img, dstImg,
            -border, 0,
            img->getWidth() * 4 - border, 0,
            border * 2, img->getHeight() * 2);

        clearRect(dstImg,
            img->getWidth() * 3 + radius, radius,
            img->getWidth() * 2 - 2 * radius,
            img->getHeight() * 2 - 2 * radius);


        if(gridOverlay) {
            for(int y = 0; y < dstImg->getHeight(); y += img->getHeight()) {
                for(int x = 0; x < dstImg->getWidth(); x++) {
                    ExPop::Gfx::Pixel *p = dstImg->getPixel(x, y);
                    p->rgba.r = p->rgba.g = p->rgba.b = (((x&1)^(y&1))?0xff:0x0);
                    p->rgba.a = 255;
                }
            }
            for(int x = 0; x < dstImg->getWidth(); x += img->getWidth()) {
                for(int y = 0; y < dstImg->getHeight(); y++) {
                    ExPop::Gfx::Pixel *p = dstImg->getPixel(x, y);
                    p->rgba.r = p->rgba.g = p->rgba.b = (((x&1)^(y&1))?0xff:0x0);
                    p->rgba.a = 255;
                }
            }
        }


        saveTGAToFile(dstImg, filename + ".template." + extension);

        delete dstImg;
        delete img;
    }

    return 0;
}
Ejemplo n.º 18
0
void DrasculaEngine::volumeControls() {
	if (_lang == kSpanish)
		loadPic(95, tableSurface);

	copyRect(1, 56, 73, 63, 177, 97, tableSurface, screenSurface);
	updateScreen(73, 63, 73, 63, 177, 97, screenSurface);

	setCursor(kCursorCrosshair);
	showCursor();

	while (!shouldQuit()) {
		int masterVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16), 0, 15);
		int voiceVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType) / 16), 0, 15);
		int musicVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16), 0, 15);

		int masterVolumeY = 72 + 61 - masterVolume * 4;
		int voiceVolumeY = 72 + 61 - voiceVolume * 4;
		int musicVolumeY = 72 + 61 - musicVolume * 4;

		updateRoom();

		copyRect(1, 56, 73, 63, 177, 97, tableSurface, screenSurface);

		copyBackground(183, 56, 82, masterVolumeY, 39, 2 + masterVolume * 4, tableSurface, screenSurface);
		copyBackground(183, 56, 138, voiceVolumeY, 39, 2 + voiceVolume * 4, tableSurface, screenSurface);
		copyBackground(183, 56, 194, musicVolumeY, 39, 2 + musicVolume * 4, tableSurface, screenSurface);

		updateScreen();

		updateEvents();

		// we're ignoring keypresses, so just empty the keyboard buffer
		while (getScan())
			;

		if (rightMouseButton == 1) {
			delay(100);
			break;
		}
		if (leftMouseButton == 1) {
			delay(100);
			if (mouseX > 80 && mouseX < 121) {
				updateVolume(Audio::Mixer::kPlainSoundType, masterVolumeY);
			}

			if (mouseX > 136 && mouseX < 178) {
				updateVolume(Audio::Mixer::kSpeechSoundType, voiceVolumeY);
			}

			if (mouseX > 192 && mouseX < 233) {
				updateVolume(Audio::Mixer::kMusicSoundType, musicVolumeY);
			}
		}

	}

	if (_lang == kSpanish)
		loadPic(974, tableSurface);

	selectVerb(kVerbNone);

	updateEvents();
}
Ejemplo n.º 19
0
int DrasculaEngine::print_abc_opc(const char *said, int screenY, int game) {
	int signY, letterY, letterX = 0;
	uint len = strlen(said);

	int screenX = 1;
	int lines = 1;

	for (uint h = 0; h < len; h++) {
		int wordLength;

		// Look ahead to the end of the word.
		wordLength = 0;
		int pos = h;
		while (said[pos] && said[pos] != ' ') {
			wordLength++;
			pos++;
		}

		if (screenX + wordLength * CHAR_WIDTH_OPC > 317) {
			screenX = 0;
			screenY += (CHAR_HEIGHT + 2);
			lines++;
		}

		if (game == 1) {
			letterY = 6;
			signY = 15;
		} else if (game == 3) {
			letterY = 56;
			signY = 65;
		} else {
			letterY = 31;
			signY = 40;
		}

		byte c = toupper(said[h]);

		// WORKAROUND: Even original did not process it correctly
		// Fixes apostrophe rendering
		if (_lang != kSpanish)
			if (c == '\'')
				c = (byte)'\244';

		for (int i = 0; i < _charMapSize; i++) {
			if (c == _charMap[i].inChar) {
				// Convert the mapped char of the normal font to the
				// mapped char of the dialogue font

				int multiplier = (_charMap[i].mappedChar - 6) / 9;

				letterX = multiplier * 7 + 10;

				if (_charMap[i].charType > 0)
					letterY = signY;
				break;
			}	// if
		}	// for

		copyRect(letterX, letterY, screenX, screenY,
				 CHAR_WIDTH_OPC, CHAR_HEIGHT_OPC, backSurface, screenSurface);

		screenX = screenX + CHAR_WIDTH_OPC;
	}

	return lines;
}
Ejemplo n.º 20
0
void DrasculaEngine::moveCharacters() {
	int curPos[6];
	int r;

	if (characterMoved == 1 && stepX == STEP_X) {
		for (r = 0; r < stepX; r++) {
			if (currentChapter != 2) {
				if (trackProtagonist == 0 && roomX - r == curX + curWidth / 2) {
					characterMoved = 0;
					stepX = STEP_X;
					stepY = STEP_Y;
				}
				if (trackProtagonist == 1 && roomX + r == curX + curWidth / 2) {
					characterMoved = 0;
					stepX = STEP_X;
					stepY = STEP_Y;
					curX = roomX - curWidth / 2;
					curY = roomY - curHeight;
				}
			} else if (currentChapter == 2) {
				if (trackProtagonist == 0 && roomX - r == curX) {
					characterMoved = 0;
					stepX = STEP_X;
					stepY = STEP_Y;
				}
				if (trackProtagonist == 1 && roomX + r == curX + curWidth) {
					characterMoved = 0;
					stepX = STEP_X;
					stepY = STEP_Y;
					curX = roomX - curWidth + 4;
					curY = roomY - curHeight;
				}
			}
		}
	}
	if (characterMoved == 1 && stepY == STEP_Y) {
		for (r = 0; r < stepY; r++) {
			if (trackProtagonist == 2 && roomY - r == curY + curHeight) {
				characterMoved = 0;
				stepX = STEP_X;
				stepY = STEP_Y;
			}
			if (trackProtagonist == 3 && roomY + r == curY + curHeight) {
				characterMoved = 0;
				stepX = STEP_X;
				stepY = STEP_Y;
			}
		}
	}

	if (currentChapter != 2 && currentChapter != 3) {
		if (characterVisible == 0) {
			increaseFrameNum();
			return;
		}
	}

	if (characterMoved == 0) {
		curPos[0] = 0;
		curPos[1] = DIF_MASK_HARE;
		curPos[2] = curX;
		curPos[3] = curY;
		if (currentChapter == 2) {
			curPos[4] = curWidth;
			curPos[5] = curHeight;
		} else {
			curPos[4] = CHARACTER_WIDTH;
			curPos[5] = CHARACTER_HEIGHT;
		}

		if (trackProtagonist == 0) {
			curPos[1] = 0;
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 extraSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], extraSurface, screenSurface);
		} else if (trackProtagonist == 1) {
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 extraSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], extraSurface, screenSurface);
		} else if (trackProtagonist == 2) {
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 backSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], backSurface, screenSurface);
		} else {
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 frontSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], frontSurface, screenSurface);
		}
	} else if (characterMoved == 1) {
		curPos[0] = _frameX[_characterFrame];
		curPos[1] = frame_y + DIF_MASK_HARE;
		curPos[2] = curX;
		curPos[3] = curY;
		if (currentChapter == 2) {
			curPos[4] = curWidth;
			curPos[5] = curHeight;
		} else {
			curPos[4] = CHARACTER_WIDTH;
			curPos[5] = CHARACTER_HEIGHT;
		}
		if (trackProtagonist == 0) {
			curPos[1] = 0;
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 extraSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], extraSurface, screenSurface);
		} else if (trackProtagonist == 1) {
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 extraSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], extraSurface, screenSurface);
		} else if (trackProtagonist == 2) {
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 backSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], backSurface, screenSurface);
		} else {
			if (currentChapter == 2)
				copyRect(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
						 frontSurface, screenSurface);
			else
				reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
									factor_red[curY + curHeight], frontSurface, screenSurface);
		}
		increaseFrameNum();
	}
}
Ejemplo n.º 21
0
TileClient
ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
                                    const nsIntPoint& aTileOrigin,
                                    const nsIntRegion& aDirtyRegion)
{
  PROFILER_LABEL("ClientTiledLayerBuffer", "ValidateTile");

#ifdef GFX_TILEDLAYER_PREF_WARNINGS
  if (aDirtyRegion.IsComplex()) {
    printf_stderr("Complex region\n");
  }
#endif

  if (aTile.IsPlaceholderTile()) {
    aTile.SetLayerManager(mManager);
  }

  // Discard our front and backbuffers if our contents changed. In this case
  // the calling code will already have taken care of invalidating the entire
  // layer.
  if (HasFormatChanged()) {
    aTile.DiscardBackBuffer();
    aTile.DiscardFrontBuffer();
  }

  bool createdTextureClient = false;
  nsIntRegion offsetDirtyRegion = aDirtyRegion.MovedBy(-aTileOrigin);
  bool usingSinglePaintBuffer = !!mSinglePaintDrawTarget;
  RefPtr<TextureClient> backBuffer =
    aTile.GetBackBuffer(offsetDirtyRegion,
                        mManager->GetTexturePool(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(GetContentType())),
                        &createdTextureClient, !usingSinglePaintBuffer);

  if (!backBuffer->Lock(OPEN_READ_WRITE)) {
    NS_WARNING("Failed to lock tile TextureClient for updating.");
    aTile.DiscardFrontBuffer();
    return aTile;
  }

  // We must not keep a reference to the DrawTarget after it has been unlocked,
  // make sure these are null'd before unlocking as destruction of the context
  // may cause the target to be flushed.
  RefPtr<DrawTarget> drawTarget = backBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget();
  drawTarget->SetTransform(Matrix());

  RefPtr<gfxContext> ctxt = new gfxContext(drawTarget);

  if (usingSinglePaintBuffer) {
    // XXX Perhaps we should just copy the bounding rectangle here?
    RefPtr<gfx::SourceSurface> source = mSinglePaintDrawTarget->Snapshot();
    nsIntRegionRectIterator it(aDirtyRegion);
    for (const nsIntRect* dirtyRect = it.Next(); dirtyRect != nullptr; dirtyRect = it.Next()) {
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
      printf_stderr(" break into subdirtyRect %i, %i, %i, %i\n",
                    dirtyRect->x, dirtyRect->y, dirtyRect->width, dirtyRect->height);
#endif
      gfx::Rect drawRect(dirtyRect->x - aTileOrigin.x,
                         dirtyRect->y - aTileOrigin.y,
                         dirtyRect->width,
                         dirtyRect->height);
      drawRect.Scale(mResolution);

      gfx::IntRect copyRect(NS_roundf((dirtyRect->x - mSinglePaintBufferOffset.x) * mResolution),
                            NS_roundf((dirtyRect->y - mSinglePaintBufferOffset.y) * mResolution),
                            drawRect.width,
                            drawRect.height);
      gfx::IntPoint copyTarget(NS_roundf(drawRect.x), NS_roundf(drawRect.y));
      drawTarget->CopySurface(source, copyRect, copyTarget);

      // Mark the newly updated area as invalid in the front buffer
      aTile.mInvalidFront.Or(aTile.mInvalidFront, nsIntRect(copyTarget.x, copyTarget.y, copyRect.width, copyRect.height));
    }

    // The new buffer is now validated, remove the dirty region from it.
    aTile.mInvalidBack.Sub(nsIntRect(0, 0, TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE),
                           offsetDirtyRegion);
  } else {
    // Area of the full tile...
    nsIntRegion tileRegion = nsIntRect(aTileOrigin.x, aTileOrigin.y, TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE);

    // Intersect this area with the portion that's dirty.
    tileRegion = tileRegion.Intersect(aDirtyRegion);

    // Move invalid areas into layer space.
    aTile.mInvalidFront.MoveBy(aTileOrigin);
    aTile.mInvalidBack.MoveBy(aTileOrigin);

    // Add the area that's going to be redrawn to the invalid area of the
    // front region.
    aTile.mInvalidFront.Or(aTile.mInvalidFront, tileRegion);

    // Add invalid areas of the backbuffer to the area to redraw.
    tileRegion.Or(tileRegion, aTile.mInvalidBack);

    // Move invalid areas back into tile space.
    aTile.mInvalidFront.MoveBy(-aTileOrigin);

    // This will be validated now.
    aTile.mInvalidBack.SetEmpty();

    nsIntRect bounds = tileRegion.GetBounds();
    bounds.ScaleRoundOut(mResolution, mResolution);
    bounds.MoveBy(-aTileOrigin);

    if (GetContentType() != gfxContentType::COLOR) {
      drawTarget->ClearRect(Rect(bounds.x, bounds.y, bounds.width, bounds.height));
    }

    ctxt->NewPath();
    ctxt->Clip(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height));
    ctxt->Scale(mResolution, mResolution);
    ctxt->Translate(gfxPoint(-aTileOrigin.x, -aTileOrigin.y));
    mCallback(mThebesLayer, ctxt,
              tileRegion.GetBounds(),
              DrawRegionClip::CLIP_NONE,
              nsIntRegion(), mCallbackData);

  }

#ifdef GFX_TILEDLAYER_DEBUG_OVERLAY
  DrawDebugOverlay(drawTarget, aTileOrigin.x * mResolution,
                   aTileOrigin.y * mResolution, GetTileLength(), GetTileLength());
#endif

  ctxt = nullptr;
  drawTarget = nullptr;

  backBuffer->Unlock();

  aTile.Flip();

  if (createdTextureClient) {
    if (!mCompositableClient->AddTextureClient(backBuffer)) {
      NS_WARNING("Failed to add tile TextureClient.");
      aTile.DiscardFrontBuffer();
      aTile.DiscardBackBuffer();
      return aTile;
    }
  }

  // Note, we don't call UpdatedTexture. The Updated function is called manually
  // by the TiledContentHost before composition.

  if (backBuffer->HasInternalBuffer()) {
    // If our new buffer has an internal buffer, we don't want to keep another
    // TextureClient around unnecessarily, so discard the back-buffer.
    aTile.DiscardBackBuffer();
  }

  return aTile;
}
Ejemplo n.º 22
0
void RMRect::setRect(const RMRect &rc) {
	copyRect(rc);
}
Ejemplo n.º 23
0
const RMRect &RMRect::operator=(const RMRect &rc) {
	copyRect(rc);
	return *this;
}
Ejemplo n.º 24
0
RMRect::RMRect(const RMRect &rc): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) {
	copyRect(rc);
}
Ejemplo n.º 25
0
static void getCursorRect(struct OzUITextEdit *textEdit, struct Rect *cursorRect)
{
    copyRect(cursorRect, &textEdit->layout->charLayout[textEdit->cursorPos].rect);
    cursorRect->w = textEdit->fontSize/2;
}