зеркало из https://github.com/mozilla/moz-skia.git
deprecate SkScalarRound (and its ilk), use SkScalarRound[ToInt,ToScalar]. #define SK_SUPPORT_DEPRECATED_SCALARROUND for legacy clients
BUG= R=robertphillips@google.com Review URL: https://codereview.chromium.org/111353003 git-svn-id: http://skia.googlecode.com/svn/trunk@12719 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
3fb15f4d21
Коммит
e1ca705cac
|
@ -43,7 +43,7 @@ public:
|
|||
if (SkScalarFraction(rad) != 0) {
|
||||
fName.printf("blur_%.2f_%s_%s", SkScalarToFloat(rad), name, quality);
|
||||
} else {
|
||||
fName.printf("blur_%d_%s_%s", SkScalarRound(rad), name, quality);
|
||||
fName.printf("blur_%d_%s_%s", SkScalarRoundToInt(rad), name, quality);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
if (SkScalarFraction(rad) != 0) {
|
||||
fName.printf("morph_%.2f_%s", SkScalarToFloat(rad), name);
|
||||
} else {
|
||||
fName.printf("morph_%d_%s", SkScalarRound(rad), name);
|
||||
fName.printf("morph_%d_%s", SkScalarRoundToInt(rad), name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ void SkGLWidget::paintGL() {
|
|||
|
||||
GrBackendRenderTargetDesc SkGLWidget::getDesc(int w, int h) {
|
||||
GrBackendRenderTargetDesc desc;
|
||||
desc.fWidth = SkScalarRound(this->width());
|
||||
desc.fHeight = SkScalarRound(this->height());
|
||||
desc.fWidth = SkScalarRoundToInt(this->width());
|
||||
desc.fHeight = SkScalarRoundToInt(this->height());
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt);
|
||||
GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits);
|
||||
|
|
|
@ -93,8 +93,8 @@ bool SkExampleWindow::setupBackend(DeviceType type) {
|
|||
|
||||
void SkExampleWindow::setupRenderTarget() {
|
||||
GrBackendRenderTargetDesc desc;
|
||||
desc.fWidth = SkScalarRound(width());
|
||||
desc.fHeight = SkScalarRound(height());
|
||||
desc.fWidth = SkScalarRoundToInt(width());
|
||||
desc.fHeight = SkScalarRoundToInt(height());
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
desc.fSampleCnt = fAttachmentInfo.fSampleCount;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "SkFixed.h"
|
||||
#include "SkFloatingPoint.h"
|
||||
|
||||
//#define SK_SUPPORT_DEPRECATED_SCALARROUND
|
||||
|
||||
typedef float SkScalar;
|
||||
|
||||
/** SK_Scalar1 is defined to be 1.0 represented as an SkScalar
|
||||
|
@ -108,13 +110,13 @@ inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
|
|||
#define SkScalarMulAdd(a, b, c) ((float)(a) * (b) + (c))
|
||||
/** Returns the product of a SkScalar and an int rounded to the nearest integer value
|
||||
*/
|
||||
#define SkScalarMulRound(a, b) SkScalarRound((float)(a) * (b))
|
||||
#define SkScalarMulRound(a, b) SkScalarRoundToInt((float)(a) * (b))
|
||||
/** Returns the product of a SkScalar and an int promoted to the next larger int
|
||||
*/
|
||||
#define SkScalarMulCeil(a, b) SkScalarCeil((float)(a) * (b))
|
||||
#define SkScalarMulCeil(a, b) SkScalarCeilToInt((float)(a) * (b))
|
||||
/** Returns the product of a SkScalar and an int truncated to the next smaller int
|
||||
*/
|
||||
#define SkScalarMulFloor(a, b) SkScalarFloor((float)(a) * (b))
|
||||
#define SkScalarMulFloor(a, b) SkScalarFloorToInt((float)(a) * (b))
|
||||
/** Returns the quotient of two SkScalars (a/b)
|
||||
*/
|
||||
#define SkScalarDiv(a, b) ((float)(a) / (b))
|
||||
|
@ -168,9 +170,11 @@ static inline bool SkScalarIsInt(SkScalar x) {
|
|||
}
|
||||
|
||||
// DEPRECATED : use ToInt or ToScalar variant
|
||||
#define SkScalarFloor(x) SkScalarFloorToInt(x)
|
||||
#define SkScalarCeil(x) SkScalarCeilToInt(x)
|
||||
#define SkScalarRound(x) SkScalarRoundToInt(x)
|
||||
#ifdef SK_SUPPORT_DEPRECATED_SCALARROUND
|
||||
# define SkScalarFloor(x) SkScalarFloorToInt(x)
|
||||
# define SkScalarCeil(x) SkScalarCeilToInt(x)
|
||||
# define SkScalarRound(x) SkScalarRoundToInt(x)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns -1 || 0 || 1 depending on the sign of value:
|
||||
|
|
|
@ -90,19 +90,19 @@ struct SkSize : public SkTSize<SkScalar> {
|
|||
|
||||
SkISize toRound() const {
|
||||
SkISize s;
|
||||
s.set(SkScalarRound(fWidth), SkScalarRound(fHeight));
|
||||
s.set(SkScalarRoundToInt(fWidth), SkScalarRoundToInt(fHeight));
|
||||
return s;
|
||||
}
|
||||
|
||||
SkISize toCeil() const {
|
||||
SkISize s;
|
||||
s.set(SkScalarCeil(fWidth), SkScalarCeil(fHeight));
|
||||
s.set(SkScalarCeilToInt(fWidth), SkScalarCeilToInt(fHeight));
|
||||
return s;
|
||||
}
|
||||
|
||||
SkISize toFloor() const {
|
||||
SkISize s;
|
||||
s.set(SkScalarFloor(fWidth), SkScalarFloor(fHeight));
|
||||
s.set(SkScalarFloorToInt(fWidth), SkScalarFloorToInt(fHeight));
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -451,7 +451,7 @@ protected:
|
|||
canvas->drawBitmap(fBug, left, top, &paint);
|
||||
canvas->translate(SkIntToScalar(30), 0);
|
||||
canvas->drawSprite(fTb,
|
||||
SkScalarRound(canvas->getTotalMatrix().getTranslateX()),
|
||||
SkScalarRoundToInt(canvas->getTotalMatrix().getTranslateX()),
|
||||
spriteOffset + 10, &paint);
|
||||
|
||||
canvas->translate(-SkIntToScalar(30), SkIntToScalar(30));
|
||||
|
|
|
@ -306,8 +306,8 @@ public:
|
|||
win->attach(fBackend, fMSAASampleCount, &attachmentInfo);
|
||||
|
||||
GrBackendRenderTargetDesc desc;
|
||||
desc.fWidth = SkScalarRound(win->width());
|
||||
desc.fHeight = SkScalarRound(win->height());
|
||||
desc.fWidth = SkScalarRoundToInt(win->width());
|
||||
desc.fHeight = SkScalarRoundToInt(win->height());
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
desc.fSampleCnt = attachmentInfo.fSampleCount;
|
||||
|
@ -1314,8 +1314,8 @@ void SampleWindow::showZoomer(SkCanvas* canvas) {
|
|||
int count = canvas->save();
|
||||
canvas->resetMatrix();
|
||||
// Ensure the mouse position is on screen.
|
||||
int width = SkScalarRound(this->width());
|
||||
int height = SkScalarRound(this->height());
|
||||
int width = SkScalarRoundToInt(this->width());
|
||||
int height = SkScalarRoundToInt(this->height());
|
||||
if (fMouseX >= width) fMouseX = width - 1;
|
||||
else if (fMouseX < 0) fMouseX = 0;
|
||||
if (fMouseY >= height) fMouseY = height - 1;
|
||||
|
@ -2039,8 +2039,8 @@ bool SampleWindow::onDispatchClick(int x, int y, Click::State state,
|
|||
if (Click::kMoved_State == state) {
|
||||
updatePointer(x, y);
|
||||
}
|
||||
int w = SkScalarRound(this->width());
|
||||
int h = SkScalarRound(this->height());
|
||||
int w = SkScalarRoundToInt(this->width());
|
||||
int h = SkScalarRoundToInt(this->height());
|
||||
|
||||
// check for the resize-box
|
||||
if (w - x < 16 && h - y < 16) {
|
||||
|
|
|
@ -79,10 +79,12 @@ FINISHED:
|
|||
for (;;)
|
||||
switch (iter.next(pts)) {
|
||||
case SkPath::kMove_Verb:
|
||||
array[n++].set(SkScalarRound(pts[0].fX), SkScalarRound(pts[0].fY));
|
||||
array[n++].set(SkScalarRoundToInt(pts[0].fX),
|
||||
SkScalarRoundToInt(pts[0].fY));
|
||||
break;
|
||||
case SkPath::kLine_Verb:
|
||||
array[n++].set(SkScalarRound(pts[1].fX), SkScalarRound(pts[1].fY));
|
||||
array[n++].set(SkScalarRoundToInt(pts[1].fX),
|
||||
SkScalarRoundToInt(pts[1].fY));
|
||||
break;
|
||||
case SkPath::kDone_Verb:
|
||||
goto FINISHED2;
|
||||
|
|
|
@ -58,7 +58,7 @@ protected:
|
|||
virtual void onDrawContent(SkCanvas* canvas) {
|
||||
fTime += SampleCode::GetAnimSecondsDelta();
|
||||
SkScalar delta = fTime / 15.f;
|
||||
int intPart = SkScalarFloor(delta);
|
||||
int intPart = SkScalarFloorToInt(delta);
|
||||
delta = delta - SK_Scalar1 * intPart;
|
||||
if (intPart % 2) {
|
||||
delta = SK_Scalar1 - delta;
|
||||
|
|
|
@ -82,8 +82,8 @@ protected:
|
|||
for (int i = 0; i < fBitmapCount; i++) {
|
||||
SkScalar x = (k * fBitmapCount + j) * W;
|
||||
SkScalar y = i * H;
|
||||
x = SkIntToScalar(SkScalarRound(x));
|
||||
y = SkIntToScalar(SkScalarRound(y));
|
||||
x = SkScalarRoundToScalar(x);
|
||||
y = SkScalarRoundToScalar(y);
|
||||
canvas->drawBitmap(fBitmaps[i], x, y, &paint);
|
||||
if (i == 0) {
|
||||
SkPaint p;
|
||||
|
|
|
@ -34,8 +34,8 @@ protected:
|
|||
|
||||
if (true) {
|
||||
SkBitmap mask;
|
||||
int w = SkScalarRound(r.width());
|
||||
int h = SkScalarRound(r.height());
|
||||
int w = SkScalarRoundToInt(r.width());
|
||||
int h = SkScalarRoundToInt(r.height());
|
||||
mask.setConfig(SkBitmap::kARGB_8888_Config, w, h);
|
||||
mask.allocPixels();
|
||||
mask.eraseColor(SK_ColorTRANSPARENT);
|
||||
|
|
|
@ -99,7 +99,7 @@ protected:
|
|||
}
|
||||
|
||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) SK_OVERRIDE {
|
||||
fAlpha = SkScalarRound(y);
|
||||
fAlpha = SkScalarRoundToInt(y);
|
||||
this->inval(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -396,7 +396,8 @@ protected:
|
|||
|
||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
|
||||
unsigned modi) SK_OVERRIDE {
|
||||
return fRect.contains(SkScalarRound(x), SkScalarRound(y)) ? new Click(this) : NULL;
|
||||
return fRect.contains(SkScalarRoundToInt(x),
|
||||
SkScalarRoundToInt(y)) ? new Click(this) : NULL;
|
||||
}
|
||||
|
||||
virtual bool onClick(Click* click) {
|
||||
|
|
|
@ -140,7 +140,7 @@ protected:
|
|||
|
||||
SkPaint paint;
|
||||
paint.setColor(fColor);
|
||||
paint.setAlpha(SkScalarRound(opacity * 255));
|
||||
paint.setAlpha(SkScalarRoundToInt(opacity * 255));
|
||||
|
||||
canvas->drawRect(r, paint);
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ void SkPowerMode::init(SkScalar e) {
|
|||
// printf(" %d %g", i, x);
|
||||
x = powf(x, ee);
|
||||
// printf(" %g", x);
|
||||
int xx = SkScalarRound(x * 255);
|
||||
int xx = SkScalarRoundToInt(x * 255);
|
||||
// printf(" %d\n", xx);
|
||||
fTable[i] = SkToU8(xx);
|
||||
}
|
||||
|
|
|
@ -163,8 +163,10 @@ void SkAnimateBase::packARGB(SkScalar array[], int count, SkTDOperandArray* conv
|
|||
{
|
||||
SkASSERT(count == 4);
|
||||
converted->setCount(1);
|
||||
SkColor color = SkColorSetARGB(SkScalarRound(array[0]), SkScalarRound(array[1]),
|
||||
SkScalarRound(array[2]), SkScalarRound(array[3]));
|
||||
SkColor color = SkColorSetARGB(SkScalarRoundToInt(array[0]),
|
||||
SkScalarRoundToInt(array[1]),
|
||||
SkScalarRoundToInt(array[2]),
|
||||
SkScalarRoundToInt(array[3]));
|
||||
(*converted)[0].fS32 = color;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ void SkDisplayMath::executeFunction(SkDisplayable* target, int index,
|
|||
scalarResult = SkScalarATan2(input, parameters[1].fOperand.fScalar);
|
||||
break;
|
||||
case SK_FUNCTION(ceil):
|
||||
scalarResult = SkIntToScalar(SkScalarCeil(input));
|
||||
scalarResult = SkScalarCeilToScalar(input);
|
||||
break;
|
||||
case SK_FUNCTION(cos):
|
||||
scalarResult = SkScalarCos(input);
|
||||
|
@ -164,7 +164,7 @@ void SkDisplayMath::executeFunction(SkDisplayable* target, int index,
|
|||
scalarResult = SkScalarExp(input);
|
||||
break;
|
||||
case SK_FUNCTION(floor):
|
||||
scalarResult = SkIntToScalar(SkScalarFloor(input));
|
||||
scalarResult = SkScalarFloorToScalar(input);
|
||||
break;
|
||||
case SK_FUNCTION(log):
|
||||
scalarResult = SkScalarLog(input);
|
||||
|
@ -193,7 +193,7 @@ void SkDisplayMath::executeFunction(SkDisplayable* target, int index,
|
|||
scalarResult = fRandom.nextUScalar1();
|
||||
break;
|
||||
case SK_FUNCTION(round):
|
||||
scalarResult = SkIntToScalar(SkScalarRound(input));
|
||||
scalarResult = SkScalarRoundToScalar(input);
|
||||
break;
|
||||
case SK_FUNCTION(sin):
|
||||
scalarResult = SkScalarSin(input);
|
||||
|
|
|
@ -69,7 +69,7 @@ static SkColor HSV_to_RGB(SkColor color, HSV_Choice choice, SkScalar hsv) {
|
|||
red = green = blue = value;
|
||||
else {
|
||||
//SkScalar fraction = SkScalarMod(hue, 60 * SK_Scalar1);
|
||||
int sextant = SkScalarFloor(hue / 60);
|
||||
int sextant = SkScalarFloorToInt(hue / 60);
|
||||
SkScalar fraction = hue / 60 - SkIntToScalar(sextant);
|
||||
SkScalar p = SkScalarMul(value , SK_Scalar1 - saturation);
|
||||
SkScalar q = SkScalarMul(value, SK_Scalar1 - SkScalarMul(saturation, fraction));
|
||||
|
@ -85,8 +85,8 @@ static SkColor HSV_to_RGB(SkColor color, HSV_Choice choice, SkScalar hsv) {
|
|||
}
|
||||
}
|
||||
//used to say SkToU8((U8CPU) red) etc
|
||||
return SkColorSetARGB(SkColorGetA(color), SkScalarRound(red),
|
||||
SkScalarRound(green), SkScalarRound(blue));
|
||||
return SkColorSetARGB(SkColorGetA(color), SkScalarRoundToInt(red),
|
||||
SkScalarRoundToInt(green), SkScalarRoundToInt(blue));
|
||||
}
|
||||
|
||||
#if defined _WIN32 && _MSC_VER >= 1300
|
||||
|
|
|
@ -81,7 +81,7 @@ SkInterpolatorBase::Result SkOperandInterpolator::timeToValues(SkMSec time, SkOp
|
|||
for (int i = fElemCount - 1; i >= 0; --i) {
|
||||
int32_t a = prevSrc[i].fS32;
|
||||
int32_t b = nextSrc[i].fS32;
|
||||
values[i].fS32 = a + SkScalarRound((b - a) * T);
|
||||
values[i].fS32 = a + SkScalarRoundToInt((b - a) * T);
|
||||
}
|
||||
} else
|
||||
memcpy(values, prevSrc, sizeof(SkOperand) * fElemCount);
|
||||
|
|
|
@ -1157,7 +1157,7 @@ noMatch:
|
|||
}
|
||||
SkOperand indexOperand;
|
||||
fOperandStack.pop(&indexOperand);
|
||||
int index = indexType == kScalar ? SkScalarFloor(indexOperand.fScalar) :
|
||||
int index = indexType == kScalar ? SkScalarFloorToInt(indexOperand.fScalar) :
|
||||
indexOperand.fS32;
|
||||
SkOpType arrayType;
|
||||
fTypeStack.pop(&arrayType);
|
||||
|
@ -1324,7 +1324,7 @@ bool SkScriptEngine::processOp() {
|
|||
type1 = kScalar;
|
||||
}
|
||||
if (type1 == kScalar && (attributes->fLeftType == kInt || type2 == kInt)) {
|
||||
operand1.fS32 = SkScalarFloor(operand1.fScalar);
|
||||
operand1.fS32 = SkScalarFloorToInt(operand1.fScalar);
|
||||
type1 = kInt;
|
||||
}
|
||||
}
|
||||
|
@ -1339,7 +1339,7 @@ bool SkScriptEngine::processOp() {
|
|||
type2 = kScalar;
|
||||
}
|
||||
if (type2 == kScalar && (attributes->fRightType == kInt || type1 == kInt)) {
|
||||
operand2.fS32 = SkScalarFloor(operand2.fScalar);
|
||||
operand2.fS32 = SkScalarFloorToInt(operand2.fScalar);
|
||||
type2 = kInt;
|
||||
}
|
||||
}
|
||||
|
@ -1503,7 +1503,7 @@ bool SkScriptEngine::ConvertTo(SkScriptEngine* engine, SkDisplayTypes toType, Sk
|
|||
if (type == SkType_Boolean)
|
||||
break;
|
||||
if (type == SkType_Float)
|
||||
operand.fS32 = SkScalarFloor(operand.fScalar);
|
||||
operand.fS32 = SkScalarFloorToInt(operand.fScalar);
|
||||
else {
|
||||
if (type != SkType_String) {
|
||||
success = false;
|
||||
|
|
|
@ -210,7 +210,7 @@ bool SkScriptRuntime::executeTokens(unsigned char* opCode) {
|
|||
return false;
|
||||
break;
|
||||
case SkScriptEngine2::kScalarToInt:
|
||||
operand[0].fS32 = SkScalarFloor(operand[0].fScalar);
|
||||
operand[0].fS32 = SkScalarFloorToInt(operand[0].fScalar);
|
||||
break;
|
||||
// arithmetic ops
|
||||
case SkScriptEngine2::kAddInt:
|
||||
|
|
|
@ -984,7 +984,7 @@ void SkScriptEngine2::processLogicalOp(Op op) {
|
|||
SkScriptValue2 value;
|
||||
fValueStack.pop(&value);
|
||||
SkASSERT(value.fType == SkOperand2::kS32 || value.fType == SkOperand2::kScalar); // !!! add error handling (although, could permit strings eventually)
|
||||
int index = value.fType == SkOperand2::kScalar ? SkScalarFloor(value.fOperand.fScalar) :
|
||||
int index = value.fType == SkOperand2::kScalar ? SkScalarFloorToInt(value.fOperand.fScalar) :
|
||||
value.fOperand.fS32;
|
||||
SkScriptValue2 arrayValue;
|
||||
fValueStack.pop(&arrayValue);
|
||||
|
@ -1200,7 +1200,7 @@ bool SkScriptEngine2::ConvertTo(SkScriptEngine2* engine, SkOperand2::OpType toTy
|
|||
switch (toType) {
|
||||
case SkOperand2::kS32:
|
||||
if (type == SkOperand2::kScalar)
|
||||
operand.fS32 = SkScalarFloor(operand.fScalar);
|
||||
operand.fS32 = SkScalarFloorToInt(operand.fScalar);
|
||||
else {
|
||||
SkASSERT(type == SkOperand2::kString);
|
||||
success = SkParse::FindS32(operand.fString->c_str(), &operand.fS32) != NULL;
|
||||
|
|
|
@ -62,6 +62,6 @@ bool SkSnapshot::draw(SkAnimateMaker& maker) {
|
|||
name.append(".png");
|
||||
encoder->encodeFile(name.c_str(),
|
||||
maker.fCanvas->getDevice()->accessBitmap(false),
|
||||
SkScalarFloor(quality));
|
||||
SkScalarFloorToInt(quality));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -288,10 +288,10 @@ void SkClipStack::Element::updateBoundAndGenID(const Element* prior) {
|
|||
// Note: the left edge is handled slightly differently below. We
|
||||
// are a bit more generous in the rounding since we don't want to
|
||||
// risk missing the left pixels when fLeft is very close to .5
|
||||
fFiniteBound.set(SkIntToScalar(SkScalarFloorToInt(fFiniteBound.fLeft+0.45f)),
|
||||
SkIntToScalar(SkScalarRound(fFiniteBound.fTop)),
|
||||
SkIntToScalar(SkScalarRound(fFiniteBound.fRight)),
|
||||
SkIntToScalar(SkScalarRound(fFiniteBound.fBottom)));
|
||||
fFiniteBound.set(SkScalarFloorToScalar(fFiniteBound.fLeft+0.45f),
|
||||
SkScalarRoundToScalar(fFiniteBound.fTop),
|
||||
SkScalarRoundToScalar(fFiniteBound.fRight),
|
||||
SkScalarRoundToScalar(fFiniteBound.fBottom));
|
||||
}
|
||||
|
||||
// Now determine the previous Element's bound information taking into
|
||||
|
|
|
@ -399,8 +399,8 @@ static void bw_pt_rect_32_hair_proc(const PtProcRec& rec,
|
|||
static void bw_pt_hair_proc(const PtProcRec& rec, const SkPoint devPts[],
|
||||
int count, SkBlitter* blitter) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int x = SkScalarFloor(devPts[i].fX);
|
||||
int y = SkScalarFloor(devPts[i].fY);
|
||||
int x = SkScalarFloorToInt(devPts[i].fX);
|
||||
int y = SkScalarFloorToInt(devPts[i].fY);
|
||||
if (rec.fClip->contains(x, y)) {
|
||||
blitter->blitH(x, y, 1);
|
||||
}
|
||||
|
@ -1195,8 +1195,8 @@ void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
|
|||
SkASSERT(bitmap.config() == SkBitmap::kA8_Config);
|
||||
|
||||
if (just_translate(*fMatrix, bitmap)) {
|
||||
int ix = SkScalarRound(fMatrix->getTranslateX());
|
||||
int iy = SkScalarRound(fMatrix->getTranslateY());
|
||||
int ix = SkScalarRoundToInt(fMatrix->getTranslateX());
|
||||
int iy = SkScalarRoundToInt(fMatrix->getTranslateY());
|
||||
|
||||
SkAutoLockPixels alp(bitmap);
|
||||
if (!bitmap.readyToDraw()) {
|
||||
|
@ -1318,8 +1318,8 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
|
|||
|
||||
if (fBounder && just_translate(matrix, bitmap)) {
|
||||
SkIRect ir;
|
||||
int32_t ix = SkScalarRound(matrix.getTranslateX());
|
||||
int32_t iy = SkScalarRound(matrix.getTranslateY());
|
||||
int32_t ix = SkScalarRoundToInt(matrix.getTranslateX());
|
||||
int32_t iy = SkScalarRoundToInt(matrix.getTranslateY());
|
||||
ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height());
|
||||
if (!fBounder->doIRect(ir)) {
|
||||
return;
|
||||
|
@ -1336,8 +1336,8 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
|
|||
if (!bitmap.readyToDraw()) {
|
||||
return;
|
||||
}
|
||||
int ix = SkScalarRound(matrix.getTranslateX());
|
||||
int iy = SkScalarRound(matrix.getTranslateY());
|
||||
int ix = SkScalarRoundToInt(matrix.getTranslateX());
|
||||
int iy = SkScalarRoundToInt(matrix.getTranslateY());
|
||||
if (clipHandlesSprite(*fRC, ix, iy, bitmap)) {
|
||||
uint32_t storage[kBlitterStorageLongCount];
|
||||
SkBlitter* blitter = SkBlitter::ChooseSprite(*fBitmap, paint, bitmap,
|
||||
|
@ -2741,16 +2741,16 @@ bool SkBounder::doHairline(const SkPoint& pt0, const SkPoint& pt1,
|
|||
if (v0 > v1) {
|
||||
SkTSwap<SkScalar>(v0, v1);
|
||||
}
|
||||
r.fLeft = SkScalarFloor(v0);
|
||||
r.fRight = SkScalarCeil(v1);
|
||||
r.fLeft = SkScalarFloorToInt(v0);
|
||||
r.fRight = SkScalarCeilToInt(v1);
|
||||
|
||||
v0 = pt0.fY;
|
||||
v1 = pt1.fY;
|
||||
if (v0 > v1) {
|
||||
SkTSwap<SkScalar>(v0, v1);
|
||||
}
|
||||
r.fTop = SkScalarFloor(v0);
|
||||
r.fBottom = SkScalarCeil(v1);
|
||||
r.fTop = SkScalarFloorToInt(v0);
|
||||
r.fBottom = SkScalarCeilToInt(v1);
|
||||
|
||||
if (paint.isAntiAlias()) {
|
||||
r.inset(-1, -1);
|
||||
|
|
|
@ -345,9 +345,9 @@ SkRTree::Branch SkRTree::bulkLoad(SkTDArray<Branch>* branches, int level) {
|
|||
}
|
||||
}
|
||||
|
||||
int numStrips = SkScalarCeil(SkScalarSqrt(SkIntToScalar(numBranches) *
|
||||
int numStrips = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(numBranches) *
|
||||
SkScalarInvert(fAspectRatio)));
|
||||
int numTiles = SkScalarCeil(SkIntToScalar(numBranches) /
|
||||
int numTiles = SkScalarCeilToInt(SkIntToScalar(numBranches) /
|
||||
SkIntToScalar(numStrips));
|
||||
int currentBranch = 0;
|
||||
|
||||
|
|
|
@ -290,8 +290,8 @@ static int count_path_runtype_values(const SkPath& path, int* itop, int* ibot) {
|
|||
}
|
||||
SkASSERT(top <= bot);
|
||||
|
||||
*itop = SkScalarRound(top);
|
||||
*ibot = SkScalarRound(bot);
|
||||
*itop = SkScalarRoundToInt(top);
|
||||
*ibot = SkScalarRoundToInt(bot);
|
||||
return maxEdges;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,8 +200,8 @@ static int compute_int_quad_dist(const SkPoint pts[3]) {
|
|||
dx = SkScalarAbs(dx);
|
||||
dy = SkScalarAbs(dy);
|
||||
// convert to whole pixel values (use ceiling to be conservative)
|
||||
int idx = SkScalarCeil(dx);
|
||||
int idy = SkScalarCeil(dy);
|
||||
int idx = SkScalarCeilToInt(dx);
|
||||
int idy = SkScalarCeilToInt(dy);
|
||||
// use the cheap approx for distance
|
||||
if (idx > idy) {
|
||||
return idx + (idy >> 1);
|
||||
|
|
|
@ -404,7 +404,7 @@ static int boxBlurInterp(const uint8_t* src, int src_y_stride, uint8_t* dst,
|
|||
|
||||
static void get_adjusted_radii(SkScalar passRadius, int *loRadius, int *hiRadius)
|
||||
{
|
||||
*loRadius = *hiRadius = SkScalarCeil(passRadius);
|
||||
*loRadius = *hiRadius = SkScalarCeilToInt(passRadius);
|
||||
if (SkIntToScalar(*hiRadius) - passRadius > 0.5f) {
|
||||
*loRadius = *hiRadius - 1;
|
||||
}
|
||||
|
@ -512,8 +512,8 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src,
|
|||
// to approximate a Gaussian blur
|
||||
int passCount = (kHigh_Quality == quality) ? 3 : 1;
|
||||
|
||||
int rx = SkScalarCeil(passRadius);
|
||||
int outerWeight = 255 - SkScalarRound((SkIntToScalar(rx) - passRadius) * 255);
|
||||
int rx = SkScalarCeilToInt(passRadius);
|
||||
int outerWeight = 255 - SkScalarRoundToInt((SkIntToScalar(rx) - passRadius) * 255);
|
||||
|
||||
SkASSERT(rx >= 0);
|
||||
SkASSERT((unsigned)outerWeight <= 255);
|
||||
|
@ -865,7 +865,7 @@ bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
|
|||
|
||||
float variance = sigma * sigma;
|
||||
|
||||
int windowSize = SkScalarCeil(sigma*6);
|
||||
int windowSize = SkScalarCeilToInt(sigma*6);
|
||||
// round window size up to nearest odd number
|
||||
windowSize |= 1;
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
|
|||
scale = SkScalarDiv(length, fIntervalLength);
|
||||
} else {
|
||||
SkScalar div = SkScalarDiv(length, fIntervalLength);
|
||||
int n = SkScalarFloor(div);
|
||||
int n = SkScalarFloorToInt(div);
|
||||
scale = SkScalarDiv(length, n * fIntervalLength);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
|
|||
bool doFill = rec->isFillStyle();
|
||||
|
||||
SkPathMeasure meas(src, doFill);
|
||||
uint32_t seed = SkScalarRound(meas.getLength());
|
||||
uint32_t seed = SkScalarRoundToInt(meas.getLength());
|
||||
SkLCGRandom rand(seed ^ ((seed << 16) | (seed >> 16)));
|
||||
SkScalar scale = fPerterb;
|
||||
SkPoint p;
|
||||
|
@ -42,7 +42,7 @@ bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
|
|||
if (fSegLength * (2 + doFill) > length) {
|
||||
meas.getSegment(0, length, dst, true); // to short for us to mangle
|
||||
} else {
|
||||
int n = SkScalarRound(SkScalarDiv(length, fSegLength));
|
||||
int n = SkScalarRoundToInt(length / fSegLength);
|
||||
SkScalar delta = length / n;
|
||||
SkScalar distance = 0;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src,
|
|||
|
||||
dst->fFormat = SkMask::k3D_Format;
|
||||
if (margin) {
|
||||
margin->set(SkScalarCeil(3*sigma), SkScalarCeil(3*sigma));
|
||||
margin->set(SkScalarCeilToInt(3*sigma), SkScalarCeilToInt(3*sigma));
|
||||
}
|
||||
|
||||
if (src.fImage == NULL) {
|
||||
|
|
|
@ -51,7 +51,7 @@ uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[],
|
|||
// subdivide x = log4(d/tol) times. x subdivisions creates 2^(x)
|
||||
// points.
|
||||
// 2^(log4(x)) = sqrt(x);
|
||||
int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
|
||||
int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol)));
|
||||
int pow2 = GrNextPow2(temp);
|
||||
// Because of NaNs & INFs we can wind up with a degenerate temp
|
||||
// such that pow2 comes out negative. Also, our point generator
|
||||
|
@ -102,7 +102,7 @@ uint32_t GrPathUtils::cubicPointCount(const GrPoint points[],
|
|||
if (d <= tol) {
|
||||
return 1;
|
||||
} else {
|
||||
int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
|
||||
int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol)));
|
||||
int pow2 = GrNextPow2(temp);
|
||||
// Because of NaNs & INFs we can wind up with a degenerate temp
|
||||
// such that pow2 comes out negative. Also, our point generator
|
||||
|
|
|
@ -988,8 +988,8 @@ SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
|
|||
SkMatrix unflip;
|
||||
unflip.setTranslate(0, SkScalarRoundToScalar(deviceBounds.height()));
|
||||
unflip.preScale(SK_Scalar1, -SK_Scalar1);
|
||||
SkISize size = SkISize::Make(SkScalarRound(deviceBounds.width()),
|
||||
SkScalarRound(deviceBounds.height()));
|
||||
SkISize size = SkISize::Make(SkScalarRoundToInt(deviceBounds.width()),
|
||||
SkScalarRoundToInt(deviceBounds.height()));
|
||||
// TODO(edisonn): should we pass here the DCT encoder of the destination device?
|
||||
// TODO(edisonn): NYI Perspective, use SkPDFDeviceFlattener.
|
||||
SkPDFDevice pattern(size, size, unflip);
|
||||
|
|
|
@ -142,7 +142,7 @@ void SkPDFScalar::Append(SkScalar value, SkWStream* stream) {
|
|||
|
||||
#if !defined(SK_ALLOW_LARGE_PDF_SCALARS)
|
||||
if (value > 32767 || value < -32767) {
|
||||
stream->writeDecAsText(SkScalarRound(value));
|
||||
stream->writeDecAsText(SkScalarRoundToInt(value));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1065,7 +1065,7 @@ static void build_power_table(uint8_t table[], float ee) {
|
|||
for (int i = 0; i < 256; i++) {
|
||||
float x = i / 255.f;
|
||||
x = sk_float_pow(x, ee);
|
||||
int xx = SkScalarRound(x * 255);
|
||||
int xx = SkScalarRoundToInt(x * 255);
|
||||
table[i] = SkToU8(xx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -487,8 +487,8 @@ const char* SkParse::FindColor(const char* value, SkColor* colorPtr) {
|
|||
// if (end == NULL)
|
||||
// return NULL;
|
||||
// !!! range check for errors?
|
||||
// *colorPtr = SkColorSetARGB(SkScalarRound(array[0]), SkScalarRound(array[1]),
|
||||
// SkScalarRound(array[2]), SkScalarRound(array[3]));
|
||||
// *colorPtr = SkColorSetARGB(SkScalarRoundToInt(array[0]), SkScalarRoundToInt(array[1]),
|
||||
// SkScalarRoundToInt(array[2]), SkScalarRoundToInt(array[3]));
|
||||
// return end;
|
||||
} else
|
||||
return FindNamedColor(value, strlen(value), colorPtr);
|
||||
|
|
|
@ -96,7 +96,7 @@ void SkPaint_Inflate(SkPaint* paint, const SkDOM& dom, const SkDOM::Node* node)
|
|||
if (dom.findScalar(node, "opacity", &x))
|
||||
{
|
||||
x = SkMaxScalar(0, SkMinScalar(x, SK_Scalar1));
|
||||
paint->setAlpha(SkScalarRound(x * 255));
|
||||
paint->setAlpha(SkScalarRoundToInt(x * 255));
|
||||
}
|
||||
|
||||
int index = dom.findList(node, "text-anchor", "left,center,right");
|
||||
|
|
|
@ -167,11 +167,11 @@ void SkStackViewLayout::onLayoutChildren(SkView* parent)
|
|||
while ((child = iter.next()) != NULL)
|
||||
{
|
||||
if (fRound)
|
||||
pos = SkIntToScalar(SkScalarRound(pos));
|
||||
pos = SkScalarRoundToScalar(pos);
|
||||
(child->*mainLocP)(pos);
|
||||
SkScalar crossLoc = crossStartM + gAlignProcs[fAlign]((child->*crossGetSizeP)(), crossLimit);
|
||||
if (fRound)
|
||||
crossLoc = SkIntToScalar(SkScalarRound(crossLoc));
|
||||
crossLoc = SkScalarRoundToScalar(crossLoc);
|
||||
(child->*crossLocP)(crossLoc);
|
||||
|
||||
if (crossSetSizeP)
|
||||
|
|
|
@ -134,8 +134,8 @@ bool SkWindow::handleInval(const SkRect* localR)
|
|||
devR.round(&ir);
|
||||
} else {
|
||||
ir.set(0, 0,
|
||||
SkScalarRound(this->width()),
|
||||
SkScalarRound(this->height()));
|
||||
SkScalarRoundToInt(this->width()),
|
||||
SkScalarRoundToInt(this->height()));
|
||||
}
|
||||
fDirtyRgn.op(ir, SkRegion::kUnion_Op);
|
||||
|
||||
|
@ -145,8 +145,8 @@ bool SkWindow::handleInval(const SkRect* localR)
|
|||
|
||||
void SkWindow::forceInvalAll() {
|
||||
fDirtyRgn.setRect(0, 0,
|
||||
SkScalarCeil(this->width()),
|
||||
SkScalarCeil(this->height()));
|
||||
SkScalarCeilToInt(this->width()),
|
||||
SkScalarCeilToInt(this->height()));
|
||||
}
|
||||
|
||||
#if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN)
|
||||
|
|
|
@ -330,7 +330,8 @@ bool SkOSWindow::attach(SkBackEndTypes, int msaaSampleCount, AttachmentInfo* inf
|
|||
fUnixWindow.fWin,
|
||||
fUnixWindow.fGLContext);
|
||||
glViewport(0, 0,
|
||||
SkScalarRound(this->width()), SkScalarRound(this->height()));
|
||||
SkScalarRoundToInt(this->width()),
|
||||
SkScalarRoundToInt(this->height()));
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClearStencil(0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
|
|
@ -361,7 +361,9 @@ bool SkOSWindow::attachGL(int msaaSampleCount, AttachmentInfo* info) {
|
|||
info->fSampleCount = 0;
|
||||
}
|
||||
|
||||
glViewport(0, 0, SkScalarRound(this->width()), SkScalarRound(this->height()));
|
||||
glViewport(0, 0,
|
||||
SkScalarRoundToInt(this->width()),
|
||||
SkScalarRoundToInt(this->height()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -500,8 +502,9 @@ bool SkOSWindow::attachANGLE(int msaaSampleCount, AttachmentInfo* info) {
|
|||
SkAutoTUnref<const GrGLInterface> intf(GrGLCreateANGLEInterface());
|
||||
|
||||
if (intf ) {
|
||||
ANGLE_GL_CALL(intf, Viewport(0, 0, SkScalarRound(this->width()),
|
||||
SkScalarRound(this->height())));
|
||||
ANGLE_GL_CALL(intf, Viewport(0, 0,
|
||||
SkScalarRoundToInt(this->width()),
|
||||
SkScalarRoundToInt(this->height())));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ static const uint32_t MAX_POINTS_PER_CURVE = 1 << MAX_COEFF_SHIFT;
|
|||
// For determining the maximum possible number of points to use in
|
||||
// drawing a quadratic, we want to err on the high side.
|
||||
static inline int cheap_distance(SkScalar dx, SkScalar dy) {
|
||||
int idx = SkAbs32(SkScalarRound(dx));
|
||||
int idy = SkAbs32(SkScalarRound(dy));
|
||||
int idx = SkAbs32(SkScalarRoundToInt(dx));
|
||||
int idy = SkAbs32(SkScalarRoundToInt(dy));
|
||||
if (idx > idy) {
|
||||
idx += idy >> 1;
|
||||
} else {
|
||||
|
@ -79,7 +79,7 @@ static uint32_t quadraticPointCount_EC(const SkPoint points[], SkScalar tol) {
|
|||
|
||||
static uint32_t quadraticPointCount_CE(const SkPoint points[]) {
|
||||
SkScalar distance = compute_distance(points);
|
||||
return estimate_pointCount(SkScalarRound(distance));
|
||||
return estimate_pointCount(SkScalarRoundToInt(distance));
|
||||
}
|
||||
|
||||
static uint32_t quadraticPointCount_CC(const SkPoint points[], SkScalar tol) {
|
||||
|
|
|
@ -347,11 +347,11 @@ bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths) {
|
|||
larger.join(bounds2);
|
||||
SkBitmap bits;
|
||||
char out[256];
|
||||
int bitWidth = SkScalarCeil(larger.width()) + 2;
|
||||
int bitWidth = SkScalarCeilToInt(larger.width()) + 2;
|
||||
if (bitWidth * 2 + 1 >= (int) sizeof(out)) {
|
||||
return false;
|
||||
}
|
||||
int bitHeight = SkScalarCeil(larger.height()) + 2;
|
||||
int bitHeight = SkScalarCeilToInt(larger.height()) + 2;
|
||||
if (bitHeight >= (int) sizeof(out)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ int tool_main(int argc, char** argv) {
|
|||
SkScalar width = paint.measureText(text.c_str(), text.size());
|
||||
SkScalar spacing = paint.getFontSpacing();
|
||||
|
||||
int w = SkScalarRound(width) + 30;
|
||||
int h = SkScalarRound(spacing) + 30;
|
||||
int w = SkScalarRoundToInt(width) + 30;
|
||||
int h = SkScalarRoundToInt(spacing) + 30;
|
||||
|
||||
static const struct {
|
||||
bool (*fProc)(int w, int h, const char path[], const char text[],
|
||||
|
|
Загрузка…
Ссылка в новой задаче