本文整理汇总了C++中PR_MAX函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_MAX函数的具体用法?C++ PR_MAX怎么用?C++ PR_MAX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_MAX函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ssl3_InitExtensionData
/* Initialize the extension data block. */
void
ssl3_InitExtensionData(TLSExtensionData *xtnData, const sslSocket *ss)
{
unsigned int advertisedMax;
PRCList *cursor;
/* Set things up to the right starting state. */
PORT_Memset(xtnData, 0, sizeof(*xtnData));
xtnData->peerSupportsFfdheGroups = PR_FALSE;
PR_INIT_CLIST(&xtnData->remoteKeyShares);
/* Allocate enough to allow for native extensions, plus any custom ones. */
if (ss->sec.isServer) {
advertisedMax = PR_MAX(PR_ARRAY_SIZE(certificateRequestHandlers),
PR_ARRAY_SIZE(tls13_cert_req_senders));
} else {
advertisedMax = PR_MAX(PR_ARRAY_SIZE(clientHelloHandlers),
PR_ARRAY_SIZE(clientHelloSendersTLS));
++advertisedMax; /* For the RI SCSV, which we also track. */
}
for (cursor = PR_NEXT_LINK(&ss->extensionHooks);
cursor != &ss->extensionHooks;
cursor = PR_NEXT_LINK(cursor)) {
++advertisedMax;
}
xtnData->advertised = PORT_ZNewArray(PRUint16, advertisedMax);
}
开发者ID:franziskuskiefer,项目名称:nss,代码行数:28,代码来源:ssl3ext.c
示例2: BoxBlurHorizontal
/**
* Box blur involves looking at one pixel, and setting its value to the average
* of its neighbouring pixels.
* @param aInput The input buffer.
* @param aOutput The output buffer.
* @param aLeftLobe The number of pixels to blend on the left.
* @param aRightLobe The number of pixels to blend on the right.
* @param aStride The stride of the buffers.
* @param aRows The number of rows in the buffers.
*/
static void
BoxBlurHorizontal(unsigned char* aInput,
unsigned char* aOutput,
PRInt32 aLeftLobe,
PRInt32 aRightLobe,
PRInt32 aStride,
PRInt32 aRows)
{
PRInt32 boxSize = aLeftLobe + aRightLobe + 1;
#pragma omp parallel for
for (PRInt32 y = 0; y < aRows; y++) {
PRInt32 alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = i - aLeftLobe;
pos = PR_MAX(pos, 0);
pos = PR_MIN(pos, aStride - 1);
alphaSum += aInput[aStride * y + pos];
}
for (PRInt32 x = 0; x < aStride; x++) {
PRInt32 tmp = x - aLeftLobe;
PRInt32 last = PR_MAX(tmp, 0);
PRInt32 next = PR_MIN(tmp + boxSize, aStride - 1);
aOutput[aStride * y + x] = alphaSum/boxSize;
alphaSum += aInput[aStride * y + next] -
aInput[aStride * y + last];
}
}
}
开发者ID:vaginessa,项目名称:infekt,代码行数:41,代码来源:cairo_box_blur.cpp
示例3: BoxBlurVertical
/**
* Identical to BoxBlurHorizontal, except it blurs top and bottom instead of
* left and right.
*/
static void
BoxBlurVertical(unsigned char* aInput,
unsigned char* aOutput,
PRInt32 aTopLobe,
PRInt32 aBottomLobe,
PRInt32 aStride,
PRInt32 aRows)
{
PRInt32 boxSize = aTopLobe + aBottomLobe + 1;
#pragma omp parallel for
for (PRInt32 x = 0; x < aStride; x++) {
PRInt32 alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = i - aTopLobe;
pos = PR_MAX(pos, 0);
pos = PR_MIN(pos, aRows - 1);
alphaSum += aInput[aStride * pos + x];
}
for (PRInt32 y = 0; y < aRows; y++) {
PRInt32 tmp = y - aTopLobe;
PRInt32 last = PR_MAX(tmp, 0);
PRInt32 next = PR_MIN(tmp + boxSize, aRows - 1);
aOutput[aStride * y + x] = alphaSum/boxSize;
alphaSum += aInput[aStride * next + x] -
aInput[aStride * last + x];
}
}
}
开发者ID:vaginessa,项目名称:infekt,代码行数:35,代码来源:cairo_box_blur.cpp
示例4: GetBoundingBox
void nsRegionPh :: GetBoundingBox( PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight ) {
/* 99.99% there is only one tile - so simplify things, while allow the general case to work as well */
if( mRegion && !mRegion->next ) {
*aX = mRegion->rect.ul.x;
*aY = mRegion->rect.ul.y;
*aWidth = mRegion->rect.lr.x - mRegion->rect.ul.x + 1;
*aHeight = mRegion->rect.lr.y - mRegion->rect.ul.y + 1;
return;
}
int bX=-32767, bY=-32767;
*aX = 32767; //0
*aY = 32767; //0
PhTile_t *t = mRegion;
while( t ) {
*aX = PR_MIN( *aX, tulx );
*aY = PR_MIN( *aY, tuly );
bX = PR_MAX( bX, tlrx );
bY = PR_MAX( bY, tlry );
t = t->next;
}
*aWidth = bX - *aX + 1;
*aHeight = bY - *aY + 1;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:29,代码来源:nsRegionPh.cpp
示例5: PR_MAX
// Deflate the rect by the specified width and height
void nsRect::Deflate(nscoord aDx, nscoord aDy)
{
x += aDx;
y += aDy;
width = PR_MAX(0, width - 2 * aDx);
height = PR_MAX(0, height - 2 * aDy);
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:8,代码来源:nsRect.cpp
示例6: Empty
// 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;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:37,代码来源:nsRect.cpp
示例7: GetFallbackGlyphMetrics
void
GetFallbackGlyphMetrics(FT_BBox *aBoundingBox, FT_Face aFace) {
aBoundingBox->xMin = 0;
aBoundingBox->yMin = 0;
aBoundingBox->xMax = PR_MAX(aFace->size->metrics.x_ppem/2 - 1, 0);
aBoundingBox->yMax = PR_MAX(aFace->size->metrics.y_ppem/2, 1);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:7,代码来源:nsFontFreeType.cpp
示例8: GetDocShell
PRBool
nsSubDocumentFrame::ReflowFinished()
{
nsCOMPtr<nsIDocShell> docShell;
GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(docShell));
// resize the sub document
if (baseWindow) {
PRInt32 x = 0;
PRInt32 y = 0;
nsWeakFrame weakFrame(this);
nsPresContext* presContext = PresContext();
baseWindow->GetPositionAndSize(&x, &y, nsnull, nsnull);
if (!weakFrame.IsAlive()) {
// GetPositionAndSize() killed us
return PR_FALSE;
}
// GetPositionAndSize might have resized us. So now is the time to
// get our size.
mPostedReflowCallback = PR_FALSE;
nsSize innerSize(GetSize());
if (IsInline()) {
nsMargin usedBorderPadding = GetUsedBorderAndPadding();
// Sadly, XUL smacks the frame size without changing the used
// border and padding, so we can't trust those. Subtracting
// them might make things negative.
innerSize.width -= usedBorderPadding.LeftRight();
innerSize.width = PR_MAX(innerSize.width, 0);
innerSize.height -= usedBorderPadding.TopBottom();
innerSize.height = PR_MAX(innerSize.height, 0);
}
PRInt32 cx = presContext->AppUnitsToDevPixels(innerSize.width);
PRInt32 cy = presContext->AppUnitsToDevPixels(innerSize.height);
baseWindow->SetPositionAndSize(x, y, cx, cy, PR_FALSE);
} else {
// Make sure that we can post a reflow callback in the future.
mPostedReflowCallback = PR_FALSE;
}
return PR_FALSE;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:51,代码来源:nsFrameFrame.cpp
示例9: PR_MIN
gfxRect
gfxRect::Union(const gfxRect& aRect) const
{
if (IsEmpty())
return aRect;
if (aRect.IsEmpty())
return *this;
gfxFloat x = PR_MIN(aRect.X(), X());
gfxFloat xmost = PR_MAX(aRect.XMost(), XMost());
gfxFloat y = PR_MIN(aRect.Y(), Y());
gfxFloat ymost = PR_MAX(aRect.YMost(), YMost());
return gfxRect(x, y, xmost - x, ymost - y);
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:14,代码来源:gfxRect.cpp
示例10: NS_ASSERTION
void
nsBlockReflowState::ComputeReplacedBlockOffsetsForFloats(nsIFrame* aFrame,
nscoord& aLeftResult,
nscoord& aRightResult,
nsBlockFrame::
ReplacedElementWidthToClear
*aReplacedWidth)
{
// The frame is clueless about the space manager and therefore we
// only give it free space. An example is a table frame - the
// tables do not flow around floats.
// However, we can let its margins intersect floats.
NS_ASSERTION(mAvailSpaceRect.x >= 0, "bad avail space rect x");
NS_ASSERTION(mAvailSpaceRect.width == 0 ||
mAvailSpaceRect.XMost() <= mContentArea.width,
"bad avail space rect width");
nscoord leftOffset, rightOffset;
if (mAvailSpaceRect.width == mContentArea.width) {
// We don't need to compute margins when there are no floats around.
leftOffset = 0;
rightOffset = 0;
} else {
// We pass in aReplacedWidth to make handling outer table frames
// work correctly. For outer table frames, we need to subtract off
// the margin that's going to be at the edge of them, since we're
// dealing with margin that it's really the child's responsibility
// to place.
nsCSSOffsetState os(aFrame, mReflowState.rendContext, mContentArea.width);
NS_ASSERTION(!aReplacedWidth ||
aFrame->GetType() == nsGkAtoms::tableOuterFrame ||
(aReplacedWidth->marginLeft == os.mComputedMargin.left &&
aReplacedWidth->marginRight == os.mComputedMargin.right),
"unexpected aReplacedWidth");
nscoord leftFloatXOffset = mAvailSpaceRect.x;
leftOffset = PR_MAX(leftFloatXOffset, os.mComputedMargin.left) -
(aReplacedWidth ? aReplacedWidth->marginLeft
: os.mComputedMargin.left);
leftOffset = PR_MAX(leftOffset, 0); // in case of negative margin
nscoord rightFloatXOffset = mContentArea.width - mAvailSpaceRect.XMost();
rightOffset = PR_MAX(rightFloatXOffset, os.mComputedMargin.right) -
(aReplacedWidth ? aReplacedWidth->marginRight
: os.mComputedMargin.right);
rightOffset = PR_MAX(rightOffset, 0); // in case of negative margin
}
aLeftResult = leftOffset;
aRightResult = rightOffset;
}
开发者ID:ahadzi,项目名称:celtx,代码行数:49,代码来源:nsBlockReflowState.cpp
示例11: PR_MIN
void nsRect::UnionRectIncludeEmpty(const nsRect &aRect1, const nsRect &aRect2)
{
nscoord xmost1 = aRect1.XMost();
nscoord xmost2 = aRect2.XMost();
nscoord ymost1 = aRect1.YMost();
nscoord 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;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:15,代码来源:nsRect.cpp
示例12: GetArraySize
PRBool nsVoidArray::GrowArrayBy(PRInt32 aGrowBy)
{
// We have to grow the array. Grow by kMinGrowArrayBy slots if we're
// smaller than kLinearThreshold bytes, or a power of two if we're
// larger. This is much more efficient with most memory allocators,
// especially if it's very large, or of the allocator is binned.
if (aGrowBy < kMinGrowArrayBy)
aGrowBy = kMinGrowArrayBy;
PRUint32 newCapacity = GetArraySize() + aGrowBy; // Minimum increase
PRUint32 newSize = SIZEOF_IMPL(newCapacity);
if (newSize >= (PRUint32) kLinearThreshold)
{
// newCount includes enough space for at least kMinGrowArrayBy new
// slots. Select the next power-of-two size in bytes above or
// equal to that.
// Also, limit the increase in size to about a VM page or two.
if (GetArraySize() >= kMaxGrowArrayBy)
{
newCapacity = GetArraySize() + PR_MAX(kMaxGrowArrayBy,aGrowBy);
newSize = SIZEOF_IMPL(newCapacity);
}
else
{
PR_CEILING_LOG2(newSize, newSize);
newCapacity = CAPACITYOF_IMPL(PR_BIT(newSize));
}
}
// frees old mImpl IF this succeeds
if (!SizeTo(newCapacity))
return PR_FALSE;
return PR_TRUE;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:35,代码来源:nsVoidArray.cpp
示例13: autoStatLock
void sbDeviceStatistics::AddAudioCount(PRInt32 aAddAudioCount)
{
nsAutoLock autoStatLock(mStatLock);
PRInt32 audioCount =
PR_MAX(static_cast<PRInt32>(mAudioCount) + aAddAudioCount, 0);
mAudioCount = audioCount;
}
开发者ID:AntoineTurmel,项目名称:nightingale-hacking,代码行数:7,代码来源:sbDeviceStatistics.cpp
示例14: LOG
// From section 13.2.3 of RFC2616, we compute the current age of a cached
// response as follows:
//
// currentAge = max(max(0, responseTime - dateValue), ageValue)
// + now - requestTime
//
// where responseTime == now
//
// This is typically a very small number.
//
nsresult
nsHttpResponseHead::ComputeCurrentAge(PRUint32 now,
PRUint32 requestTime,
PRUint32 *result)
{
PRUint32 dateValue;
PRUint32 ageValue;
*result = 0;
if (NS_FAILED(GetDateValue(&dateValue))) {
LOG(("nsHttpResponseHead::ComputeCurrentAge [this=%x] "
"Date response header not set!\n", this));
// Assume we have a fast connection and that our clock
// is in sync with the server.
dateValue = now;
}
// Compute apparent age
if (now > dateValue)
*result = now - dateValue;
// Compute corrected received age
if (NS_SUCCEEDED(GetAgeValue(&ageValue)))
*result = PR_MAX(*result, ageValue);
NS_ASSERTION(now >= requestTime, "bogus request time");
// Compute current age
*result += (now - requestTime);
return NS_OK;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:42,代码来源:nsHttpResponseHead.cpp
示例15: ResetIfSet
PRBool
nsAttrValue::ParseSpecialIntValue(const nsAString& aString,
PRBool aCanBePercent)
{
ResetIfSet();
PRInt32 ec;
nsAutoString tmp(aString);
PRInt32 val = tmp.ToInteger(&ec);
if (NS_FAILED(ec)) {
return PR_FALSE;
}
val = PR_MAX(val, 0);
val = PR_MIN(val, NS_ATTRVALUE_INTEGERTYPE_MAXVALUE);
// % (percent)
// XXX RFindChar means that 5%x will be parsed!
if (aCanBePercent && tmp.RFindChar('%') >= 0) {
if (val > 100) {
val = 100;
}
SetIntValueAndType(val, ePercent);
return PR_TRUE;
}
// Straight number is interpreted as integer
SetIntValueAndType(val, eInteger);
return PR_TRUE;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:31,代码来源:nsAttrValue.cpp
示例16: NS_NOTREACHED
void nsIntervalSet::IncludeInterval(coord_type aBegin, coord_type aEnd)
{
Interval *newInterval = static_cast<Interval*>
((*mAlloc)(sizeof(Interval), mAllocatorClosure));
if (!newInterval) {
NS_NOTREACHED("allocation failure");
return;
}
new(newInterval) Interval(aBegin, aEnd);
Interval **current = &mList;
while (*current && (*current)->mEnd < aBegin)
current = &(*current)->mNext;
newInterval->mNext = *current;
*current = newInterval;
Interval *subsumed = newInterval->mNext;
while (subsumed && subsumed->mBegin <= aEnd) {
newInterval->mBegin = PR_MIN(newInterval->mBegin, subsumed->mBegin);
newInterval->mEnd = PR_MAX(newInterval->mEnd, subsumed->mEnd);
newInterval->mNext = subsumed->mNext;
FreeInterval(subsumed);
subsumed = newInterval->mNext;
}
}
开发者ID:ahadzi,项目名称:celtx,代码行数:26,代码来源:nsIntervalSet.cpp
示例17: PR_MAX
void
nsSMILTimeContainer::SetCurrentTime(nsSMILTime aSeekTo)
{
// SVG 1.1 doesn't specify what to do for negative times so we adopt SVGT1.2's
// behaviour of clamping negative times to 0.
aSeekTo = PR_MAX(0, aSeekTo);
// The following behaviour is consistent with:
// http://www.w3.org/2003/01/REC-SVG11-20030114-errata
// #getCurrentTime_setCurrentTime_undefined_before_document_timeline_begin
// which says that if SetCurrentTime is called before the document timeline
// has begun we should still adjust the offset.
nsSMILTime parentTime = GetParentTime();
mParentOffset = parentTime - aSeekTo;
mIsSeeking = PR_TRUE;
if (IsPaused()) {
mNeedsPauseSample = PR_TRUE;
mPauseStart = parentTime;
}
if (aSeekTo < mCurrentTime) {
// Backwards seek
mNeedsRewind = PR_TRUE;
ClearMilestones();
}
// Force an update to the current time in case we get a call to GetCurrentTime
// before another call to Sample().
UpdateCurrentTime();
NotifyTimeChange();
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:33,代码来源:nsSMILTimeContainer.cpp
示例18: AppendStr
static SECStatus
AppendStr(stringBuf *bufp, char *str)
{
char *buf;
unsigned bufLen, bufSize, len;
int size = 0;
/* Figure out how much to grow buf by (add in the '\0') */
buf = bufp->buffer;
bufLen = bufp->offset;
len = PORT_Strlen(str);
bufSize = bufLen + len;
if (!buf) {
bufSize++;
size = PR_MAX(DEFAULT_BUFFER_SIZE,bufSize*2);
buf = (char *) PORT_Alloc(size);
bufp->size = size;
} else if (bufp->size < bufSize) {
size = bufSize*2;
buf =(char *) PORT_Realloc(buf,size);
bufp->size = size;
}
if (!buf) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
return SECFailure;
}
bufp->buffer = buf;
bufp->offset = bufSize;
/* Concatenate str onto buf */
buf = buf + bufLen;
if (bufLen) buf--; /* stomp on old '\0' */
PORT_Memcpy(buf, str, len+1); /* put in new null */
return SECSuccess;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:35,代码来源:alg1485.c
示例19: NS_ASSERTION
nsresult
txMozillaXMLOutput::createTxWrapper()
{
NS_ASSERTION(mDocument == mCurrentNode,
"creating wrapper when document isn't parent");
PRInt32 namespaceID;
nsresult rv = nsContentUtils::NameSpaceManager()->
RegisterNameSpace(NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> wrapper;
rv = mDocument->CreateElem(nsAtomString(nsGkAtoms::result), nsGkAtoms::transformiix,
namespaceID, PR_FALSE, getter_AddRefs(wrapper));
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 i, j, childCount = mDocument->GetChildCount();
#ifdef DEBUG
// Keep track of the location of the current documentElement, if there is
// one, so we can verify later
PRUint32 rootLocation = 0;
#endif
for (i = 0, j = 0; i < childCount; ++i) {
nsCOMPtr<nsIContent> childContent = mDocument->GetChildAt(j);
#ifdef DEBUG
if (childContent->IsElement()) {
rootLocation = j;
}
#endif
if (childContent->Tag() == nsGkAtoms::documentTypeNodeName) {
#ifdef DEBUG
// The new documentElement should go after the document type.
// This is needed for cases when there is no existing
// documentElement in the document.
rootLocation = PR_MAX(rootLocation, j + 1);
#endif
++j;
}
else {
rv = mDocument->RemoveChildAt(j, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
rv = wrapper->AppendChildTo(childContent, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
break;
}
}
if (!mCurrentNodeStack.AppendObject(wrapper)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mCurrentNode = wrapper;
mRootContentCreated = PR_TRUE;
NS_ASSERTION(rootLocation == mDocument->GetChildCount(),
"Incorrect root location");
return mDocument->AppendChildTo(wrapper, PR_TRUE);
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:59,代码来源:txMozillaXMLOutput.cpp
注:本文中的PR_MAX函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论