本文整理汇总了C++中nsIntRect::XMost方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIntRect::XMost方法的具体用法?C++ nsIntRect::XMost怎么用?C++ nsIntRect::XMost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIntRect
的用法示例。
在下文中一共展示了nsIntRect::XMost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IntersectRect
// Computes the area in which aRect1 and aRect2 overlap and fills 'this' with
// the result. Returns FALSE if the rectangles don't intersect.
PRBool nsIntRect::IntersectRect(const nsIntRect &aRect1, const nsIntRect &aRect2)
{
PRInt32 xmost1 = aRect1.XMost();
PRInt32 ymost1 = aRect1.YMost();
PRInt32 xmost2 = aRect2.XMost();
PRInt32 ymost2 = aRect2.YMost();
PRInt32 temp;
x = PR_MAX(aRect1.x, aRect2.x);
y = PR_MAX(aRect1.y, aRect2.y);
// Compute the destination width
temp = PR_MIN(xmost1, xmost2);
if (temp <= x) {
Empty();
return PR_FALSE;
}
width = temp - x;
// Compute the destination height
temp = PR_MIN(ymost1, ymost2);
if (temp <= y) {
Empty();
return PR_FALSE;
}
height = temp - y;
return PR_TRUE;
}
示例2:
/**
* Identical to BoxBlurHorizontal, except it blurs top and bottom instead of
* left and right.
* XXX shouldn't we pass stride in separately here?
*/
static void
BoxBlurVertical(unsigned char* aInput,
unsigned char* aOutput,
PRInt32 aTopLobe,
PRInt32 aBottomLobe,
PRInt32 aWidth,
PRInt32 aRows,
const nsIntRect& aSkipRect)
{
NS_ASSERTION(aRows > 0, "Can't handle zero rows here");
PRInt32 boxSize = aTopLobe + aBottomLobe + 1;
PRBool skipRectCoversWholeColumn = 0 >= aSkipRect.y &&
aRows <= aSkipRect.YMost();
for (PRInt32 x = 0; x < aWidth; x++) {
PRBool inSkipRectX = x >= aSkipRect.x &&
x < aSkipRect.XMost();
if (inSkipRectX && skipRectCoversWholeColumn) {
x = aSkipRect.XMost() - 1;
continue;
}
PRInt32 alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = i - aTopLobe;
// See assertion above; if aRows is zero, then we would have no
// valid position to clamp to.
pos = NS_MAX(pos, 0);
pos = NS_MIN(pos, aRows - 1);
alphaSum += aInput[aWidth * pos + x];
}
for (PRInt32 y = 0; y < aRows; y++) {
if (inSkipRectX && y >= aSkipRect.y &&
y < aSkipRect.YMost()) {
y = aSkipRect.YMost();
if (y >= aRows)
break;
alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = y + i - aTopLobe;
// See assertion above; if aRows is zero, then we would have no
// valid position to clamp to.
pos = NS_MAX(pos, 0);
pos = NS_MIN(pos, aRows - 1);
alphaSum += aInput[aWidth * pos + x];
}
}
PRInt32 tmp = y - aTopLobe;
PRInt32 last = NS_MAX(tmp, 0);
PRInt32 next = NS_MIN(tmp + boxSize, aRows - 1);
aOutput[aWidth * y + x] = alphaSum/boxSize;
alphaSum += aInput[aWidth * next + x] -
aInput[aWidth * last + x];
}
}
}
示例3: UnionRect
// Computes the smallest rectangle that contains both aRect1 and aRect2 and
// fills 'this' with the result. Returns FALSE if both aRect1 and aRect2 are
// empty and TRUE otherwise
PRBool nsIntRect::UnionRect(const nsIntRect &aRect1, const nsIntRect &aRect2)
{
PRBool result = PR_TRUE;
// Is aRect1 empty?
if (aRect1.IsEmpty()) {
if (aRect2.IsEmpty()) {
// Both rectangles are empty which is an error
Empty();
result = PR_FALSE;
} else {
// aRect1 is empty so set the result to aRect2
*this = aRect2;
}
} else if (aRect2.IsEmpty()) {
// aRect2 is empty so set the result to aRect1
*this = aRect1;
} else {
PRInt32 xmost1 = aRect1.XMost();
PRInt32 xmost2 = aRect2.XMost();
PRInt32 ymost1 = aRect1.YMost();
PRInt32 ymost2 = aRect2.YMost();
// Compute the origin
x = PR_MIN(aRect1.x, aRect2.x);
y = PR_MIN(aRect1.y, aRect2.y);
// Compute the size
width = PR_MAX(xmost1, xmost2) - x;
height = PR_MAX(ymost1, ymost2) - y;
}
return result;
}
示例4:
/**
* Identical to BoxBlurHorizontal, except it blurs top and bottom instead of
* left and right.
* XXX shouldn't we pass stride in separately here?
*/
static void
BoxBlurVertical(unsigned char* aInput,
unsigned char* aOutput,
PRInt32 aTopLobe,
PRInt32 aBottomLobe,
PRInt32 aWidth,
PRInt32 aRows,
const nsIntRect& aSkipRect)
{
PRInt32 boxSize = aTopLobe + aBottomLobe + 1;
PRBool skipRectCoversWholeColumn = 0 >= aSkipRect.y &&
aRows <= aSkipRect.YMost();
for (PRInt32 x = 0; x < aWidth; x++) {
PRBool inSkipRectX = x >= aSkipRect.x &&
x < aSkipRect.XMost();
if (inSkipRectX && skipRectCoversWholeColumn) {
x = aSkipRect.XMost() - 1;
continue;
}
PRInt32 alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = i - aTopLobe;
pos = NS_MAX(pos, 0);
pos = NS_MIN(pos, aRows - 1);
alphaSum += aInput[aWidth * pos + x];
}
for (PRInt32 y = 0; y < aRows; y++) {
if (inSkipRectX && y >= aSkipRect.y &&
y < aSkipRect.YMost()) {
y = aSkipRect.YMost();
if (y >= aRows)
break;
alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = y + i - aTopLobe;
pos = NS_MAX(pos, 0);
pos = NS_MIN(pos, aRows - 1);
alphaSum += aInput[aWidth * pos + x];
}
}
PRInt32 tmp = y - aTopLobe;
PRInt32 last = NS_MAX(tmp, 0);
PRInt32 next = NS_MIN(tmp + boxSize, aRows - 1);
aOutput[aWidth * y + x] = alphaSum/boxSize;
alphaSum += aInput[aWidth * next + x] -
aInput[aWidth * last + x];
}
}
}
示例5: memset
static void
ComputesRGBLuminanceMask(uint8_t *aData,
int32_t aStride,
const nsIntRect &aRect,
float aOpacity)
{
for (int32_t y = aRect.y; y < aRect.YMost(); y++) {
for (int32_t x = aRect.x; x < aRect.XMost(); x++) {
uint8_t *pixel = aData + aStride * y + 4 * x;
uint8_t a = pixel[GFX_ARGB32_OFFSET_A];
uint8_t luminance;
if (a) {
/* sRGB -> intensity (unpremultiply cancels out the
* (a/255.0) multiplication with aOpacity */
luminance =
static_cast<uint8_t>
((pixel[GFX_ARGB32_OFFSET_R] * 0.2125 +
pixel[GFX_ARGB32_OFFSET_G] * 0.7154 +
pixel[GFX_ARGB32_OFFSET_B] * 0.0721) *
aOpacity);
} else {
luminance = 0;
}
memset(pixel, luminance, 4);
}
}
}
示例6:
void
nsSVGUtils::UnPremultiplyImageDataAlpha(PRUint8 *data,
PRInt32 stride,
const nsIntRect &rect)
{
for (PRInt32 y = rect.y; y < rect.YMost(); y++) {
for (PRInt32 x = rect.x; x < rect.XMost(); x++) {
PRUint8 *pixel = data + stride * y + 4 * x;
PRUint8 a = pixel[GFX_ARGB32_OFFSET_A];
if (a == 255)
continue;
if (a) {
pixel[GFX_ARGB32_OFFSET_B] = (255 * pixel[GFX_ARGB32_OFFSET_B]) / a;
pixel[GFX_ARGB32_OFFSET_G] = (255 * pixel[GFX_ARGB32_OFFSET_G]) / a;
pixel[GFX_ARGB32_OFFSET_R] = (255 * pixel[GFX_ARGB32_OFFSET_R]) / a;
} else {
pixel[GFX_ARGB32_OFFSET_B] = 0;
pixel[GFX_ARGB32_OFFSET_G] = 0;
pixel[GFX_ARGB32_OFFSET_R] = 0;
}
}
}
}
示例7: tmp
void
SVGFEGaussianBlurElement::GaussianBlur(const Image* aSource,
const Image* aTarget,
const nsIntRect& aDataRect,
uint32_t aDX, uint32_t aDY)
{
NS_ASSERTION(nsIntRect(0, 0, aTarget->mImage->Width(), aTarget->mImage->Height()).Contains(aDataRect),
"aDataRect out of bounds");
nsAutoArrayPtr<uint8_t> tmp(new uint8_t[aTarget->mImage->GetDataSize()]);
if (!tmp)
return;
memset(tmp, 0, aTarget->mImage->GetDataSize());
bool alphaOnly = AreAllColorChannelsZero(aTarget);
const uint8_t* sourceData = aSource->mImage->Data();
uint8_t* targetData = aTarget->mImage->Data();
uint32_t stride = aTarget->mImage->Stride();
if (aDX == 0) {
CopyDataRect(tmp, sourceData, stride, aDataRect);
} else {
int32_t longLobe = aDX/2;
int32_t shortLobe = (aDX & 1) ? longLobe : longLobe - 1;
for (int32_t major = aDataRect.y; major < aDataRect.YMost(); ++major) {
int32_t ms = major*stride;
BoxBlur(sourceData + ms, tmp + ms, 4, aDataRect.x, aDataRect.XMost(), longLobe, shortLobe, alphaOnly);
BoxBlur(tmp + ms, targetData + ms, 4, aDataRect.x, aDataRect.XMost(), shortLobe, longLobe, alphaOnly);
BoxBlur(targetData + ms, tmp + ms, 4, aDataRect.x, aDataRect.XMost(), longLobe, longLobe, alphaOnly);
}
}
if (aDY == 0) {
CopyDataRect(targetData, tmp, stride, aDataRect);
} else {
int32_t longLobe = aDY/2;
int32_t shortLobe = (aDY & 1) ? longLobe : longLobe - 1;
for (int32_t major = aDataRect.x; major < aDataRect.XMost(); ++major) {
int32_t ms = major*4;
BoxBlur(tmp + ms, targetData + ms, stride, aDataRect.y, aDataRect.YMost(), longLobe, shortLobe, alphaOnly);
BoxBlur(targetData + ms, tmp + ms, stride, aDataRect.y, aDataRect.YMost(), shortLobe, longLobe, alphaOnly);
BoxBlur(tmp + ms, targetData + ms, stride, aDataRect.y, aDataRect.YMost(), longLobe, longLobe, alphaOnly);
}
}
}
示例8: gfxPoint
// Clip aTarget's image to its filter primitive subregion.
// aModifiedRect contains all the pixels which might not be RGBA(0,0,0,0),
// it's relative to the surface data.
static void
ClipTarget(nsSVGFilterInstance* aInstance, const nsSVGFE::Image* aTarget,
const nsIntRect& aModifiedRect)
{
nsIntPoint surfaceTopLeft = aInstance->GetSurfaceRect().TopLeft();
NS_ASSERTION(aInstance->GetSurfaceRect().Contains(aModifiedRect + surfaceTopLeft),
"Modified data area overflows the surface?");
nsIntRect clip = aModifiedRect;
nsSVGUtils::ClipToGfxRect(&clip,
aTarget->mFilterPrimitiveSubregion - gfxPoint(surfaceTopLeft.x, surfaceTopLeft.y));
ClearRect(aTarget->mImage, aModifiedRect.x, aModifiedRect.y, aModifiedRect.XMost(), clip.y);
ClearRect(aTarget->mImage, aModifiedRect.x, clip.y, clip.x, clip.YMost());
ClearRect(aTarget->mImage, clip.XMost(), clip.y, aModifiedRect.XMost(), clip.YMost());
ClearRect(aTarget->mImage, aModifiedRect.x, clip.YMost(), aModifiedRect.XMost(), aModifiedRect.YMost());
}
示例9: GLuint
// |aTexCoordRect| is the rectangle from the texture that we want to
// draw using the given program. The program already has a necessary
// offset and scale, so the geometry that needs to be drawn is a unit
// square from 0,0 to 1,1.
//
// |aTexSize| is the actual size of the texture, as it can be larger
// than the rectangle given by |aTexCoordRect|.
void
LayerManagerOGL::BindAndDrawQuadWithTextureRect(LayerProgram *aProg,
const nsIntRect& aTexCoordRect,
const nsIntSize& aTexSize,
GLenum aWrapMode)
{
GLuint vertAttribIndex =
aProg->AttribLocation(LayerProgram::VertexAttrib);
GLuint texCoordAttribIndex =
aProg->AttribLocation(LayerProgram::TexCoordAttrib);
NS_ASSERTION(texCoordAttribIndex != GLuint(-1), "no texture coords?");
// clear any bound VBO so that glVertexAttribPointer() goes back to
// "pointer mode"
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
// Given what we know about these textures and coordinates, we can
// compute fmod(t, 1.0f) to get the same texture coordinate out. If
// the texCoordRect dimension is < 0 or > width/height, then we have
// wraparound that we need to deal with by drawing multiple quads,
// because we can't rely on full non-power-of-two texture support
// (which is required for the REPEAT wrap mode).
GLContext::RectTriangles rects;
if (aWrapMode == LOCAL_GL_REPEAT) {
rects.addRect(/* dest rectangle */
0.0f, 0.0f, 1.0f, 1.0f,
/* tex coords */
aTexCoordRect.x / GLfloat(aTexSize.width),
aTexCoordRect.y / GLfloat(aTexSize.height),
aTexCoordRect.XMost() / GLfloat(aTexSize.width),
aTexCoordRect.YMost() / GLfloat(aTexSize.height));
} else {
GLContext::DecomposeIntoNoRepeatTriangles(aTexCoordRect, aTexSize, rects);
}
mGLContext->fVertexAttribPointer(vertAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
rects.vertexPointer());
mGLContext->fVertexAttribPointer(texCoordAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
rects.texCoordPointer());
{
mGLContext->fEnableVertexAttribArray(texCoordAttribIndex);
{
mGLContext->fEnableVertexAttribArray(vertAttribIndex);
mGLContext->fDrawArrays(LOCAL_GL_TRIANGLES, 0, rects.elements());
mGLContext->fDisableVertexAttribArray(vertAttribIndex);
}
mGLContext->fDisableVertexAttribArray(texCoordAttribIndex);
}
}
示例10:
void
SwapChainD3D9::Present(const nsIntRect &aRect)
{
RECT r;
r.left = aRect.x;
r.top = aRect.y;
r.right = aRect.XMost();
r.bottom = aRect.YMost();
mSwapChain->Present(&r, &r, 0, 0, 0);
}
示例11: jniFrame
void
AndroidGeckoLayerClient::SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect)
{
NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
if (!env)
return;
AutoLocalJNIFrame jniFrame(env, 0);
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, (float)aOffset.x, (float)aOffset.y, aZoom,
(float)aPageRect.x, (float)aPageRect.y, (float)aPageRect.XMost(), (float)aPageRect.YMost(),
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
}
示例12: RotateRect
nsIntRect RotateRect(nsIntRect aRect,
const nsIntRect& aBounds,
ScreenRotation aRotation)
{
switch (aRotation) {
case ROTATION_0:
return aRect;
case ROTATION_90:
return nsIntRect(aRect.Y(),
aBounds.Width() - aRect.XMost(),
aRect.Height(), aRect.Width());
case ROTATION_180:
return nsIntRect(aBounds.Width() - aRect.XMost(),
aBounds.Height() - aRect.YMost(),
aRect.Width(), aRect.Height());
case ROTATION_270:
return nsIntRect(aBounds.Height() - aRect.YMost(),
aRect.X(),
aRect.Height(), aRect.Width());
default:
MOZ_CRASH("Unknown rotation");
}
}
示例13: gfxContext
already_AddRefed<gfxContext>
ThebesLayerBuffer::GetContextForQuadrantUpdate(const nsIntRect& aBounds)
{
nsRefPtr<gfxContext> ctx = new gfxContext(mBuffer);
// Figure out which quadrant to draw in
PRInt32 xBoundary = mBufferRect.XMost() - mBufferRotation.x;
PRInt32 yBoundary = mBufferRect.YMost() - mBufferRotation.y;
XSide sideX = aBounds.XMost() <= xBoundary ? RIGHT : LEFT;
YSide sideY = aBounds.YMost() <= yBoundary ? BOTTOM : TOP;
nsIntRect quadrantRect = GetQuadrantRectangle(sideX, sideY);
NS_ASSERTION(quadrantRect.Contains(aBounds), "Messed up quadrants");
ctx->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
return ctx.forget();
}
示例14: gfxContext
already_AddRefed<gfxContext>
RotatedContentBuffer::GetContextForQuadrantUpdate(const nsIntRect& aBounds,
ContextSource aSource,
nsIntPoint *aTopLeft)
{
if (!EnsureBuffer()) {
return nullptr;
}
nsRefPtr<gfxContext> ctx;
if (aSource == BUFFER_BOTH && HaveBufferOnWhite()) {
if (!EnsureBufferOnWhite()) {
return nullptr;
}
MOZ_ASSERT(mDTBuffer && mDTBufferOnWhite);
RefPtr<DrawTarget> dualDT = Factory::CreateDualDrawTarget(mDTBuffer, mDTBufferOnWhite);
ctx = new gfxContext(dualDT);
} else if (aSource == BUFFER_WHITE) {
if (!EnsureBufferOnWhite()) {
return nullptr;
}
ctx = new gfxContext(mDTBufferOnWhite);
} else {
// BUFFER_BLACK, or BUFFER_BOTH with a single buffer.
ctx = new gfxContext(mDTBuffer);
}
// Figure out which quadrant to draw in
int32_t xBoundary = mBufferRect.XMost() - mBufferRotation.x;
int32_t yBoundary = mBufferRect.YMost() - mBufferRotation.y;
XSide sideX = aBounds.XMost() <= xBoundary ? RIGHT : LEFT;
YSide sideY = aBounds.YMost() <= yBoundary ? BOTTOM : TOP;
nsIntRect quadrantRect = GetQuadrantRectangle(sideX, sideY);
NS_ASSERTION(quadrantRect.Contains(aBounds), "Messed up quadrants");
ctx->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
if (aTopLeft) {
*aTopLeft = nsIntPoint(quadrantRect.x, quadrantRect.y);
}
return ctx.forget();
}
示例15: while
/* static */
void
WinUtils::InvalidatePluginAsWorkaround(nsIWidget *aWidget, const nsIntRect &aRect)
{
aWidget->Invalidate(aRect);
// XXX - Even more evil workaround!! See bug 762948, flash's bottom
// level sandboxed window doesn't seem to get our invalidate. We send
// an invalidate to it manually. This is totally specialized for this
// bug, for other child window structures this will just be a more or
// less bogus invalidate but since that should not have any bad
// side-effects this will have to do for now.
HWND current = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW);
RECT windowRect;
RECT parentRect;
::GetWindowRect(current, &parentRect);
HWND next = current;
do {
current = next;
::EnumChildWindows(current, &EnumFirstChild, (LPARAM)&next);
::GetWindowRect(next, &windowRect);
// This is relative to the screen, adjust it to be relative to the
// window we're reconfiguring.
windowRect.left -= parentRect.left;
windowRect.top -= parentRect.top;
} while (next != current && windowRect.top == 0 && windowRect.left == 0);
if (windowRect.top == 0 && windowRect.left == 0) {
RECT rect;
rect.left = aRect.x;
rect.top = aRect.y;
rect.right = aRect.XMost();
rect.bottom = aRect.YMost();
::InvalidateRect(next, &rect, FALSE);
}
}