本文整理汇总了C++中Rect::Intersect方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::Intersect方法的具体用法?C++ Rect::Intersect怎么用?C++ Rect::Intersect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::Intersect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyFilter
void SimpleSurface::applyFilter (Surface *inSrc, const Rect &inRect, ImagePoint inOffset, Filter *inFilter) {
if (!mBase) return;
FilterList f;
f.push_back (inFilter);
Rect src_rect (inRect.w, inRect.h);
Rect dest = GetFilteredObjectRect (f, src_rect);
inSrc->IncRef ();
Surface *result = FilterBitmap (f, inSrc, src_rect, dest, false, ImagePoint (inRect.x, inRect.y));
dest.Translate (inOffset.x, inOffset.y);
src_rect = Rect (0, 0, result->Width (), result->Height ());
int dx = dest.x;
int dy = dest.y;
dest = dest.Intersect (Rect (0, 0, mWidth, mHeight));
dest.Translate (-dx, -dy);
dest = dest.Intersect (src_rect);
dest.Translate (dx, dy);
int bpp = BytesPP ();
RenderTarget t = BeginRender (dest, false);
//printf("Copy back @ %d,%d %dx%d + (%d,%d)\n", dest.x, dest.y, t.Width(), t.Height(), dx, dy);
for (int y = 0; y < t.Height (); y++)
memcpy ((void *)(t.Row (y + dest.y) + ((dest.x) * bpp)), result->Row (y - dy) - (dx * bpp), dest.w * bpp);
EndRender ();
result->DecRef ();
}
示例2: GetBitmap
Bitmap Bitmap::GetBitmap(const Rect& area) const
{
// assert
assert( image );
// test area
if ( area.width < 1 ||
area.height < 1 ||
area.x < 0 ||
area.y < 0 ||
(area.x+area.width) > width ||
(area.y+area.height) > height )
return *this;
// clip
Rect q;
if ( !q.Intersect(GetRect(),area) )
return *this;
// new bitmap
Bitmap p(q.width,q.height,format);
// copy image
CopyImage(p.image,
image + q.y * pitch + q.x * format.GetBytes(),
p.pitch,pitch,q.height);
return p;
}
示例3: IsPaintingOp
bool SystemDraw::IsPaintingOp(const Rect& r) const
{
Rect cr = r.Offseted(GetOffset());
cr.Intersect(GetClip());
if(cr.IsEmpty())
return false;
return !invalid || gdk_region_rect_in(invalid, GdkRect(cr)) != GDK_OVERLAP_RECTANGLE_OUT;
}
示例4: surfRect
void
gfxContext::PushGroupAndCopyBackground(gfxContentType content)
{
IntRect clipExtents;
if (mDT->GetFormat() != SurfaceFormat::B8G8R8X8) {
gfxRect clipRect = GetRoundOutDeviceClipExtents(this);
clipExtents = IntRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
}
if ((mDT->GetFormat() == SurfaceFormat::B8G8R8X8 ||
mDT->GetOpaqueRect().Contains(clipExtents)) &&
!mDT->GetUserData(&sDontUseAsSourceKey)) {
DrawTarget *oldDT = mDT;
RefPtr<SourceSurface> source = mDT->Snapshot();
Point oldDeviceOffset = CurrentState().deviceOffset;
PushNewDT(gfxContentType::COLOR);
if (oldDT == mDT) {
// Creating new DT failed.
return;
}
Point offset = CurrentState().deviceOffset - oldDeviceOffset;
Rect surfRect(0, 0, Float(mDT->GetSize().width), Float(mDT->GetSize().height));
Rect sourceRect = surfRect + offset;
mDT->SetTransform(Matrix());
// XXX: It's really sad that we have to do this (for performance).
// Once DrawTarget gets a PushLayer API we can implement this within
// DrawTargetTiled.
if (source->GetType() == SurfaceType::TILED) {
SnapshotTiled *sourceTiled = static_cast<SnapshotTiled*>(source.get());
for (uint32_t i = 0; i < sourceTiled->mSnapshots.size(); i++) {
Rect tileSourceRect = sourceRect.Intersect(Rect(sourceTiled->mOrigins[i].x,
sourceTiled->mOrigins[i].y,
sourceTiled->mSnapshots[i]->GetSize().width,
sourceTiled->mSnapshots[i]->GetSize().height));
if (tileSourceRect.IsEmpty()) {
continue;
}
Rect tileDestRect = tileSourceRect - offset;
tileSourceRect -= sourceTiled->mOrigins[i];
mDT->DrawSurface(sourceTiled->mSnapshots[i], tileDestRect, tileSourceRect);
}
} else {
mDT->DrawSurface(source, surfRect, sourceRect);
}
mDT->SetOpaqueRect(oldDT->GetOpaqueRect());
PushClipsToDT(mDT);
mDT->SetTransform(GetDTTransform());
return;
}
PushGroup(content);
}
示例5: Render
bool PolygonRender::Render(const RenderTarget &inTarget, const RenderState &inState)
{
Extent2DF extent;
CachedExtentRenderer::GetExtent(inState.mTransform, extent);
if (!extent.Valid())
return true;
// Get bounding pixel rect
Rect rect = inState.mTransform.GetTargetRect(extent);
// Intersect with clip rect ...
Rect visible_pixels = rect.Intersect(inState.mClipRect);
if (visible_pixels.HasPixels())
{
// Check to see if AlphaMask is invalid...
int tx = 0;
int ty = 0;
if (mAlphaMask && !mAlphaMask->Compatible(inState.mTransform, rect,visible_pixels, tx, ty))
{
mAlphaMask->Dispose();
mAlphaMask = 0;
}
if (!mAlphaMask)
{
SetTransform(inState.mTransform);
// TODO: make visible_pixels a bit bigger ?
SpanRect span(visible_pixels, inState.mTransform.mAAFactor);
span.mWinding = GetWinding();
mSpanRect = &span;
int alpha_factor = Iterate(itCreateRenderer, *inState.mTransform.mMatrix);
mAlphaMask = mSpanRect->CreateMask(mTransform, alpha_factor);
mSpanRect = 0;
}
if (inTarget.mPixelFormat == pfAlpha)
{
mAlphaMask->RenderBitmap(tx, ty, inTarget, inState);
}
else
{
mFiller->Fill(*mAlphaMask, tx, ty, inTarget, inState);
}
}
return true;
}
示例6: BeginRender
RenderTarget SimpleSurface::BeginRender (const Rect &inRect, bool inForHitTest) {
if (!mBase)
return RenderTarget ();
Rect r = inRect.Intersect (Rect (0, 0, mWidth, mHeight));
if (mTexture)
mTexture->Dirty (r);
mVersion++;
return RenderTarget (r, mPixelFormat, mBase, mStride);
}
示例7:
void
CliWindow::Invalidate (const Rect& region)
{
Rect bounds = _canvas.GetDrawBounds();
if (bounds.Intersects(region)) {
bounds = bounds.Intersect(region);
Redraw(bounds);
if (_parent) {
bounds.Move(Bounds().TopLeft()+_parent->ClientOffset());
_parent->Invalidate(bounds);
}
}
}
示例8: Paint
bool MultiFormMgr::Paint(bool fForceBackBufferValid)
{
// Calc opaque rect
Rect rcOpaque;
rcOpaque.SetEmpty();
CalcOpaqueRect(NULL, NULL, &rcOpaque);
bool fAnyScroll = false;
int n;
for (n = 0; n < m_cfrmm; n++) {
// Paint children form mgr bits
bool fScrolled = m_apfrmm[n]->ScrollBits();
if (fForceBackBufferValid)
fScrolled = true;
if (fScrolled)
fAnyScroll = true;
// Paint / calc updatemaps for children
Rect rcT;
rcT.Intersect(&m_arcFormMgr[n], &rcOpaque);
rcT.Offset(-m_arcFormMgr[n].left, -m_arcFormMgr[n].top);
m_apfrmm[n]->Paint(fScrolled, &rcT);
}
// There is a form, need the children updatemap data to be reflected in the
// parent updatemap
for (n = 0; n < m_cfrmm; n++) {
FormMgr *pfrmm = m_apfrmm[n];
UpdateMap *pupd = pfrmm->GetUpdateMap();
Rect rcT;
bool fFirst = true;
while (pupd->EnumUpdateRects(fFirst, NULL, &rcT)) {
fFirst = false;
rcT.Offset(m_arcFormMgr[n].left, m_arcFormMgr[n].top);
m_pupd->InvalidateRect(&rcT);
}
}
// Now that the multi-form mgr has all the invalid state reflected,
// it is ok to paint
rcOpaque.SetEmpty();
FormMgr::Paint(false, &rcOpaque);
return fAnyScroll;
}
示例9: DrawRectBASE
void DrawRectBASE(PixelBlock& w, int x, int y, int cx, int cy, Color c)
{
RTIMING("DrawRect");
Rect r = RectC(x, y, cx, cy);
r.Intersect(w.GetSize());
if(r.IsEmpty())
return;
dword color = c.GetRaw();
dword *a = w.PointAdr(r.left, r.top);
int d = w.LineDelta();
cy = r.Height();
cx = r.Width();
while(cy--) {
memsetd(a, color, cx);
a += d;
}
}
示例10: AssignBigImage
void TexturedLayerMLGPU::AssignBigImage(FrameBuilder* aBuilder,
RenderViewMLGPU* aView,
BigImageIterator* aIter,
const Maybe<Polygon>& aGeometry) {
const Matrix4x4& transform = GetLayer()->GetEffectiveTransformForBuffer();
// Note that we don't need to assign these in any particular order, since
// they do not overlap.
do {
IntRect tileRect = aIter->GetTileRect();
IntRect rect = tileRect.Intersect(mPictureRect);
if (rect.IsEmpty()) {
continue;
}
{
Rect screenRect = transform.TransformBounds(Rect(rect));
screenRect.MoveBy(-aView->GetTargetOffset());
screenRect =
screenRect.Intersect(Rect(mComputedClipRect.ToUnknownRect()));
if (screenRect.IsEmpty()) {
// This tile is not in the clip region, so skip it.
continue;
}
}
RefPtr<TextureSource> tile = mBigImageTexture->ExtractCurrentTile();
if (!tile) {
continue;
}
// Create a temporary item.
RefPtr<TempImageLayerMLGPU> item =
new TempImageLayerMLGPU(aBuilder->GetManager());
item->Init(this, tile, rect);
Maybe<Polygon> geometry = aGeometry;
item->AddBoundsToView(aBuilder, aView, std::move(geometry));
// Since the layer tree is not holding this alive, we have to ask the
// FrameBuilder to do it for us.
aBuilder->RetainTemporaryLayer(item);
} while (aIter->NextTile());
}
示例11: GetLayer
IntRect
LayerMLGPU::GetClippedBoundingBox(RenderViewMLGPU* aView,
const Maybe<gfx::Polygon>& aGeometry)
{
MOZ_ASSERT(IsPrepared());
Layer* layer = GetLayer();
const Matrix4x4& transform = layer->GetEffectiveTransform();
Rect rect = aGeometry
? aGeometry->BoundingBox()
: Rect(layer->GetLocalVisibleRegion().GetBounds().ToUnknownRect());
rect = transform.TransformBounds(rect);
rect.MoveBy(-aView->GetTargetOffset());
rect = rect.Intersect(Rect(mComputedClipRect.ToUnknownRect()));
IntRect bounds;
rect.RoundOut();
rect.ToIntRect(&bounds);
return bounds;
}
示例12: InvalidateRect
void MultiFormMgr::InvalidateRect(Rect *prc)
{
// Distribute to this form mgr
Rect rcDib;
if (prc == NULL) {
Size siz;
m_pbm->GetSize(&siz);
rcDib.Set(0, 0, siz.cx, siz.cy);
prc = &rcDib;
}
// Distribute to children form mgr's
for (int n = 0; n < m_cfrmm; n++) {
Rect rcT;
if (rcT.Intersect(prc, &m_arcFormMgr[n])) {
rcT.Offset(-m_arcFormMgr[n].left, -m_arcFormMgr[n].top);
m_apfrmm[n]->InvalidateRect(&rcT);
}
}
}
示例13: Render
bool PointRenderer::Render( const RenderTarget &inTarget, const RenderState &inState )
{
Extent2DF extent;
CachedExtentRenderer::GetExtent(inState.mTransform,extent);
if (!extent.Valid())
return true;
// Get bounding pixel rect
Rect rect = inState.mTransform.GetTargetRect(extent);
// Intersect with clip rect ...
Rect visible_pixels = rect.Intersect(inState.mClipRect);
int x0 = visible_pixels.x;
int y0 = visible_pixels.y;
int x1 = visible_pixels.x1();
int y1 = visible_pixels.y1();
bool swap = gC0IsRed != (bool)(inTarget.mPixelFormat & pfSwapRB);
//bool alpha = (inTarget.mPixelFormat & pfHasAlpha);
if (!mHasColours)
{
int val = swap ? mCol.SwappedIVal() : mCol.ival;
// 100% alpha...
if ( ( (val & 0xff000000) == 0xff000000 ) || (inTarget.mPixelFormat & pfHasAlpha) )
{
for(int i=0; i<mTransformed.size(); i++)
{
const UserPoint &point = mTransformed[i];
int tx = point.x;
if (x0<=tx && tx<x1)
{
int ty = point.y;
if (y0<=ty && ty<y1)
((int *)inTarget.Row(ty))[tx] = val;
}
}
}
else
{
ARGB argb = swap ? mCol.Swapped() : mCol;
for(int i=0; i<mTransformed.size(); i++)
{
const UserPoint &point = mTransformed[i];
int tx = point.x;
if (x0<=tx && tx<x1)
{
int ty = point.y;
if (y0<=ty && ty<y1)
((ARGB *)inTarget.Row(ty))[tx].QBlendA(argb);
}
}
}
}
else
{
ARGB *argb = (ARGB *) & mData[mData0 + mTransformed.size()*2];
if (inTarget.mPixelFormat & pfHasAlpha)
for(int i=0; i<mTransformed.size(); i++)
{
const UserPoint &point = mTransformed[i];
int tx = point.x;
if (x0<=tx && tx<x1)
{
int ty = point.y;
if (y0<=ty && ty<y1)
((ARGB *)inTarget.Row(ty))[tx].QBlendA( swap? argb[i] : argb[i].Swapped() );
}
}
else
for(int i=0; i<mTransformed.size(); i++)
{
const UserPoint &point = mTransformed[i];
int tx = point.x;
if (x0<=tx && tx<x1)
{
int ty = point.y;
if (y0<=ty && ty<y1)
((ARGB *)inTarget.Row(ty))[tx].QBlend( swap? argb[i].Swapped() : argb[i] );
}
}
}
return true;
}
示例14: Render
bool Render(const RenderTarget &inTarget, const RenderState &inState)
{
Surface *s = mFill->bitmapData;
double bmp_scale_x = 1.0/s->Width();
double bmp_scale_y = 1.0/s->Height();
// Todo:skew
bool is_stretch = (inState.mTransform.mMatrix->m00!=1.0 ||
inState.mTransform.mMatrix->m11!=1.0) &&
( inState.mTransform.mMatrix->m00 > 0 &&
inState.mTransform.mMatrix->m11 > 0 );
for(int i=0; i<mTileData.size(); i++)
{
TileData &data= mTileData[i];
BlendMode blend = data.mHasColour ? ( mBlendMode==bmAdd ? bmTintedAdd : bmTinted ):
mBlendMode;
UserPoint corner(data.mPos);
UserPoint pos = inState.mTransform.mMatrix->Apply(corner.x,corner.y);
if (s->Format()==pfAlpha && !is_stretch && mBlendMode==bmNormal && data.mHasColour /* integer co-ordinate?*/ )
{
unsigned int col = inState.mColourTransform->Transform(data.mColour|0xff000000);
s->BlitTo(inTarget, data.mRect, (int)(pos.x), (int)(pos.y), blend, 0, col);
}
else if ( (is_stretch || data.mHasTrans) )
{
// Can use stretch if there is no skew and no colour transform...
if (!data.mHasColour && (!data.mHasTrans) && mBlendMode==bmNormal )
{
UserPoint p0 = pos;
pos = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y+data.mRect.h);
s->StretchTo(inTarget, data.mRect, DRect(p0.x,p0.y,pos.x,pos.y,true));
}
else
{
int tile_alpha = 256;
bool just_alpha = (data.mHasColour) &&
((data.mColour&0x00ffffff ) == 0x00ffffff);
if (data.mHasColour && mBlendMode==bmNormal)
{
tile_alpha = data.mColour>>24;
if (tile_alpha>0) tile_alpha++;
}
// Create alpha mask...
UserPoint p[4];
p[0] = inState.mTransform.mMatrix->Apply(corner.x,corner.y);
if (data.mHasTrans)
{
p[1] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.w*data.mTransX.x,
corner.y + data.mRect.w*data.mTransY.x);
p[2] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.w*data.mTransX.x + data.mRect.h*data.mTransX.y,
corner.y + data.mRect.w*data.mTransY.x + data.mRect.h*data.mTransY.y );
p[3] = inState.mTransform.mMatrix->Apply(
corner.x + data.mRect.h*data.mTransX.y,
corner.y + data.mRect.h*data.mTransY.y );
}
else
{
p[1] = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y);
p[2] = inState.mTransform.mMatrix->Apply(corner.x+data.mRect.w,corner.y+data.mRect.h);
p[3] = inState.mTransform.mMatrix->Apply(corner.x,corner.y+data.mRect.h);
}
Extent2DF extent;
extent.Add(p[0]);
extent.Add(p[1]);
extent.Add(p[2]);
extent.Add(p[3]);
// Get bounding pixel rect
Rect rect = inState.mTransform.GetTargetRect(extent);
// Intersect with clip rect ...
Rect visible_pixels = rect.Intersect(inState.mClipRect);
if (!visible_pixels.HasPixels())
continue;
Rect alpha_rect(visible_pixels);
bool offscreen_buffer = mBlendMode!=bmNormal;
if (offscreen_buffer)
{
for(int i=0; i<4; i++)
{
p[i].x -= visible_pixels.x;
p[i].y -= visible_pixels.y;
}
alpha_rect.x -= visible_pixels.x;
alpha_rect.y -= visible_pixels.y;
}
int aa = 1;
SpanRect *span = new SpanRect(alpha_rect,aa);
for(int i=0; i<4; i++)
span->Line00(
Fixed10( p[i].x, p[i].y ),
Fixed10( p[(i+1)&3].x, p[(i+1)&3].y) );
//.........这里部分代码省略.........
示例15: Render
bool Render(const RenderTarget &inTarget, const RenderState &inState)
{
if (mTriangles->mUVT.empty())
return PolygonRender::Render(inTarget,inState);
Extent2DF extent;
CachedExtentRenderer::GetExtent(inState.mTransform,extent,true);
if (!extent.Valid())
return true;
// Get bounding pixel rect
Rect rect = inState.mTransform.GetTargetRect(extent);
// Intersect with clip rect ...
Rect visible_pixels = rect.Intersect(inState.mClipRect);
int tris = mTriangles->mTriangleCount;
UserPoint *point = &mTransformed[0];
bool *edge_aa = &mEdgeAA[0];
float *uvt = &mTriangles->mUVT[0];
int tex_components = mTriangles->mType == vtVertex ? 0 : mTriangles->mType==vtVertexUV ? 2 : 3;
int aa = inState.mTransform.mAAFactor;
bool aa1 = aa==1;
for(int i=0;i<tris;i++)
{
// For each alpha mask ...
// Check to see if AlphaMask is invalid...
AlphaMask *&alpha = mAlphaMasks[i];
int tx=0;
int ty=0;
if (alpha && !alpha->Compatible(inState.mTransform, rect,visible_pixels,tx,ty))
{
alpha->Dispose();
alpha = 0;
}
if (!alpha)
{
SetTransform(inState.mTransform);
SpanRect *span = new SpanRect(visible_pixels,inState.mTransform.mAAFactor);
if (aa1 || edge_aa[0])
span->Line01( mTransform.ToImageAA(point[0]),mTransform.ToImageAA(point[1]) );
else
span->Line11( mTransform.ToImageAA(point[0]),mTransform.ToImageAA(point[1]) );
if (aa1 || edge_aa[1])
span->Line01( mTransform.ToImageAA(point[1]),mTransform.ToImageAA(point[2]) );
else
span->Line11( mTransform.ToImageAA(point[1]),mTransform.ToImageAA(point[2]) );
if (aa1 || edge_aa[2])
span->Line01( mTransform.ToImageAA(point[2]),mTransform.ToImageAA(point[0]) );
else
span->Line11( mTransform.ToImageAA(point[2]),mTransform.ToImageAA(point[0]) );
alpha = span->CreateMask(mTransform,256);
delete span;
}
if (inTarget.mPixelFormat==pfAlpha)
{
alpha->RenderBitmap(tx,ty,inTarget,inState);
}
else
{
if (tex_components)
mFiller->SetMapping(point,uvt,tex_components);
mFiller->Fill(*alpha,tx,ty,inTarget,inState);
}
point += 3;
uvt+=tex_components*3;
edge_aa += 3;
}
mMappingDirty = false;
return true;
}