/* x86-64 doesn't use asm version */ void make_decode_tables_mmx(mpg123_handle *fr) { int i,j,val; int idx = 0; short *ptr = (short *)fr->decwins; /* Scale is always based on 1.0 . */ double scaleval = -0.5*(fr->lastscale < 0 ? fr->p.outscale : fr->lastscale); debug1("MMX decode tables with scaleval %g", scaleval); for(i=0,j=0;i<256;i++,j++,idx+=32) { if(idx < 512+16) fr->decwin_mmx[idx+16] = fr->decwin_mmx[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval); if(i % 32 == 31) idx -= 1023; if(i % 64 == 63) scaleval = - scaleval; } for( /* i=256 */ ;i<512;i++,j--,idx+=32) { if(idx < 512+16) fr->decwin_mmx[idx+16] = fr->decwin_mmx[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval); if(i % 32 == 31) idx -= 1023; if(i % 64 == 63) scaleval = - scaleval; } for(i=0; i<512; i++) { if(i&1) val = rounded(fr->decwin_mmx[i]*0.5); else val = rounded(fr->decwin_mmx[i]*-0.5); if(val > 32767) val = 32767; else if(val < -32768) val = -32768; ptr[i] = val; } for(i=512; i<512+32; i++) { if(i&1) val = rounded(fr->decwin_mmx[i]*0.5); else val = 0; if(val > 32767) val = 32767; else if(val < -32768) val = -32768; ptr[i] = val; } for(i=0; i<512; i++) { val = rounded(fr->decwin_mmx[511-i]*-0.5); if(val > 32767) val = 32767; else if(val < -32768) val = -32768; ptr[512+32+i] = val; } debug("decode tables done"); }
// [[Rcpp::export]] IntegerVector bootPerm(const int n) { RNGScope scope; NumericVector unRound(runif(n, 0, n)); NumericVector rounded(floor(unRound)); IntegerVector out = Rcpp::as< IntegerVector >(rounded); return out; }
static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz) { #ifdef QT_OPENGL_ES_2 QSize rounded(qt_next_power_of_two(sz.width()), qt_next_power_of_two(sz.height())); if (rounded.width() * rounded.height() < 1.20 * sz.width() * sz.height()) return rounded; #endif return sz; }
FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode /* mode */) { FloatRect rounded(rect); rounded.setX(roundf(rect.x())); rounded.setY(roundf(rect.y())); rounded.setWidth(roundf(rect.width())); rounded.setHeight(roundf(rect.height())); return rounded; }
QPixmap SenderAvatarProvider::drawAvatar(const QString &url, const QSize &renderSize) { auto userSettings = inbox_.userSettings(); // Cut query string from URL QString path = url.split("?").at(0); if (path != userSettings->address()) { Log.w() << "Requested avatar url does not match user's Kullo address: " << url; } QPixmap out = getUserAvatarData(url, renderSize, userSettings); return rounded(out); }
void marktable(const int day, const int ibin, const int unused) { int label, counter, k; printf(" "); for (counter = 0, label = 0; label < LENGTH(convert); label++) { const unsigned int time = rounded(data[IDX(day, ibin, label)] * 5, bin * daycounter[day]); for (k = 0; k < time; k++) { if (counter < 5) printf("%c", convert[label].mark); counter++; } } for (; counter < 5; counter++) printf(" "); }
int QtGnuplotWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 8) qt_static_metacall(this, _c, _id, _a); _id -= 8; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = antialias(); break; case 1: *reinterpret_cast< bool*>(_v) = rounded(); break; case 2: *reinterpret_cast< bool*>(_v) = replotOnResize(); break; case 3: *reinterpret_cast< QColor*>(_v) = backgroundColor(); break; case 4: *reinterpret_cast< bool*>(_v) = statusLabelActive(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setAntialias(*reinterpret_cast< bool*>(_v)); break; case 1: setRounded(*reinterpret_cast< bool*>(_v)); break; case 2: setReplotOnResize(*reinterpret_cast< bool*>(_v)); break; case 3: setBackgroundColor(*reinterpret_cast< QColor*>(_v)); break; case 4: setStatusLabelActive(*reinterpret_cast< bool*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
std::string DecimalDecNumber::toStringAllowScientific(uint32 decimalPlaces) const { if (!isZero() && !isInfinity() && !decNumberIsNaN(&m_value)) { static const int BUFFER_SIZE = 256; char buffer[BUFFER_SIZE]; { DecimalDecNumber rounded(*this); rounded.round(decimalPlaces, RoundingMode::ROUND_TO_ZERO); decNumberToString(&rounded.m_value, buffer); } char * e = buffer + strlen(buffer); char * f = std::find(buffer, e, '+'); if (f != e) return buffer; } return toString(decimalPlaces); }
QPixmap ConversationAvatarProvider::drawAvatar(const QString &url, const QSize &renderSize) { if (!inbox_.loggedIn()) { return QPixmap(); } // Cut query string from URL QString path = url.split("?").at(0); bool okConvId; auto convId = path.toInt(&okConvId); if (!okConvId || convId < 0) { Log.e() << "Invalid conversation avatar request string: " << url; return QPixmap(); } Qml::ConversationModel *conv = inbox_.conversationsListSource()->get(convId); if (!conv) { Log.e() << "Conversation for conversation avatar not found: " << convId; return QPixmap(); } auto participantsAddresses = conv->participantsAddresses(); QPixmap out; if (participantsAddresses.size() == 1) { out = getAvatarForAddress(participantsAddresses[0], renderSize); } else if (participantsAddresses.size() <= 4) { out = composeAvatar(participantsAddresses, renderSize); } else { out = getFallbackAvatar(QString::number(participantsAddresses.size()), renderSize); } return rounded(out); }
CSSRect CalculateRectToZoomTo(const nsCOMPtr<nsIDocument>& aRootContentDocument, const CSSPoint& aPoint) { // Ensure the layout information we get is up-to-date. aRootContentDocument->FlushPendingNotifications(FlushType::Layout); // An empty rect as return value is interpreted as "zoom out". const CSSRect zoomOut; nsCOMPtr<nsIPresShell> shell = aRootContentDocument->GetShell(); if (!shell) { return zoomOut; } nsIScrollableFrame* rootScrollFrame = shell->GetRootScrollFrameAsScrollable(); if (!rootScrollFrame) { return zoomOut; } nsCOMPtr<dom::Element> element = ElementFromPoint(shell, aPoint); if (!element) { return zoomOut; } while (element && !ShouldZoomToElement(element)) { element = element->GetParentElement(); } if (!element) { return zoomOut; } FrameMetrics metrics = nsLayoutUtils::CalculateBasicFrameMetrics(rootScrollFrame); CSSRect compositedArea(metrics.GetScrollOffset(), metrics.CalculateCompositedSizeInCssPixels()); const CSSCoord margin = 15; CSSRect rect = nsLayoutUtils::GetBoundingContentRect(element, rootScrollFrame); // If the element is taller than the visible area of the page scale // the height of the |rect| so that it has the same aspect ratio as // the root frame. The clipped |rect| is centered on the y value of // the touch point. This allows tall narrow elements to be zoomed. if (!rect.IsEmpty() && compositedArea.width > 0.0f) { const float widthRatio = rect.width / compositedArea.width; float targetHeight = compositedArea.height * widthRatio; if (widthRatio < 0.9 && targetHeight < rect.height) { const CSSPoint scrollPoint = CSSPoint::FromAppUnits(rootScrollFrame->GetScrollPosition()); float newY = aPoint.y + scrollPoint.y - (targetHeight * 0.5f); if ((newY + targetHeight) > (rect.y + rect.height)) { rect.y += rect.height - targetHeight; } else if (newY > rect.y) { rect.y = newY; } rect.height = targetHeight; } } rect = CSSRect(std::max(metrics.GetScrollableRect().x, rect.x - margin), rect.y, rect.width + 2 * margin, rect.height); // Constrict the rect to the screen's right edge rect.width = std::min(rect.width, metrics.GetScrollableRect().XMost() - rect.x); // If the rect is already taking up most of the visible area and is // stretching the width of the page, then we want to zoom out instead. if (IsRectZoomedIn(rect, compositedArea)) { return zoomOut; } CSSRect rounded(rect); rounded.Round(); // If the block we're zooming to is really tall, and the user double-tapped // more than a screenful of height from the top of it, then adjust the // y-coordinate so that we center the actual point the user double-tapped // upon. This prevents flying to the top of the page when double-tapping // to zoom in (bug 761721). The 1.2 multiplier is just a little fuzz to // compensate for 'rect' including horizontal margins but not vertical ones. CSSCoord cssTapY = metrics.GetScrollOffset().y + aPoint.y; if ((rect.height > rounded.height) && (cssTapY > rounded.y + (rounded.height * 1.2))) { rounded.y = cssTapY - (rounded.height / 2); } return rounded; }
double TransformEPS::mapY( double y ) const { return rounded( y * _scale + _deltaY ); }
double Transform::scale( double x ) const { return rounded( x * _scale ); }
double TransformCairo::mapY( double y ) const { return rounded( _height - ( y * _scale + _deltaY ) ); }
QPixmap MessageAvatarProvider::drawAvatar(const QString &url, const QSize &renderSize) { if (!inbox_.loggedIn()) { return QPixmap(); } // Cut query string from URL QString path = url.split("?").at(0); // Example request path: simon%23kullo.net/35/582 QStringList convIdAndMsgId = path.split('/'); if (convIdAndMsgId.size() != 3) { return QPixmap(); } bool okConvId; bool okMsgId; auto convId = convIdAndMsgId[1].toInt(&okConvId); auto msgId = convIdAndMsgId[2].toInt(&okMsgId); if (!okConvId || !okMsgId || convId < 0 || msgId < 0) { Log.w() << "Invalid message avatar request string: " << url; return QPixmap(); } Qml::ConversationModel *conv = inbox_.conversationsListSource()->get(convId); if (!conv) { Log.e() << "Conversation for message avatar not found: " << convId; return QPixmap(); } Qml::MessageModel *msg = conv->messages()->get(msgId); if (!msg) { Log.e() << "Message for avatar not found: " << msgId; return QPixmap(); } QPixmap out; QPixmap avatar = msg->sender()->avatar(); if (!avatar.isNull()) { if (avatar.width() != avatar.height()) { Log.w() << "Avatar must be square at this point " << "(" << QSize(avatar.width(), avatar.height()) << ")" << ": " << url; } out = avatar.scaled(renderSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); } else { out = getFallbackAvatar(msg->sender()->name(), renderSize); } return rounded(out); }
// Lalit: toString should "truncate" values rather than round std::string DecimalDecNumber::toString(uint32 decimalPlaces) const { // Remove these statics if we ever get a short string optimisation in place (gcc 4.1) static const std::string zero = "0.0"; static const std::string posinf = "+INF"; static const std::string neginf = "-INF"; static const std::string nan = "NaN"; if (isZero()) return zero; else if (isInfinity()) { return isNegative() ? neginf : posinf; } else if (decNumberIsNaN(&m_value)) { // TODO: is it possible to have positive/negative nans? return nan; } static const int BUFFER_SIZE = 256; char buffer[BUFFER_SIZE]; { DecimalDecNumber rounded(*this); rounded.round(decimalPlaces, RoundingMode::ROUND_TO_ZERO); decNumberToString(&rounded.m_value, buffer); } // printf("after round: %s\n", buffer); char * b = buffer; char * e = buffer + strlen(buffer); unpackScientificFormat(b, e, BUFFER_SIZE, decimalPlaces); if ((e-b) == 3 && strcmp(buffer, "NaN") == 0) { return buffer; } else if (std::find(b, e, '.') == e) { strcpy(e, ".0"); return buffer; } { // This code makes the unit tests pass (which were based on the old Decimal implementation) // Ensure that there are no trailing zeros, except when the value is an integer, in which case there should be one trailing zero. char * lastNonZeroDigitAfterDecimal = e - 1; while (*lastNonZeroDigitAfterDecimal == '0') { --lastNonZeroDigitAfterDecimal; } if (*lastNonZeroDigitAfterDecimal == '.') { *(++lastNonZeroDigitAfterDecimal) = '0'; } *(lastNonZeroDigitAfterDecimal + 1) = 0; } // printf("last return\n"); return buffer; }
double Transform::mapX( double x ) const { return rounded( x * _scale + _deltaX ); }
CSSRect CalculateRectToZoomTo(const nsCOMPtr<nsIDocument>& aRootContentDocument, const CSSPoint& aPoint) { // Ensure the layout information we get is up-to-date. aRootContentDocument->FlushPendingNotifications(Flush_Layout); // An empty rect as return value is interpreted as "zoom out". const CSSRect zoomOut; nsCOMPtr<nsIPresShell> shell = aRootContentDocument->GetShell(); if (!shell) { return zoomOut; } nsIScrollableFrame* rootScrollFrame = shell->GetRootScrollFrameAsScrollable(); if (!rootScrollFrame) { return zoomOut; } nsCOMPtr<dom::Element> element = ElementFromPoint(shell, aPoint); if (!element) { return zoomOut; } while (element && !ShouldZoomToElement(element)) { element = element->GetParentElement(); } if (!element) { return zoomOut; } FrameMetrics metrics = nsLayoutUtils::CalculateBasicFrameMetrics(rootScrollFrame); CSSRect compositedArea(metrics.GetScrollOffset(), metrics.CalculateCompositedSizeInCssPixels()); const CSSCoord margin = 15; CSSRect rect = GetBoundingContentRect(shell, element, rootScrollFrame); rect = CSSRect(std::max(metrics.GetScrollableRect().x, rect.x - margin), rect.y, rect.width + 2 * margin, rect.height); // Constrict the rect to the screen's right edge rect.width = std::min(rect.width, metrics.GetScrollableRect().XMost() - rect.x); // If the rect is already taking up most of the visible area and is // stretching the width of the page, then we want to zoom out instead. if (IsRectZoomedIn(rect, compositedArea)) { return zoomOut; } CSSRect rounded(rect); rounded.Round(); // If the block we're zooming to is really tall, and the user double-tapped // more than a screenful of height from the top of it, then adjust the // y-coordinate so that we center the actual point the user double-tapped // upon. This prevents flying to the top of the page when double-tapping // to zoom in (bug 761721). The 1.2 multiplier is just a little fuzz to // compensate for 'rect' including horizontal margins but not vertical ones. CSSCoord cssTapY = metrics.GetScrollOffset().y + aPoint.y; if ((rect.height > rounded.height) && (cssTapY > rounded.y + (rounded.height * 1.2))) { rounded.y = cssTapY - (rounded.height / 2); } return rounded; }