本文整理汇总了C++中common::Rect::clip方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::clip方法的具体用法?C++ Rect::clip怎么用?C++ Rect::clip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Rect
的用法示例。
在下文中一共展示了Rect::clip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: fillRect
void Surface::fillRect(Common::Rect r, uint32 color) {
r.clip(w, h);
if (!r.isValidRect())
return;
int width = r.width();
int height = r.height();
// int i;
if (bytesPerPixel == 1) {
byte *ptr = (byte *)getBasePtr(r.left, r.top);
while (height--) {
memset(ptr, (byte)color, width);
ptr += pitch;
}
} else if (bytesPerPixel == 2) {
uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top);
while (height--) {
Common::set_to(ptr, ptr + width, (uint16)color);
ptr += pitch/2;
}
} else {
error("Surface::fillRect: bytesPerPixel must be 1 or 2");
}
}
示例3: 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);
}
示例4: addRect
void MicroTileArray::addRect(Common::Rect r) {
int ux0, uy0, ux1, uy1;
int tx0, ty0, tx1, ty1;
int ix0, iy0, ix1, iy1;
r.clip(Common::Rect(0, 0, 799, 599));
ux0 = r.left / TileSize;
uy0 = r.top / TileSize;
ux1 = r.right / TileSize;
uy1 = r.bottom / TileSize;
tx0 = r.left % TileSize;
ty0 = r.top % TileSize;
tx1 = r.right % TileSize;
ty1 = r.bottom % TileSize;
for (int yc = uy0; yc <= uy1; yc++) {
for (int xc = ux0; xc <= ux1; xc++) {
ix0 = (xc == ux0) ? tx0 : 0;
ix1 = (xc == ux1) ? tx1 : TileSize - 1;
iy0 = (yc == uy0) ? ty0 : 0;
iy1 = (yc == uy1) ? ty1 : TileSize - 1;
updateBoundingBox(_tiles[xc + yc * _tilesW], ix0, iy0, ix1, iy1);
}
}
}
示例5: 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));
}
}
}
}
示例6: getFrameSize
uint16 RobotDecoder::getFrameSize(Common::Rect &outRect) const {
outRect.clip(0, 0);
for (RobotScreenItemList::size_type i = 0; i < _screenItemList.size(); ++i) {
ScreenItem &screenItem = *_screenItemList[i];
outRect.extend(screenItem.getNowSeenRect(*_plane));
}
return _numFramesTotal;
}
示例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);
}
示例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;
}
示例9: drawRect
void CSTimeGraphics::drawRect(Common::Rect rect, byte color) {
rect.clip(Common::Rect(640, 480));
// Useful with debugging. Shows where hotspots are on the screen and whether or not they're active.
if (!rect.isValidRect() || rect.width() == 0 || rect.height() == 0)
return;
Graphics::Surface *screen = _vm->_system->lockScreen();
screen->frameRect(rect, color);
_vm->_system->unlockScreen();
}
示例10:
// 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);
}
示例11: drawChar
void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state, FontColor color) {
if (!ready())
return;
Common::Rect charArea = r;
charArea.clip(_screen.w, _screen.h);
uint32 rgbColor = _overlayFormat.RGBToColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b);
restoreBackground(charArea);
font->drawChar(&_screen, ch, charArea.left, charArea.top, rgbColor);
addDirtyRect(charArea);
}
示例12:
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;
}
示例13: queueBitmap
void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha) {
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
ThemeItemBitmap *q = new ThemeItemBitmap(this, area, bitmap, alpha);
if (_buffering) {
_bufferQueue.push_back(q);
} else {
q->drawSelf(true, false);
delete q;
}
}
示例14:
// 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);
}
}
}
示例15: queueDDText
void ThemeEngine::queueDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg,
bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax) {
if (_texts[type] == 0)
return;
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
ThemeItemTextData *q = new ThemeItemTextData(this, _texts[type], _textColors[color], area, text, alignH, alignV, ellipsis, restoreBg, deltax);
if (_buffering) {
_screenQueue.push_back(q);
} else {
q->drawSelf(true, false);
delete q;
}
}