当前位置: 首页>>代码示例>>C++>>正文


C++ Rect::isEmpty方法代码示例

本文整理汇总了C++中common::Rect::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::isEmpty方法的具体用法?C++ Rect::isEmpty怎么用?C++ Rect::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common::Rect的用法示例。


在下文中一共展示了Rect::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render

Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect, uint zoom) const {
	if (src_rect.isEmpty()) {
		src_rect = Common::Rect(0, 0, w, h);
	}
	Common::Rect dst_rect(x + dx, y + dy, x + dx + zoom * src_rect.width() / 256, y + dy + zoom * src_rect.height() / 256);
	if (dst_rect.left < 0) {
		src_rect.left = -dst_rect.left;
		dst_rect.left = 0;
	}
	if (dst_rect.right > surface->w) {
		src_rect.right -= dst_rect.right - surface->w;
		dst_rect.right = surface->w;
	}
	if (dst_rect.top < 0) {
		src_rect.top -= dst_rect.top;
		dst_rect.top = 0;
	}
	if (dst_rect.bottom > surface->h) {
		src_rect.bottom -= dst_rect.bottom - surface->h;
		dst_rect.bottom = surface->h;
	}
	if (src_rect.isEmpty() || dst_rect.isEmpty())
		return Common::Rect();

	if (zoom == 256) {
		const byte *src = (const byte *)getBasePtr(0, src_rect.top);
		byte *dst_base = (byte *)surface->getBasePtr(dst_rect.left, dst_rect.top);

		for (int i = src_rect.top; i < src_rect.bottom; ++i) {
			byte *dst = dst_base;
			for (int j = src_rect.left; j < src_rect.right; ++j) {
				byte p = src[(mirror? w - j - 1: j)];
				if (p != 0xff)
					*dst++ = p;
				else
					++dst;
			}
			dst_base += surface->pitch;
			src += pitch;
		}
	} else {
		byte *dst = (byte *)surface->getBasePtr(dst_rect.left, dst_rect.top);
		for(int i = 0; i < dst_rect.height(); ++i) {
			for (int j = 0; j < dst_rect.width(); ++j) {
				int px = j * 256 / zoom;
				const byte *src = (const byte *)getBasePtr(src_rect.left + (mirror? w - px - 1: px), src_rect.top + i * 256 / zoom);
				byte p = *src;
				if (p != 0xff)
					dst[j] = p;
			}
			dst += surface->pitch;
		}
	}
	return dst_rect;
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:55,代码来源:surface.cpp

示例2: rectSubtract

int BbvsEngine::rectSubtract(const Common::Rect &rect1, const Common::Rect &rect2, Common::Rect *outRects) {
	int count = 0;
	Common::Rect workRect = rect1.findIntersectingRect(rect2);
	if (!workRect.isEmpty()) {
		count = 0;
		outRects[count] = Common::Rect(rect2.width(), workRect.top - rect2.top);
		if (!outRects[count].isEmpty()) {
			outRects[count].translate(rect2.left, rect2.top);
			++count;
		}
		outRects[count] = Common::Rect(workRect.left - rect2.left, workRect.height());
		if (!outRects[count].isEmpty()) {
			outRects[count].translate(rect2.left, workRect.top);
			++count;
		}
		outRects[count] = Common::Rect(rect2.right - workRect.right, workRect.height());
		if (!outRects[count].isEmpty()) {
			outRects[count].translate(workRect.right, workRect.top);
			++count;
		}
		outRects[count] = Common::Rect(rect2.width(), rect2.bottom - workRect.bottom);
		if (!outRects[count].isEmpty()) {
			outRects[count].translate(rect2.left, workRect.bottom);
			++count;
		}
	} else {
		outRects[0] = rect2;
		count = 1;
	}
	return count;
}
开发者ID:andrew889,项目名称:scummvm,代码行数:31,代码来源:walk.cpp

示例3: addDirtyRect

void ThemeEngine::addDirtyRect(Common::Rect r) {
	// Clip the rect to screen coords
	r.clip(_screen.w, _screen.h);

	// If it is empty after clipping, we are done
	if (r.isEmpty())
		return;

	// Check if the new rectangle is contained within another in the list
	Common::List<Common::Rect>::iterator it;
	for (it = _dirtyScreen.begin(); it != _dirtyScreen.end();) {
		// If we find a rectangle which fully contains the new one,
		// we can abort the search.
		if (it->contains(r))
			return;

		// Conversely, if we find rectangles which are contained in
		// the new one, we can remove them
		if (r.contains(*it))
			it = _dirtyScreen.erase(it);
		else
			++it;
	}

	// If we got here, we can safely add r to the list of dirty rects.
	_dirtyScreen.push_back(r);
}
开发者ID:megaboy,项目名称:scummvm,代码行数:27,代码来源:ThemeEngine.cpp

示例4: addDirtyRect

void Render::addDirtyRect(Common::Rect r) {
	if (_fullRefresh)
		return;

	// Clip rectangle
	r.clip(_backGroundSurface.w, _backGroundSurface.h);

	// If it is empty after clipping, we are done
	if (r.isEmpty())
		return;

	// Check if the new rectangle is contained within another in the list
	Common::List<Common::Rect>::iterator it;
	for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ) {
		// If we find a rectangle which fully contains the new one,
		// we can abort the search.
		if (it->contains(r))
			return;

		// Conversely, if we find rectangles which are contained in
		// the new one, we can remove them
		if (r.contains(*it))
			it = _dirtyRects.erase(it);
		else
			++it;
	}

	// If we got here, we can safely add r to the list of dirty rects.
	if (_vm->_interface->getFadeMode() != kFadeOut)
		_dirtyRects.push_back(r);
}
开发者ID:michailBs,项目名称:scummvm,代码行数:31,代码来源:render.cpp

示例5: UnionRectangle

/**
 * Creates the union of two rectangles.
 * Returns True if there is a union.
 * @param pDest			destination rectangle that is to receive the new union
 * @param pSrc1			a source rectangle
 * @param pSrc2			a source rectangle
 */
bool UnionRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
	pDest.left   = MIN(pSrc1.left, pSrc2.left);
	pDest.top    = MIN(pSrc1.top, pSrc2.top);
	pDest.right  = MAX(pSrc1.right, pSrc2.right);
	pDest.bottom = MAX(pSrc1.bottom, pSrc2.bottom);

	return !pDest.isEmpty();
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:15,代码来源:cliprect.cpp

示例6: if

void GfxPaint16::fillRect(const Common::Rect &rect, int16 drawFlags, byte color, byte priority, byte control) {
	Common::Rect r = rect;
	r.clip(_ports->_curPort->rect);
	if (r.isEmpty()) // nothing to fill
		return;

	int16 oldPenMode = _ports->_curPort->penMode;
	_ports->offsetRect(r);
	int16 x, y;
	byte curVisual;

	// Doing visual first
	if (drawFlags & GFX_SCREEN_MASK_VISUAL) {
		if (oldPenMode == 2) { // invert mode
			for (y = r.top; y < r.bottom; y++) {
				for (x = r.left; x < r.right; x++) {
					curVisual = _screen->getVisual(x, y);
					if (curVisual == color) {
						_screen->putPixel(x, y, GFX_SCREEN_MASK_VISUAL, priority, 0, 0);
					} else if (curVisual == priority) {
						_screen->putPixel(x, y, GFX_SCREEN_MASK_VISUAL, color, 0, 0);
					}
				}
			}
		} else { // just fill rect with color
			for (y = r.top; y < r.bottom; y++) {
				for (x = r.left; x < r.right; x++) {
//20140521
			//		if(y >= 0)															
						_screen->putPixel(x, y, GFX_SCREEN_MASK_VISUAL, color, 0, 0);
				}
			}
		}
	}

	if (drawFlags < 2)
		return;
	drawFlags &= GFX_SCREEN_MASK_PRIORITY|GFX_SCREEN_MASK_CONTROL;

	// we need to isolate the bits, sierra sci saved priority and control inside one byte, we don't
	priority &= 0x0f;
	control &= 0x0f;

	if (oldPenMode != 2) {
		for (y = r.top; y < r.bottom; y++) {
			for (x = r.left; x < r.right; x++) {
				_screen->putPixel(x, y, drawFlags, 0, priority, control);
			}
		}
	} else {
		for (y = r.top; y < r.bottom; y++) {
			for (x = r.left; x < r.right; x++) {
				_screen->putPixel(x, y, drawFlags, 0, !_screen->getPriority(x, y), !_screen->getControl(x, y));
			}
		}
	}
}
开发者ID:pdpdds,项目名称:scummvm,代码行数:57,代码来源:paint16.cpp

示例7: restoreArea

void TattooMap::restoreArea(const Common::Rect &bounds) {
	Screen &screen = *_vm->_screen;

	Common::Rect r = bounds;
	r.clip(Common::Rect(0, 0, screen._backBuffer1.w(), screen._backBuffer1.h()));

	if (!r.isEmpty())
		screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(r.left, r.top), r);
}
开发者ID:popey,项目名称:scummvm,代码行数:9,代码来源:tattoo_map.cpp

示例8: blitSurfaceToSurface

void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y) {
	Common::Rect srcRect = _srcRect;
	if (srcRect.isEmpty())
		srcRect = Common::Rect(src.w, src.h);
	srcRect.clip(src.w, src.h);
	Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h);
	srcRect.clip(dstRect);

	if (srcRect.isEmpty() || !srcRect.isValidRect())
		return;

	Graphics::Surface *srcAdapted = src.convertTo(dst.format);

	// Copy srcRect from src surface to dst surface
	const byte *srcBuffer = (const byte *)srcAdapted->getBasePtr(srcRect.left, srcRect.top);

	int xx = _x;
	int yy = _y;

	if (xx < 0)
		xx = 0;
	if (yy < 0)
		yy = 0;

	if (_x >= dst.w || _y >= dst.h) {
		srcAdapted->free();
		delete srcAdapted;
		return;
	}

	byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy);

	int32 w = srcRect.width();
	int32 h = srcRect.height();

	for (int32 y = 0; y < h; y++) {
		memcpy(dstBuffer, srcBuffer, w * srcAdapted->format.bytesPerPixel);
		srcBuffer += srcAdapted->pitch;
		dstBuffer += dst.pitch;
	}

	srcAdapted->free();
	delete srcAdapted;
}
开发者ID:superg,项目名称:scummvm,代码行数:44,代码来源:render_manager.cpp

示例9: draw

bool GraphicsManager::draw(Drawable *drawable, BackgroundType type, bool transition) {
	// TODO handle transition properly
	if (transition)
		clear(type);

	// TODO store rect for later use
	Common::Rect rect = drawable->draw(getSurface(type));

	return (!rect.isEmpty());
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:10,代码来源:graphics.cpp

示例10: allocateSurface

void Surface::allocateSurface(const Common::Rect &bounds) {
	deallocateSurface();

	if (bounds.isEmpty())
		return;

	_bounds = bounds;
	_surface = new Graphics::Surface();
	_surface->create(bounds.width(), bounds.height(), g_system->getScreenFormat());
	_ownsSurface = true;
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:11,代码来源:surface.cpp

示例11:

// This version of drawCel is not supposed to call BitsShow()!
void GfxPaint16::drawCel(GfxView *view, int16 loopNo, int16 celNo, const Common::Rect &celRect, byte priority, uint16 paletteNo, uint16 scaleX, uint16 scaleY) {
	Common::Rect clipRect = celRect;
	clipRect.clip(_ports->_curPort->rect);
	if (clipRect.isEmpty()) // nothing to draw
		return;

	Common::Rect clipRectTranslated = clipRect;
	_ports->offsetRect(clipRectTranslated);
	if (scaleX == 128 && scaleY == 128)
		view->draw(celRect, clipRect, clipRectTranslated, loopNo, celNo, priority, paletteNo, false);
	else
		view->drawScaled(celRect, clipRect, clipRectTranslated, loopNo, celNo, priority, scaleX, scaleY);
}
开发者ID:pdpdds,项目名称:scummvm,代码行数:14,代码来源:paint16.cpp

示例12: drawRect

void Director::drawRect(const Common::Rect &rect) {
	_surface.fillRect(rect, 0);
	for (uint i = 0; i < _sprites.size(); ++i) {
		const Common::Rect &spriteRect = _sprites[i]->getBounds();
		Common::Rect interRect = rect.findIntersectingRect(spriteRect);
		if (interRect.isEmpty())
			continue;

		Common::Rect srcRect(interRect);
		srcRect.translate(-spriteRect.left, -spriteRect.top);
		_surface.transBlitFrom(*_sprites[i]->getDecoder()->getCurrentFrame(), srcRect, interRect, _sprites[i]->getDecoder()->getTransparentColourIndex());
	}
}
开发者ID:vladimir-zahradnik,项目名称:scummvm,代码行数:13,代码来源:director.cpp

示例13:

Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) {
	Common::Rect dst = rect;
	dst.clip(_backgroundWidth, _backgroundHeight);

	if (dst.isEmpty() || !dst.isValidRect())
		return NULL;

	Graphics::Surface *srf = new Graphics::Surface;
	srf->create(dst.width(), dst.height(), _currentBackgroundImage.format);

	srf->copyRectToSurface(_currentBackgroundImage, 0, 0, Common::Rect(dst));

	return srf;
}
开发者ID:superg,项目名称:scummvm,代码行数:14,代码来源:render_manager.cpp

示例14: drawSurface

void OpenGLGfxDriver::drawSurface(const Graphics::Surface *surface, Common::Point dest, Common::Rect rect) {
	// Draw the whole surface by default
	if (rect.isEmpty())
		rect = Common::Rect(surface->w, surface->h);

	start2DMode();

	float rasterX = (2 * (float)dest.x / (float)_screenWidth);
	float rasterY = (2 * (float)dest.y / (float)_screenHeight);
	glRasterPos2f(-1.0f + rasterX, 1.0f - rasterY);
	glDrawPixels(surface->w, surface->h, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);

	//glBegin(GL_QUADS); glVertex3i(-1, -1, -1); glVertex3i(1, -1, -1); glVertex3i(1, 1, -1); glVertex3i(-1, 1, -1); glEnd();

	end2DMode();
}
开发者ID:briankory,项目名称:tlj-residual,代码行数:16,代码来源:opengl.cpp

示例15:

// used in SCI0early exclusively
void GfxPaint16::invertRectViaXOR(const Common::Rect &rect) {
	Common::Rect r = rect;
	int16 x, y;
	byte curVisual;

	r.clip(_ports->_curPort->rect);
	if (r.isEmpty()) // nothing to invert
		return;

	_ports->offsetRect(r);
	for (y = r.top; y < r.bottom; y++) {
		for (x = r.left; x < r.right; x++) {
			curVisual = _screen->getVisual(x, y);
			_screen->putPixel(x, y, GFX_SCREEN_MASK_VISUAL, curVisual ^ 0x0f, 0, 0);
		}
	}
}
开发者ID:Templier,项目名称:scummvm-test,代码行数:18,代码来源:paint16.cpp


注:本文中的common::Rect::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。