这篇教程C++ IsNaN函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中IsNaN函数的典型用法代码示例。如果您正苦于以下问题:C++ IsNaN函数的具体用法?C++ IsNaN怎么用?C++ IsNaN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了IsNaN函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: MOZ_ASSERTvoidSourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv){ MOZ_ASSERT(NS_IsMainThread()); MSE_API("SourceBuffer(%p)::Remove(aStart=%f, aEnd=%f)", this, aStart, aEnd); if (!IsAttached()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } if (IsNaN(mMediaSource->Duration()) || aStart < 0 || aStart > mMediaSource->Duration() || aEnd <= aStart || IsNaN(aEnd)) { aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return; } if (mUpdating || mMediaSource->ReadyState() != MediaSourceReadyState::Open) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } StartUpdating(); /// TODO: Run coded frame removal algorithm. // Run the final step of the coded frame removal algorithm asynchronously // to ensure the SourceBuffer's updating flag transition behaves as // required by the spec. nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &SourceBuffer::StopUpdating); NS_DispatchToMainThread(event);}
开发者ID:msliu,项目名称:gecko-dev,代码行数:28,
示例2: MOZ_ASSERTvoidSourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv){ MOZ_ASSERT(NS_IsMainThread()); MSE_API("Remove(aStart=%f, aEnd=%f)", aStart, aEnd); if (!IsAttached()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } if (mUpdating) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } if (IsNaN(mMediaSource->Duration()) || aStart < 0 || aStart > mMediaSource->Duration() || aEnd <= aStart || IsNaN(aEnd)) { aRv.Throw(NS_ERROR_DOM_TYPE_ERR); return; } if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) { mMediaSource->SetReadyState(MediaSourceReadyState::Open); } RangeRemoval(aStart, aEnd);}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:25,
示例3: MOZ_ASSERTvoidSourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv){ MOZ_ASSERT(NS_IsMainThread()); MSE_API("Remove(aStart=%f, aEnd=%f)", aStart, aEnd); if (!IsAttached()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } if (mUpdating) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } if (IsNaN(mMediaSource->Duration()) || aStart < 0 || aStart > mMediaSource->Duration() || aEnd <= aStart || IsNaN(aEnd)) { aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return; } if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) { mMediaSource->SetReadyState(MediaSourceReadyState::Open); } StartUpdating(); nsCOMPtr<nsIRunnable> task = new RangeRemovalRunnable(this, aStart, aEnd); NS_DispatchToMainThread(task);}
开发者ID:RobertJGabriel,项目名称:Waterfox,代码行数:27,
示例4: MOZ_ASSERTmedia::TimeIntervalsMediaSourceDecoder::GetSeekable(){ MOZ_ASSERT(NS_IsMainThread()); if (!mMediaSource) { NS_WARNING("MediaSource element isn't attached"); return media::TimeIntervals::Invalid(); } media::TimeIntervals seekable; double duration = mMediaSource->Duration(); if (IsNaN(duration)) { // Return empty range. } else if (duration > 0 && mozilla::IsInfinite(duration)) { media::TimeIntervals buffered = GetBuffered(); if (buffered.Length()) { seekable += media::TimeInterval(media::TimeUnit::FromSeconds(0), buffered.GetEnd()); } } else { seekable += media::TimeInterval(media::TimeUnit::FromSeconds(0), media::TimeUnit::FromSeconds(duration)); } MSE_DEBUG("ranges=%s", DumpTimeRanges(seekable).get()); return seekable;}
开发者ID:SJasoria,项目名称:gecko-dev,代码行数:26,
示例5: calculateNormalizationScalestatic float calculateNormalizationScale(ThreadSharedFloatArrayBufferList* response, size_t aLength, float sampleRate){ // Normalize by RMS power size_t numberOfChannels = response->GetChannels(); float power = 0; for (size_t i = 0; i < numberOfChannels; ++i) { float channelPower = AudioBufferSumOfSquares(static_cast<const float*>(response->GetData(i)), aLength); power += channelPower; } power = sqrt(power / (numberOfChannels * aLength)); // Protect against accidental overload if (!IsFinite(power) || IsNaN(power) || power < MinPower) power = MinPower; float scale = 1 / power; scale *= GainCalibration; // calibrate to make perceived volume same as unprocessed // Scale depends on sample-rate. if (sampleRate) scale *= GainCalibrationSampleRate / sampleRate; // True-stereo compensation if (response->GetChannels() == 4) scale *= 0.5f; return scale;}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:32,
示例6: IsCacheCorrect// For NaNs, etc.static bool IsCacheCorrect(float cached, float actual) { if (IsNaN(cached)) { // GL is allowed to do anything it wants for NaNs, so if we're shadowing // a NaN, then whatever `actual` is might be correct. return true; } return cached == actual;}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:10,
示例7: CheckNaN void CheckNaN( const Matrix44& matrix ) { for (int i = 0; i < 16; ++i) { if (IsNaN( matrix.m[ i ] )) { //std::cerr << "Matrix contains NaN" << std::endl; } } }
开发者ID:souxiaosou,项目名称:aether3d,代码行数:10,
示例8: MOZ_ASSERTvoidSourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv){ MOZ_ASSERT(NS_IsMainThread()); MSE_API("SourceBuffer(%p)::Remove(aStart=%f, aEnd=%f)", this, aStart, aEnd); if (IsNaN(mMediaSource->Duration()) || aStart < 0 || aStart > mMediaSource->Duration() || aEnd <= aStart || IsNaN(aEnd)) { aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return; } if (!IsAttached() || mUpdating || mMediaSource->ReadyState() != MediaSourceReadyState::Open) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } StartUpdating(); /// TODO: Run coded frame removal algorithm asynchronously (would call StopUpdating()). StopUpdating();}
开发者ID:bebef1987,项目名称:gecko-dev,代码行数:20,
示例9: TestDouble/* Test given float values */void TestDouble(double a, double b){ DOUB_LONG param1, param2, result, check; param1.d = a; param2.d = b; check.d = param1.d + param2.d; result.l = DoubleAdd (param1.l, param2.l);#if ALWAYS_PRINT printf("/n"); Display(param1, param2, result);#endif if (result.l != check.l && !(IsNaN(result.l) && IsNaN(check.l)) && !(IsZero(result.l) && IsZero(check.l))) { printf("/nFailed! Answer should be %e (%08lx)./n", check.d, check.l); Display(param1, param2, result); printf("/n"); }}
开发者ID:mmaloney007,项目名称:Old_CS_Code,代码行数:21,
示例10: f4PlaneCoefs bool Ray::Intersects(const Plane& plane, F32* distance) const { Vector3f planeNormal = plane.GetNormal(); Vector3f rayEnd = origin + direction * this->distance; XMFLOAT4 f4PlaneCoefs(planeNormal.x, planeNormal.y, planeNormal.z, plane.GetDistance()); XMFLOAT3 f3RayBegin(origin.v); XMFLOAT3 f3RayEnd(rayEnd.v); XMVECTOR vPlaneCoefs = XMLoadFloat4(&f4PlaneCoefs); XMVECTOR vRayBegin = XMLoadFloat3(&f3RayBegin); XMVECTOR vRayEnd = XMLoadFloat3(&f3RayEnd); XMVECTOR vIntersection = XMPlaneIntersectLine(vPlaneCoefs, vRayBegin, vRayEnd); XMFLOAT3 f3Intersection; XMStoreFloat3(&f3Intersection, vIntersection); if (IsNaN(f3Intersection.x) || IsNaN(f3Intersection.y) || IsNaN(f3Intersection.z)) { return false; } else { *distance = Vector3f::Distance(origin, Vector3f(f3Intersection.x, f3Intersection.y, f3Intersection.z)); return true; } }
开发者ID:panmar,项目名称:pg3,代码行数:23,
示例11: find_minmax/* ------------------------------------------------------------------------ * Function: find_minmax * ------------------------------------------------------------------------ */void find_minmax(double *input, int M, double *minval, int *minind, double *maxval, int *maxind){ int i; for (i = 0; i < M; i++) { if (!IsNaN(input[i])) { // init min/max to first non-NAN element *minval = input[i]; *minind = i; *maxval = input[i]; *maxind = i; break; } } if (i == M) { // special case: if all NaNs *minval = GetNaN(); *minind = 0; *maxval = GetNaN(); *maxind = 0; } for (; i < M; i++) { // go through keeping track of min/max if ((input[i] < *minval) && (!IsNaN(input[i]))) {*minval = input[i]; *minind = i;} else if ((input[i] > *maxval) && (!IsNaN(input[i]))) {*maxval = input[i]; *maxind = i;} }}
开发者ID:FelixPascal,项目名称:BCILAB,代码行数:26,
示例12: MOZ_ASSERTvoidSourceBuffer::SetAppendWindowEnd(double aAppendWindowEnd, ErrorResult& aRv){ MOZ_ASSERT(NS_IsMainThread()); MSE_API("SetAppendWindowEnd(aAppendWindowEnd=%f)", aAppendWindowEnd); if (!IsAttached() || mUpdating) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } if (IsNaN(aAppendWindowEnd) || aAppendWindowEnd <= mAppendWindowStart) { aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return; } mAppendWindowEnd = aAppendWindowEnd;}
开发者ID:alison-shiue,项目名称:gecko-dev,代码行数:15,
示例13: ASCIIShadechar ASCIIShade(double x){ if(IsNaN(x)) return 'E'; if(IsInf(x)==1) return 'I'; else if(IsInf(x)==-1) return 'i'; int index = (int)Trunc(x*8) + 7; if(index < 0) index=0; if(index >= kNumAsciiShades) index=kNumAsciiShades-1; if(index == 7) { if(x > 0) return kAsciiShades[8]; else if(x < 0) return kAsciiShades[6]; else return kAsciiShades[7]; } return kAsciiShades[index];}
开发者ID:krishauser,项目名称:KrisLibrary,代码行数:15,
示例14: GetResourceint64_tSubBufferDecoder::ConvertToByteOffset(double aTime){ // Uses a conversion based on (aTime/duration) * length. For the // purposes of eviction this should be adequate since we have the // byte threshold as well to ensure data actually gets evicted and // we ensure we don't evict before the current playable point. double duration = mParentDecoder->GetMediaSourceDuration(); if (duration <= 0.0 || IsNaN(duration)) { return -1; } int64_t length = GetResource()->GetLength(); MOZ_ASSERT(length > 0); int64_t offset = (aTime / duration) * length; return offset;}
开发者ID:karzler,项目名称:DivFirefoxTesting,代码行数:16,
示例15: monvoidMediaSourceDecoder::SetInitialDuration(int64_t aDuration){ // Only use the decoded duration if one wasn't already // set. ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); if (!mMediaSource || !IsNaN(mMediaSourceDuration)) { return; } double duration = aDuration; // A duration of -1 is +Infinity. if (aDuration >= 0) { duration /= USECS_PER_S; } SetMediaSourceDuration(duration, MSRangeRemovalAction::SKIP);}
开发者ID:nixiValor,项目名称:Waterfox,代码行数:16,
示例16: MOZ_ASSERTvoidMediaSource::SetDuration(double aDuration, ErrorResult& aRv){ MOZ_ASSERT(NS_IsMainThread()); MSE_API("SetDuration(aDuration=%f, ErrorResult)", aDuration); if (aDuration < 0 || IsNaN(aDuration)) { aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return; } if (mReadyState != MediaSourceReadyState::Open || mSourceBuffers->AnyUpdating()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } SetDuration(aDuration, MSRangeRemovalAction::RUN);}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:16,
示例17: MOZ_ASSERTvoidMediaSource::SetDuration(double aDuration, ErrorResult& aRv){ MOZ_ASSERT(NS_IsMainThread()); MSE_API("MediaSource(%p)::SetDuration(aDuration=%f)", this, aDuration); if (aDuration < 0 || IsNaN(aDuration)) { aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return; } if (mReadyState != MediaSourceReadyState::Open || mSourceBuffers->AnyUpdating()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } DurationChange(aDuration, aRv);}
开发者ID:jrmuizel,项目名称:mozilla-central-skia,代码行数:16,
示例18: DoubleToBufferchar* DoubleToBuffer(double value, char* buffer) { // DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all // platforms these days. Just in case some system exists where DBL_DIG // is significantly larger -- and risks overflowing our buffer -- we have // this assert. GOOGLE_COMPILE_ASSERT(DBL_DIG < 20, DBL_DIG_is_too_big); if (value == numeric_limits<double>::infinity()) { strcpy(buffer, "inf"); return buffer; } else if (value == -numeric_limits<double>::infinity()) { strcpy(buffer, "-inf"); return buffer; } else if (IsNaN(value)) { strcpy(buffer, "nan"); return buffer; } int snprintf_result = snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG, value); // The snprintf should never overflow because the buffer is significantly // larger than the precision we asked for. GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); // We need to make parsed_value volatile in order to force the compiler to // write it out to the stack. Otherwise, it may keep the value in a // register, and if it does that, it may keep it as a long double instead // of a double. This long double may have extra bits that make it compare // unequal to "value" even though it would be exactly equal if it were // truncated to a double. volatile double parsed_value = strtod(buffer, NULL); if (parsed_value != value) { int snprintf_result = snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value); // Should never overflow; see above. GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); } DelocalizeRadix(buffer); return buffer;}
开发者ID:marmalade,项目名称:protocolbuffers,代码行数:43,
示例19: MOZ_ASSERTmedia::TimeIntervalsMediaSourceDecoder::GetSeekable(){ MOZ_ASSERT(NS_IsMainThread()); if (!mMediaSource) { NS_WARNING("MediaSource element isn't attached"); return media::TimeIntervals::Invalid(); } media::TimeIntervals seekable; double duration = mMediaSource->Duration(); if (IsNaN(duration)) { // Return empty range. } else if (duration > 0 && mozilla::IsInfinite(duration)) { media::TimeIntervals buffered = GetBuffered(); // 1. If live seekable range is not empty: if (mMediaSource->HasLiveSeekableRange()) { // 1. Let union ranges be the union of live seekable range and the // HTMLMediaElement.buffered attribute. media::TimeIntervals unionRanges = buffered + mMediaSource->LiveSeekableRange(); // 2. Return a single range with a start time equal to the earliest start // time in union ranges and an end time equal to the highest end time in // union ranges and abort these steps. seekable += media::TimeInterval(unionRanges.GetStart(), unionRanges.GetEnd()); return seekable; } if (buffered.Length()) { seekable += media::TimeInterval(media::TimeUnit::FromSeconds(0), buffered.GetEnd()); } } else { seekable += media::TimeInterval(media::TimeUnit::FromSeconds(0), media::TimeUnit::FromSeconds(duration)); } MSE_DEBUG("ranges=%s", DumpTimeRanges(seekable).get()); return seekable;}
开发者ID:cliqz-oss,项目名称:browser-f,代码行数:41,
示例20: MOZ_ASSERTnsresultMediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable){ MOZ_ASSERT(NS_IsMainThread()); if (!mMediaSource) { return NS_ERROR_FAILURE; } double duration = mMediaSource->Duration(); if (IsNaN(duration)) { // Return empty range. } else if (duration > 0 && mozilla::IsInfinite(duration)) { nsRefPtr<dom::TimeRanges> bufferedRanges = new dom::TimeRanges(); mMediaSource->GetBuffered(bufferedRanges); aSeekable->Add(bufferedRanges->GetStartTime(), bufferedRanges->GetEndTime()); } else { aSeekable->Add(0, duration); } MSE_DEBUG("MediaSourceDecoder(%p)::GetSeekable ranges=%s", this, DumpTimeRanges(aSeekable).get()); return NS_OK;}
开发者ID:shuangMoz,项目名称:gattdemo1,代码行数:21,
示例21: IsInfint IsInf(double x){#ifdef _MSC_VER //doesn't have isinf int cls = _fpclass(x); if(cls == _FPCLASS_PINF) return 1; else if(cls == _FPCLASS_NINF) return -1; else return 0;#elif HAVE_DECL_ISINF if(isinf(x)) { if(x > 0) return 1; else return -1; } else return 0;#elif HAVE_IEEE_COMPARISONS double y=x-x; if(IsNaN(y)) return (x>0?1:-1); else return 0;#else#error "IsInf: Neither Microsoft's _fpclass, isinf, or IEEE comparisons defined" return 0;#endif}
开发者ID:panjia1983,项目名称:mintos,代码行数:23,
示例22: FloatToBufferchar* FloatToBuffer(float value, char* buffer) { // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all // platforms these days. Just in case some system exists where FLT_DIG // is significantly larger -- and risks overflowing our buffer -- we have // this assert. GOOGLE_COMPILE_ASSERT(FLT_DIG < 10, FLT_DIG_is_too_big); if (value == numeric_limits<double>::infinity()) { strcpy(buffer, "inf"); return buffer; } else if (value == -numeric_limits<double>::infinity()) { strcpy(buffer, "-inf"); return buffer; } else if (IsNaN(value)) { strcpy(buffer, "nan"); return buffer; } int snprintf_result = snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG, value); // The snprintf should never overflow because the buffer is significantly // larger than the precision we asked for. GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); float parsed_value; if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { int snprintf_result = snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+2, value); // Should never overflow; see above. GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); } DelocalizeRadix(buffer); return buffer;}
开发者ID:marmalade,项目名称:protocolbuffers,代码行数:37,
示例23: TEST_FTEST_F(TextFormatTest, ParseExotic) { unittest::TestAllTypes message; ASSERT_TRUE(TextFormat::ParseFromString( "repeated_int32: -1/n" "repeated_int32: -2147483648/n" "repeated_int64: -1/n" "repeated_int64: -9223372036854775808/n" "repeated_uint32: 4294967295/n" "repeated_uint32: 2147483648/n" "repeated_uint64: 18446744073709551615/n" "repeated_uint64: 9223372036854775808/n" "repeated_double: 123.0/n" "repeated_double: 123.5/n" "repeated_double: 0.125/n" "repeated_double: 1.23E17/n" "repeated_double: 1.235E+22/n" "repeated_double: 1.235e-18/n" "repeated_double: 123.456789/n" "repeated_double: inf/n" "repeated_double: Infinity/n" "repeated_double: -inf/n" "repeated_double: -Infinity/n" "repeated_double: nan/n" "repeated_double: NaN/n" "repeated_string: /"//000//001//a//b//f//n//r//t//v//////'///"/"/n", &message)); ASSERT_EQ(2, message.repeated_int32_size()); EXPECT_EQ(-1, message.repeated_int32(0)); // Note: In C, a negative integer literal is actually the unary negation // operator being applied to a positive integer literal, and 2147483648 is // outside the range of int32. However, it is not outside the range of // uint32. Confusingly, this means that everything works if we make the // literal unsigned, even though we are negating it. EXPECT_EQ(-2147483648u, message.repeated_int32(1)); ASSERT_EQ(2, message.repeated_int64_size()); EXPECT_EQ(-1, message.repeated_int64(0)); // Note: In C, a negative integer literal is actually the unary negation // operator being applied to a positive integer literal, and // 9223372036854775808 is outside the range of int64. However, it is not // outside the range of uint64. Confusingly, this means that everything // works if we make the literal unsigned, even though we are negating it. EXPECT_EQ(-GOOGLE_ULONGLONG(9223372036854775808), message.repeated_int64(1)); ASSERT_EQ(2, message.repeated_uint32_size()); EXPECT_EQ(4294967295u, message.repeated_uint32(0)); EXPECT_EQ(2147483648u, message.repeated_uint32(1)); ASSERT_EQ(2, message.repeated_uint64_size()); EXPECT_EQ(GOOGLE_ULONGLONG(18446744073709551615), message.repeated_uint64(0)); EXPECT_EQ(GOOGLE_ULONGLONG(9223372036854775808), message.repeated_uint64(1)); ASSERT_EQ(13, message.repeated_double_size()); EXPECT_EQ(123.0 , message.repeated_double(0)); EXPECT_EQ(123.5 , message.repeated_double(1)); EXPECT_EQ(0.125 , message.repeated_double(2)); EXPECT_EQ(1.23E17 , message.repeated_double(3)); EXPECT_EQ(1.235E22 , message.repeated_double(4)); EXPECT_EQ(1.235E-18 , message.repeated_double(5)); EXPECT_EQ(123.456789, message.repeated_double(6)); EXPECT_EQ(message.repeated_double(7), numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity()); EXPECT_TRUE(IsNaN(message.repeated_double(11))); EXPECT_TRUE(IsNaN(message.repeated_double(12))); // Note: Since these string literals have /0's in them, we must explicitly // pass their sizes to string's constructor. ASSERT_EQ(1, message.repeated_string_size()); EXPECT_EQ(string("/000/001/a/b/f/n/r/t/v///'/"", 12), message.repeated_string(0));}
开发者ID:marmalade,项目名称:protocolbuffers,代码行数:74,
示例24: ClearboolTiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles, Compositor* aCompositor, ISurfaceAllocator* aAllocator){ if (mResolution != aTiles.resolution()) { Clear(); } MOZ_ASSERT(aAllocator); MOZ_ASSERT(aCompositor); if (!aAllocator || !aCompositor) { return false; } if (aTiles.resolution() == 0 || IsNaN(aTiles.resolution())) { // There are divisions by mResolution so this protects the compositor process // against malicious content processes and fuzzing. return false; } TilesPlacement oldTiles = mTiles; TilesPlacement newTiles(aTiles.firstTileX(), aTiles.firstTileY(), aTiles.retainedWidth(), aTiles.retainedHeight()); const InfallibleTArray<TileDescriptor>& tileDescriptors = aTiles.tiles(); nsTArray<TileHost> oldRetainedTiles; mRetainedTiles.SwapElements(oldRetainedTiles); mRetainedTiles.SetLength(tileDescriptors.Length()); // Step 1, we need to unlock tiles that don't have an internal buffer after the // next frame where they are replaced. // Since we are about to replace the tiles' textures, we need to keep their locks // somewhere (in mPreviousSharedLock) until we composite the layer. for (size_t i = 0; i < oldRetainedTiles.Length(); ++i) { TileHost& tile = oldRetainedTiles[i]; // It can happen that we still have a previous lock at this point, // if we changed a tile's front buffer (causing mSharedLock to // go into mPreviousSharedLock, and then did not composite that tile until // the next transaction, either because the tile is offscreen or because the // two transactions happened with no composition in between (over-production). tile.ReadUnlockPrevious(); if (tile.mTextureHost && !tile.mTextureHost->HasInternalBuffer()) { MOZ_ASSERT(tile.mSharedLock); const TileIntPoint tilePosition = oldTiles.TilePosition(i); if (newTiles.HasTile(tilePosition)) { // This tile still exist in the new buffer tile.mPreviousSharedLock = tile.mSharedLock; tile.mSharedLock = nullptr; } else { // This tile does not exist anymore in the new buffer because the size // changed. tile.ReadUnlock(); } } // By now we should not have anything in mSharedLock. MOZ_ASSERT(!tile.mSharedLock); } // Step 2, move the tiles in mRetainedTiles at places that correspond to where // they should be with the new retained with and height rather than the // old one. for (size_t i = 0; i < tileDescriptors.Length(); i++) { const TileIntPoint tilePosition = newTiles.TilePosition(i); // First, get the already existing tiles to the right place in the array, // and use placeholders where there was no tiles. if (!oldTiles.HasTile(tilePosition)) { mRetainedTiles[i] = GetPlaceholderTile(); } else { mRetainedTiles[i] = oldRetainedTiles[oldTiles.TileIndex(tilePosition)]; // If we hit this assertion it means we probably mixed something up in the // logic that tries to reuse tiles on the compositor side. It is most likely // benign, but we are missing some fast paths so let's try to make it not happen. MOZ_ASSERT(tilePosition.x == mRetainedTiles[i].x && tilePosition.y == mRetainedTiles[i].y); } } // It is important to remove the duplicated reference to tiles before calling // TextureHost::PrepareTextureSource, etc. because depending on the textures // ref counts we may or may not get some of the fast paths. oldRetainedTiles.Clear(); // Step 3, handle the texture updates and release the copy-on-write locks. for (size_t i = 0; i < mRetainedTiles.Length(); i++) { const TileDescriptor& tileDesc = tileDescriptors[i]; TileHost& tile = mRetainedTiles[i]; switch (tileDesc.type()) { case TileDescriptor::TTexturedTileDescriptor: { const TexturedTileDescriptor& texturedDesc = tileDesc.get_TexturedTileDescriptor(); const TileLock& ipcLock = texturedDesc.sharedLock(); if (!GetCopyOnWriteLock(ipcLock, tile, aAllocator)) { return false; }//.........这里部分代码省略.........
开发者ID:haasn,项目名称:gecko-dev,代码行数:101,
示例25: CSSToParentLayerScaleTiledLayerBufferComposite::TiledLayerBufferComposite(ISurfaceAllocator* aAllocator, const SurfaceDescriptorTiles& aDescriptor, const nsIntRegion& aOldPaintedRegion, Compositor* aCompositor){ mIsValid = true; mHasDoubleBufferedTiles = false; mValidRegion = aDescriptor.validRegion(); mPaintedRegion = aDescriptor.paintedRegion(); mRetainedWidth = aDescriptor.retainedWidth(); mRetainedHeight = aDescriptor.retainedHeight(); mResolution = aDescriptor.resolution(); mFrameResolution = CSSToParentLayerScale(aDescriptor.frameResolution()); if (mResolution == 0 || IsNaN(mResolution)) { // There are divisions by mResolution so this protects the compositor process // against malicious content processes and fuzzing. mIsValid = false; return; } // Combine any valid content that wasn't already uploaded nsIntRegion oldPaintedRegion(aOldPaintedRegion); oldPaintedRegion.And(oldPaintedRegion, mValidRegion); mPaintedRegion.Or(mPaintedRegion, oldPaintedRegion); bool isSameProcess = aAllocator->IsSameProcess(); const InfallibleTArray<TileDescriptor>& tiles = aDescriptor.tiles(); for(size_t i = 0; i < tiles.Length(); i++) { CompositableTextureHostRef texture; CompositableTextureHostRef textureOnWhite; const TileDescriptor& tileDesc = tiles[i]; switch (tileDesc.type()) { case TileDescriptor::TTexturedTileDescriptor : { texture = TextureHost::AsTextureHost(tileDesc.get_TexturedTileDescriptor().textureParent()); MaybeTexture onWhite = tileDesc.get_TexturedTileDescriptor().textureOnWhite(); if (onWhite.type() == MaybeTexture::TPTextureParent) { textureOnWhite = TextureHost::AsTextureHost(onWhite.get_PTextureParent()); } const TileLock& ipcLock = tileDesc.get_TexturedTileDescriptor().sharedLock(); nsRefPtr<gfxSharedReadLock> sharedLock; if (ipcLock.type() == TileLock::TShmemSection) { sharedLock = gfxShmSharedReadLock::Open(aAllocator, ipcLock.get_ShmemSection()); } else { if (!isSameProcess) { // Trying to use a memory based lock instead of a shmem based one in // the cross-process case is a bad security violation. NS_ERROR("A client process may be trying to peek at the host's address space!"); // This tells the TiledContentHost that deserialization failed so that // it can propagate the error. mIsValid = false; mRetainedTiles.Clear(); return; } sharedLock = reinterpret_cast<gfxMemorySharedReadLock*>(ipcLock.get_uintptr_t()); if (sharedLock) { // The corresponding AddRef is in TiledClient::GetTileDescriptor sharedLock.get()->Release(); } } CompositableTextureSourceRef textureSource; CompositableTextureSourceRef textureSourceOnWhite; if (texture) { texture->SetCompositor(aCompositor); texture->PrepareTextureSource(textureSource); } if (textureOnWhite) { textureOnWhite->SetCompositor(aCompositor); textureOnWhite->PrepareTextureSource(textureSourceOnWhite); } mRetainedTiles.AppendElement(TileHost(sharedLock, texture.get(), textureOnWhite.get(), textureSource.get(), textureSourceOnWhite.get())); break; } default: NS_WARNING("Unrecognised tile descriptor type"); // Fall through case TileDescriptor::TPlaceholderTileDescriptor : mRetainedTiles.AppendElement(GetPlaceholderTile()); break; } if (texture && !texture->HasInternalBuffer()) { mHasDoubleBufferedTiles = true; } }}
开发者ID:Standard8,项目名称:gecko-dev,代码行数:91,
示例26: ClearboolTiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles, Compositor* aCompositor, ISurfaceAllocator* aAllocator){ if (mResolution != aTiles.resolution() || aTiles.tileSize() != mTileSize) { Clear(); } MOZ_ASSERT(aAllocator); MOZ_ASSERT(aCompositor); if (!aAllocator || !aCompositor) { return false; } if (aTiles.resolution() == 0 || IsNaN(aTiles.resolution())) { // There are divisions by mResolution so this protects the compositor process // against malicious content processes and fuzzing. return false; } TilesPlacement newTiles(aTiles.firstTileX(), aTiles.firstTileY(), aTiles.retainedWidth(), aTiles.retainedHeight()); const InfallibleTArray<TileDescriptor>& tileDescriptors = aTiles.tiles(); // Step 1, unlock all the old tiles that haven't been unlocked yet. Any tiles that // exist in both the old and new sets will have been locked again by content, so this // doesn't result in the surface being writeable again. MarkTilesForUnlock(); TextureSourceRecycler oldRetainedTiles(Move(mRetainedTiles)); mRetainedTiles.SetLength(tileDescriptors.Length()); // Step 2, deserialize the incoming set of tiles into mRetainedTiles, and attempt // to recycle the TextureSource for any repeated tiles. // // Since we don't have any retained 'tile' object, we have to search for instances // of the same TextureHost in the old tile set. The cost of binding a TextureHost // to a TextureSource for gralloc (binding EGLImage to GL texture) can be really // high, so we avoid this whenever possible. for (size_t i = 0; i < tileDescriptors.Length(); i++) { const TileDescriptor& tileDesc = tileDescriptors[i]; TileHost& tile = mRetainedTiles[i]; if (tileDesc.type() != TileDescriptor::TTexturedTileDescriptor) { NS_WARN_IF_FALSE(tileDesc.type() == TileDescriptor::TPlaceholderTileDescriptor, "Unrecognised tile descriptor type"); continue; } const TexturedTileDescriptor& texturedDesc = tileDesc.get_TexturedTileDescriptor(); const TileLock& ipcLock = texturedDesc.sharedLock(); if (!GetCopyOnWriteLock(ipcLock, tile, aAllocator)) { return false; } tile.mTextureHost = TextureHost::AsTextureHost(texturedDesc.textureParent()); tile.mTextureHost->SetCompositor(aCompositor); if (texturedDesc.textureOnWhite().type() == MaybeTexture::TPTextureParent) { tile.mTextureHostOnWhite = TextureHost::AsTextureHost(texturedDesc.textureOnWhite().get_PTextureParent()); } tile.mTilePosition = newTiles.TilePosition(i); // If this same tile texture existed in the old tile set then this will move the texture // source into our new tile. oldRetainedTiles.RecycleTextureSourceForTile(tile); } // Step 3, attempt to recycle unused texture sources from the old tile set into new tiles. // // For gralloc, binding a new TextureHost to the existing TextureSource is the fastest way // to ensure that any implicit locking on the old gralloc image is released. for (TileHost& tile : mRetainedTiles) { if (!tile.mTextureHost || tile.mTextureSource) { continue; } oldRetainedTiles.RecycleTextureSource(tile); } // Step 4, handle the texture uploads, texture source binding and release the // copy-on-write locks for textures with an internal buffer. for (size_t i = 0; i < mRetainedTiles.Length(); i++) { TileHost& tile = mRetainedTiles[i]; if (!tile.mTextureHost) { continue; } const TileDescriptor& tileDesc = tileDescriptors[i]; const TexturedTileDescriptor& texturedDesc = tileDesc.get_TexturedTileDescriptor(); UseTileTexture(tile.mTextureHost, tile.mTextureSource, texturedDesc.updateRect(), aCompositor);//.........这里部分代码省略.........
开发者ID:paulmadore,项目名称:luckyde,代码行数:101,
示例27: MOZ_ASSERTvoid DynamicsCompressorKernel::process(float* sourceChannels[], float* destinationChannels[], unsigned numberOfChannels, unsigned framesToProcess, float dbThreshold, float dbKnee, float ratio, float attackTime, float releaseTime, float preDelayTime, float dbPostGain, float effectBlend, /* equal power crossfade */ float releaseZone1, float releaseZone2, float releaseZone3, float releaseZone4 ){ MOZ_ASSERT(m_preDelayBuffers.Length() == numberOfChannels); float sampleRate = this->sampleRate(); float dryMix = 1 - effectBlend; float wetMix = effectBlend; float k = updateStaticCurveParameters(dbThreshold, dbKnee, ratio); // Makeup gain. float fullRangeGain = saturate(1, k); float fullRangeMakeupGain = 1 / fullRangeGain; // Empirical/perceptual tuning. fullRangeMakeupGain = powf(fullRangeMakeupGain, 0.6f); float masterLinearGain = WebAudioUtils::ConvertDecibelsToLinear(dbPostGain) * fullRangeMakeupGain; // Attack parameters. attackTime = max(0.001f, attackTime); float attackFrames = attackTime * sampleRate; // Release parameters. float releaseFrames = sampleRate * releaseTime; // Detector release time. float satReleaseTime = 0.0025f; float satReleaseFrames = satReleaseTime * sampleRate; // Create a smooth function which passes through four points. // Polynomial of the form // y = a + b*x + c*x^2 + d*x^3 + e*x^4; float y1 = releaseFrames * releaseZone1; float y2 = releaseFrames * releaseZone2; float y3 = releaseFrames * releaseZone3; float y4 = releaseFrames * releaseZone4; // All of these coefficients were derived for 4th order polynomial curve fitting where the y values // match the evenly spaced x values as follows: (y1 : x == 0, y2 : x == 1, y3 : x == 2, y4 : x == 3) float kA = 0.9999999999999998f*y1 + 1.8432219684323923e-16f*y2 - 1.9373394351676423e-16f*y3 + 8.824516011816245e-18f*y4; float kB = -1.5788320352845888f*y1 + 2.3305837032074286f*y2 - 0.9141194204840429f*y3 + 0.1623677525612032f*y4; float kC = 0.5334142869106424f*y1 - 1.272736789213631f*y2 + 0.9258856042207512f*y3 - 0.18656310191776226f*y4; float kD = 0.08783463138207234f*y1 - 0.1694162967925622f*y2 + 0.08588057951595272f*y3 - 0.00429891410546283f*y4; float kE = -0.042416883008123074f*y1 + 0.1115693827987602f*y2 - 0.09764676325265872f*y3 + 0.028494263462021576f*y4; // x ranges from 0 -> 3 0 1 2 3 // -15 -10 -5 0db // y calculates adaptive release frames depending on the amount of compression. setPreDelayTime(preDelayTime); const int nDivisionFrames = 32; const int nDivisions = framesToProcess / nDivisionFrames; unsigned frameIndex = 0; for (int i = 0; i < nDivisions; ++i) { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Calculate desired gain // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Fix gremlins. if (IsNaN(m_detectorAverage)) m_detectorAverage = 1; if (IsInfinite(m_detectorAverage)) m_detectorAverage = 1; float desiredGain = m_detectorAverage; // Pre-warp so we get desiredGain after sin() warp below. float scaledDesiredGain = asinf(desiredGain) / (0.5f * M_PI); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Deal with envelopes // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // envelopeRate is the rate we slew from current compressor level to the desired level.//.........这里部分代码省略.........
开发者ID:LaiPhil,项目名称:gecko-dev,代码行数:101,
示例28: IsNaN static bool IsNaN(FloatConstant* value) { return IsNaN(value->Value(), value->GetType()->GetSubtype()); }
开发者ID:lgratian,项目名称:compiler,代码行数:3,
注:本文中的IsNaN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ IsNetworkGame函数代码示例 C++ IsMyAddress函数代码示例 |