当前位置: 首页>>代码示例>>C++>>正文


C++ PR_MAX函数代码示例

本文整理汇总了C++中PR_MAX函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_MAX函数的具体用法?C++ PR_MAX怎么用?C++ PR_MAX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PR_MAX函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的PR_MAX函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。