本文整理汇总了C++中gfx::IntRect::TopLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ IntRect::TopLeft方法的具体用法?C++ IntRect::TopLeft怎么用?C++ IntRect::TopLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gfx::IntRect
的用法示例。
在下文中一共展示了IntRect::TopLeft方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: desc
TemporaryRef<CompositingRenderTarget>
CompositorD3D11::CreateRenderTargetFromSource(const gfx::IntRect &aRect,
const CompositingRenderTarget* aSource,
const gfx::IntPoint &aSourcePoint)
{
MOZ_ASSERT(aRect.width != 0 && aRect.height != 0);
if (aRect.width * aRect.height == 0) {
return nullptr;
}
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
aRect.width, aRect.height, 1, 1,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
RefPtr<ID3D11Texture2D> texture;
HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture));
NS_ASSERTION(texture, "Could not create texture");
if (Failed(hr) || !texture) {
return nullptr;
}
if (aSource) {
const CompositingRenderTargetD3D11* sourceD3D11 =
static_cast<const CompositingRenderTargetD3D11*>(aSource);
D3D11_BOX srcBox;
srcBox.left = aSourcePoint.x;
srcBox.top = aSourcePoint.y;
srcBox.front = 0;
srcBox.right = aSourcePoint.x + aRect.width;
srcBox.bottom = aSourcePoint.y + aRect.height;
srcBox.back = 1;
const IntSize& srcSize = sourceD3D11->GetSize();
MOZ_ASSERT(srcSize.width >= 0 && srcSize.height >= 0,
"render targets should have nonnegative sizes");
if (srcBox.left >= 0 &&
srcBox.top >= 0 &&
srcBox.left < srcBox.right &&
srcBox.top < srcBox.bottom &&
srcBox.right <= static_cast<uint32_t>(srcSize.width) &&
srcBox.bottom <= static_cast<uint32_t>(srcSize.height)) {
mContext->CopySubresourceRegion(texture, 0,
0, 0, 0,
sourceD3D11->GetD3D11Texture(), 0,
&srcBox);
} else {
NS_WARNING("Could not copy render target - source rect out of bounds");
}
}
RefPtr<CompositingRenderTargetD3D11> rt =
new CompositingRenderTargetD3D11(texture, aRect.TopLeft());
rt->SetSize(aRect.Size());
return rt;
}
示例2: renderBounds
gfx::IntRect
ComputeBackdropCopyRect(const gfx::Rect& aRect,
const gfx::IntRect& aClipRect,
const gfx::Matrix4x4& aTransform,
const gfx::IntRect& aRenderTargetRect,
gfx::Matrix4x4* aOutTransform,
gfx::Rect* aOutLayerQuad)
{
// Compute the clip.
IntPoint rtOffset = aRenderTargetRect.TopLeft();
IntSize rtSize = aRenderTargetRect.Size();
gfx::IntRect renderBounds(0, 0, rtSize.width, rtSize.height);
renderBounds.IntersectRect(renderBounds, aClipRect);
renderBounds.MoveBy(rtOffset);
// Apply the layer transform.
RectDouble dest = aTransform.TransformAndClipBounds(
RectDouble(aRect.x, aRect.y, aRect.width, aRect.height),
RectDouble(renderBounds.x, renderBounds.y, renderBounds.width, renderBounds.height));
dest -= rtOffset;
// Ensure we don't round out to -1, which trips up Direct3D.
dest.IntersectRect(dest, RectDouble(0, 0, rtSize.width, rtSize.height));
if (aOutLayerQuad) {
*aOutLayerQuad = Rect(dest.x, dest.y, dest.width, dest.height);
}
// Round out to integer.
IntRect result;
dest.RoundOut();
dest.ToIntRect(&result);
// Create a transform from adjusted clip space to render target space,
// translate it for the backdrop rect, then transform it into the backdrop's
// uv-space.
Matrix4x4 transform;
transform.PostScale(rtSize.width, rtSize.height, 1.0);
transform.PostTranslate(-result.x, -result.y, 0.0);
transform.PostScale(1 / float(result.width), 1 / float(result.height), 1.0);
*aOutTransform = transform;
return result;
}
示例3: backdropLock
void
CompositorD3D9::FinishMixBlend(const gfx::IntRect& aBackdropRect,
const gfx::Rect& aBackdropDest,
const gfx::Matrix4x4& aBackdropTransform,
RefPtr<IDirect3DTexture9> aBackdrop,
gfx::CompositionOp aBlendMode)
{
HRESULT hr;
RefPtr<IDirect3DTexture9> source =
CreateTexture(aBackdropRect, mCurrentRT, aBackdropRect.TopLeft());
if (!source) {
return;
}
// Slow path - do everything in software. Unfortunately this requires
// a lot of copying, since we have to readback the source and backdrop,
// then upload the blended result, then blit it back.
IDirect3DDevice9* d3d9Device = device();
// Query geometry/format of the two surfaces.
D3DSURFACE_DESC backdropDesc, sourceDesc;
if (FAILED(aBackdrop->GetLevelDesc(0, &backdropDesc)) ||
FAILED(source->GetLevelDesc(0, &sourceDesc)))
{
gfxCriticalNote << "Failed to query mix-blend texture descriptor";
return;
}
MOZ_ASSERT(backdropDesc.Format == D3DFMT_A8R8G8B8);
MOZ_ASSERT(sourceDesc.Format == D3DFMT_A8R8G8B8);
// Acquire a temporary data surface for the backdrop texture.
RefPtr<IDirect3DSurface9> backdropSurface = GetSurfaceOfTexture(aBackdrop);
if (!backdropSurface) {
return;
}
RefPtr<IDirect3DSurface9> tmpBackdrop =
CreateDataSurfaceForTexture(d3d9Device, backdropSurface, backdropDesc);
if (!tmpBackdrop) {
return;
}
// New scope for locks and temporary surfaces.
{
// Acquire a temporary data surface for the source texture.
RefPtr<IDirect3DSurface9> sourceSurface = GetSurfaceOfTexture(source);
if (!sourceSurface) {
return;
}
RefPtr<IDirect3DSurface9> tmpSource =
CreateDataSurfaceForTexture(d3d9Device, sourceSurface, sourceDesc);
if (!tmpSource) {
return;
}
// Perform the readback and blend in software.
AutoSurfaceLock backdropLock(tmpBackdrop);
AutoSurfaceLock sourceLock(tmpSource, D3DLOCK_READONLY);
if (!backdropLock.Okay() || !sourceLock.Okay()) {
return;
}
RefPtr<DataSourceSurface> source = Factory::CreateWrappingDataSourceSurface(
sourceLock.Bits(), sourceLock.Pitch(),
gfx::IntSize(sourceDesc.Width, sourceDesc.Height),
SurfaceFormat::B8G8R8A8);
RefPtr<DrawTarget> dest = Factory::CreateDrawTargetForData(
BackendType::CAIRO,
backdropLock.Bits(),
gfx::IntSize(backdropDesc.Width, backdropDesc.Height),
backdropLock.Pitch(),
SurfaceFormat::B8G8R8A8);
// The backdrop rect is rounded out - account for any difference between
// it and the actual destination.
gfx::Rect destRect(
aBackdropDest.x - aBackdropRect.x,
aBackdropDest.y - aBackdropRect.y,
aBackdropDest.width,
aBackdropDest.height);
dest->DrawSurface(
source, destRect, destRect,
gfx::DrawSurfaceOptions(),
gfx::DrawOptions(1.0f, aBlendMode));
}
// Upload the new blended surface to the backdrop texture.
d3d9Device->UpdateSurface(tmpBackdrop, nullptr, backdropSurface, nullptr);
// Finally, drop in the new backdrop. We don't need to do another
// DrawPrimitive() since the software blend will have included the
// final OP_OVER step for us.
RECT destRect = {
aBackdropRect.x, aBackdropRect.y,
aBackdropRect.XMost(), aBackdropRect.YMost()
};
//.........这里部分代码省略.........
示例4: scopedScissorTestState
void
GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const gfx::IntRect& aSrcRect,
TextureImage *aDst, const gfx::IntRect& aDstRect)
{
GLContext *gl = mCompositor->gl();
if (!aSrc || !aDst || aSrcRect.IsEmpty() || aDstRect.IsEmpty())
return;
int savedFb = 0;
gl->fGetIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &savedFb);
ScopedGLState scopedScissorTestState(gl, LOCAL_GL_SCISSOR_TEST, false);
ScopedGLState scopedBlendState(gl, LOCAL_GL_BLEND, false);
// 2.0 means scale up by two
float blitScaleX = float(aDstRect.width) / float(aSrcRect.width);
float blitScaleY = float(aDstRect.height) / float(aSrcRect.height);
// We start iterating over all destination tiles
aDst->BeginBigImageIteration();
do {
// calculate portion of the tile that is going to be painted to
gfx::IntRect dstSubRect;
gfx::IntRect dstTextureRect = aDst->GetTileRect();
dstSubRect.IntersectRect(aDstRect, dstTextureRect);
// this tile is not part of the destination rectangle aDstRect
if (dstSubRect.IsEmpty())
continue;
// (*) transform the rect of this tile into the rectangle defined by aSrcRect...
gfx::IntRect dstInSrcRect(dstSubRect);
dstInSrcRect.MoveBy(-aDstRect.TopLeft());
// ...which might be of different size, hence scale accordingly
dstInSrcRect.ScaleRoundOut(1.0f / blitScaleX, 1.0f / blitScaleY);
dstInSrcRect.MoveBy(aSrcRect.TopLeft());
SetBlitFramebufferForDestTexture(aDst->GetTextureID());
UseBlitProgram();
aSrc->BeginBigImageIteration();
// now iterate over all tiles in the source Image...
do {
// calculate portion of the source tile that is in the source rect
gfx::IntRect srcSubRect;
gfx::IntRect srcTextureRect = aSrc->GetTileRect();
srcSubRect.IntersectRect(aSrcRect, srcTextureRect);
// this tile is not part of the source rect
if (srcSubRect.IsEmpty()) {
continue;
}
// calculate intersection of source rect with destination rect
srcSubRect.IntersectRect(srcSubRect, dstInSrcRect);
// this tile does not overlap the current destination tile
if (srcSubRect.IsEmpty()) {
continue;
}
// We now have the intersection of
// the current source tile
// and the desired source rectangle
// and the destination tile
// and the desired destination rectange
// in destination space.
// We need to transform this back into destination space, inverting the transform from (*)
gfx::IntRect srcSubInDstRect(srcSubRect);
srcSubInDstRect.MoveBy(-aSrcRect.TopLeft());
srcSubInDstRect.ScaleRoundOut(blitScaleX, blitScaleY);
srcSubInDstRect.MoveBy(aDstRect.TopLeft());
// we transform these rectangles to be relative to the current src and dst tiles, respectively
gfx::IntSize srcSize = srcTextureRect.Size();
gfx::IntSize dstSize = dstTextureRect.Size();
srcSubRect.MoveBy(-srcTextureRect.x, -srcTextureRect.y);
srcSubInDstRect.MoveBy(-dstTextureRect.x, -dstTextureRect.y);
float dx0 = 2.0f * float(srcSubInDstRect.x) / float(dstSize.width) - 1.0f;
float dy0 = 2.0f * float(srcSubInDstRect.y) / float(dstSize.height) - 1.0f;
float dx1 = 2.0f * float(srcSubInDstRect.x + srcSubInDstRect.width) / float(dstSize.width) - 1.0f;
float dy1 = 2.0f * float(srcSubInDstRect.y + srcSubInDstRect.height) / float(dstSize.height) - 1.0f;
ScopedViewportRect autoViewportRect(gl, 0, 0, dstSize.width, dstSize.height);
RectTriangles rects;
gfx::IntSize realTexSize = srcSize;
if (!CanUploadNonPowerOfTwo(gl)) {
realTexSize = gfx::IntSize(RoundUpPow2(srcSize.width),
RoundUpPow2(srcSize.height));
}
if (aSrc->GetWrapMode() == LOCAL_GL_REPEAT) {
rects.addRect(/* dest rectangle */
dx0, dy0, dx1, dy1,
/* tex coords */
srcSubRect.x / float(realTexSize.width),
srcSubRect.y / float(realTexSize.height),
srcSubRect.XMost() / float(realTexSize.width),
srcSubRect.YMost() / float(realTexSize.height));
} else {
//.........这里部分代码省略.........