本文整理汇总了C++中SkScalarAbs函数的典型用法代码示例。如果您正苦于以下问题:C++ SkScalarAbs函数的具体用法?C++ SkScalarAbs怎么用?C++ SkScalarAbs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkScalarAbs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkScalarAbs
bool SkBitmapController::State::processHighRequest(const SkBitmapProvider& provider) {
if (fQuality != kHigh_SkFilterQuality) {
return false;
}
fQuality = kMedium_SkFilterQuality;
SkScalar invScaleX = fInvMatrix.getScaleX();
SkScalar invScaleY = fInvMatrix.getScaleY();
if (fInvMatrix.getType() & SkMatrix::kAffine_Mask) {
SkSize scale;
if (!fInvMatrix.decomposeScale(&scale)) {
return false;
}
invScaleX = scale.width();
invScaleY = scale.height();
}
invScaleX = SkScalarAbs(invScaleX);
invScaleY = SkScalarAbs(invScaleY);
if (invScaleX >= 1 - SK_ScalarNearlyZero || invScaleY >= 1 - SK_ScalarNearlyZero) {
// we're down-scaling so abort HQ
return false;
}
// Confirmed that we can use HQ (w/ rasterpipeline)
fQuality = kHigh_SkFilterQuality;
(void)provider.asBitmap(&fResultBitmap);
return true;
}
示例2: SkScalarCeilToInt
SkIRect SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection) const {
SkVector scale = SkVector::Make(fScale, fScale);
ctm.mapVectors(&scale, 1);
return src.makeOutset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHalf),
SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHalf));
}
示例3: map_sigma
static SkVector map_sigma(const SkSize& localSigma, const SkMatrix& ctm) {
SkVector sigma = SkVector::Make(localSigma.width(), localSigma.height());
ctm.mapVectors(&sigma, 1);
sigma.fX = SkMinScalar(SkScalarAbs(sigma.fX), MAX_SIGMA);
sigma.fY = SkMinScalar(SkScalarAbs(sigma.fY), MAX_SIGMA);
return sigma;
}
示例4: draw
bool draw(SkCanvas* canvas, const SkString& newText, SkScalar x, SkScalar y, SkPaint& paint)
{
SkScalar scale;
if (fInterp.timeToValues(SkTime::GetMSecs(), &scale) == SkInterpolator::kFreezeEnd_Result)
{
canvas->drawText(newText.c_str(), newText.size(), x, y, paint);
return false;
}
else
{
U8 alpha = paint.getAlpha();
SkScalar above, below;
(void)paint.measureText(nil, 0, &above, &below);
SkScalar height = below - above;
SkScalar dy = SkScalarMul(height, scale);
if (scale < 0)
height = -height;
// draw the old
paint.setAlpha((U8)SkScalarMul(alpha, SK_Scalar1 - SkScalarAbs(scale)));
canvas->drawText(fOldText.c_str(), fOldText.size(), x, y - dy, paint);
// draw the new
paint.setAlpha((U8)SkScalarMul(alpha, SkScalarAbs(scale)));
canvas->drawText(newText.c_str(), newText.size(), x, y + height - dy, paint);
// restore the paint
paint.setAlpha(alpha);
return true;
}
}
示例5: SkChopQuadAtXExtrema
/* Returns 0 for 1 quad, and 1 for two quads, either way the answer is
stored in dst[]. Guarantees that the 1/2 quads will be monotonic.
*/
int SkChopQuadAtXExtrema(const SkPoint src[3], SkPoint dst[5])
{
SkASSERT(src);
SkASSERT(dst);
SkScalar a = src[0].fX;
SkScalar b = src[1].fX;
SkScalar c = src[2].fX;
if (is_not_monotonic(a, b, c)) {
SkScalar tValue;
if (valid_unit_divide(a - b, a - b - b + c, &tValue)) {
SkChopQuadAt(src, dst, tValue);
flatten_double_quad_extrema(&dst[0].fX);
return 1;
}
// if we get here, we need to force dst to be monotonic, even though
// we couldn't compute a unit_divide value (probably underflow).
b = SkScalarAbs(a - b) < SkScalarAbs(b - c) ? a : c;
}
dst[0].set(a, src[0].fY);
dst[1].set(b, src[1].fY);
dst[2].set(c, src[2].fY);
return 0;
}
示例6: SkScalarAbs
void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const {
if (this->getColorInput()) {
this->getColorInput()->computeFastBounds(src, dst);
} else {
*dst = src;
}
dst->outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_ScalarHalf);
}
示例7: SkMaxScalar
bool SkPathMeasure::conic_too_curvy(const SkPoint& firstPt, const SkPoint& midTPt,
const SkPoint& lastPt) {
SkPoint midEnds = firstPt + lastPt;
midEnds *= 0.5f;
SkVector dxy = midTPt - midEnds;
SkScalar dist = SkMaxScalar(SkScalarAbs(dxy.fX), SkScalarAbs(dxy.fY));
return dist > fTolerance;
}
示例8: force_small_to_zero
// very tiny points cause numerical instability : don't allow them
static void force_small_to_zero(SkPoint* pt) {
if (SkScalarAbs(pt->fX) < FLT_EPSILON_ORDERABLE_ERR) {
pt->fX = 0;
}
if (SkScalarAbs(pt->fY) < FLT_EPSILON_ORDERABLE_ERR) {
pt->fY = 0;
}
}
示例9: unit_axis_align
static void unit_axis_align(SkVector* unit) {
const SkScalar TOLERANCE = SkDoubleToScalar(0.15);
if (SkScalarAbs(unit->fX) < TOLERANCE) {
unit->fX = 0;
unit->fY = SkScalarSign(unit->fY);
} else if (SkScalarAbs(unit->fY) < TOLERANCE) {
unit->fX = SkScalarSign(unit->fX);
unit->fY = 0;
}
}
示例10: has_aligned_samples
static bool has_aligned_samples(const SkRect& srcRect, const SkRect& transformedRect) {
// detect pixel disalignment
if (SkScalarAbs(SkScalarRoundToScalar(transformedRect.left()) - transformedRect.left()) < kColorBleedTolerance &&
SkScalarAbs(SkScalarRoundToScalar(transformedRect.top()) - transformedRect.top()) < kColorBleedTolerance &&
SkScalarAbs(transformedRect.width() - srcRect.width()) < kColorBleedTolerance &&
SkScalarAbs(transformedRect.height() - srcRect.height()) < kColorBleedTolerance) {
return true;
}
return false;
}
示例11: quad_too_curvy
static bool quad_too_curvy(const SkPoint pts[3]) {
// diff = (a/4 + b/2 + c/4) - (a/2 + c/2)
// diff = -a/4 + b/2 - c/4
SkScalar dx = SkScalarHalf(pts[1].fX) -
SkScalarHalf(SkScalarHalf(pts[0].fX + pts[2].fX));
SkScalar dy = SkScalarHalf(pts[1].fY) -
SkScalarHalf(SkScalarHalf(pts[0].fY + pts[2].fY));
SkScalar dist = SkMaxScalar(SkScalarAbs(dx), SkScalarAbs(dy));
return dist > CHEAP_DIST_LIMIT;
}
示例12: SkScalarHalf
bool SkPathMeasure::quad_too_curvy(const SkPoint pts[3]) {
// diff = (a/4 + b/2 + c/4) - (a/2 + c/2)
// diff = -a/4 + b/2 - c/4
SkScalar dx = SkScalarHalf(pts[1].fX) -
SkScalarHalf(SkScalarHalf(pts[0].fX + pts[2].fX));
SkScalar dy = SkScalarHalf(pts[1].fY) -
SkScalarHalf(SkScalarHalf(pts[0].fY + pts[2].fY));
SkScalar dist = SkMaxScalar(SkScalarAbs(dx), SkScalarAbs(dy));
return dist > fTolerance;
}
示例13: onClick
virtual bool onClick(SkView::Click* click) {
SkPoint prev = click->fPrev;
SkPoint curr = click->fCurr;
bool handled = true;
switch (click->fState) {
case SkView::Click::kDown_State:
if (SkScalarAbs(curr.fX - fCommands->width()) <= SKDEBUGGER_RESIZEBARSIZE) {
fCommandsResizing = true;
}
else if (SkScalarAbs(curr.fY - (this->height() - fState->height())) <= SKDEBUGGER_RESIZEBARSIZE &&
curr.fX > fCommands->width()) {
fStateResizing = true;
}
else if (curr.fX < fCommands->width()) {
fAtomsToRead = fCommands->selectHighlight(
SkScalarFloorToInt(curr.fY));
}
else
handled = false;
break;
case SkView::Click::kMoved_State:
if (fCommandsResizing)
fCommands->setSize(curr.fX, this->height());
else if (fStateResizing)
fState->setSize(this->width(), this->height() - curr.fY);
else if (curr.fX < fCommands->width()) {
if (curr.fY - prev.fY < 0) {
fCommands->scrollDown();
}
if (curr.fY - prev.fY > 0) {
fCommands->scrollUp();
}
}
else
handled = false;
break;
case SkView::Click::kUp_State:
fStateResizing = fCommandsResizing = false;
break;
default:
break;
}
fStateOffset = fCommands->width();
fState->setSize(this->width() - fStateOffset, fState->height());
fState->setLoc(fStateOffset, this->height() - fState->height());
if (handled)
this->inval(NULL);
return handled;
}
示例14: CurvesAreEqual
static bool CurvesAreEqual(const SkPoint c0[4],
const SkPoint c1[4],
float tol) {
for (int i = 0; i < 4; i++) {
if (SkScalarAbs(c0[i].fX - c1[i].fX) > tol ||
SkScalarAbs(c0[i].fY - c1[i].fY) > tol
) {
PrintCurve("c0", c0);
PrintCurve("c1", c1);
return false;
}
}
return true;
}
示例15: SkMaxScalar
// k = (y2 - y0, x0 - x2, (x2 - x0)*y0 - (y2 - y0)*x0 )
// l = (2*w * (y1 - y0), 2*w * (x0 - x1), 2*w * (x1*y0 - x0*y1))
// m = (2*w * (y2 - y1), 2*w * (x1 - x2), 2*w * (x2*y1 - x1*y2))
void GrPathUtils::getConicKLM(const SkPoint p[3], const SkScalar weight, SkScalar klm[9]) {
const SkScalar w2 = 2.f * weight;
klm[0] = p[2].fY - p[0].fY;
klm[1] = p[0].fX - p[2].fX;
klm[2] = (p[2].fX - p[0].fX) * p[0].fY - (p[2].fY - p[0].fY) * p[0].fX;
klm[3] = w2 * (p[1].fY - p[0].fY);
klm[4] = w2 * (p[0].fX - p[1].fX);
klm[5] = w2 * (p[1].fX * p[0].fY - p[0].fX * p[1].fY);
klm[6] = w2 * (p[2].fY - p[1].fY);
klm[7] = w2 * (p[1].fX - p[2].fX);
klm[8] = w2 * (p[2].fX * p[1].fY - p[1].fX * p[2].fY);
// scale the max absolute value of coeffs to 10
SkScalar scale = 0.f;
for (int i = 0; i < 9; ++i) {
scale = SkMaxScalar(scale, SkScalarAbs(klm[i]));
}
SkASSERT(scale > 0.f);
scale = 10.f / scale;
for (int i = 0; i < 9; ++i) {
klm[i] *= scale;
}
}