本文整理汇总了C++中SkScalarToFloat函数的典型用法代码示例。如果您正苦于以下问题:C++ SkScalarToFloat函数的具体用法?C++ SkScalarToFloat怎么用?C++ SkScalarToFloat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkScalarToFloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MorphologyBench
MorphologyBench(SkScalar rad, MorphologyType style)
{
fRadius = rad;
fStyle = style;
const char* name = rad > 0 ? gStyleName[style] : "none";
if (SkScalarFraction(rad) != 0) {
fName.printf("morph_%.2f_%s", SkScalarToFloat(rad), name);
} else {
fName.printf("morph_%d_%s", SkScalarRoundToInt(rad), name);
}
}
示例2: SkScalarToFloat
float SkTouchGesture::limitTotalZoom(float scale) const {
// this query works 'cause we know that we're square-scale w/ no skew/rotation
const float curr = SkScalarToFloat(fGlobalM[0]);
if (scale > 1 && curr * scale > MAX_ZOOM_SCALE) {
scale = MAX_ZOOM_SCALE / curr;
} else if (scale < 1 && curr * scale < MIN_ZOOM_SCALE) {
scale = MIN_ZOOM_SCALE / curr;
}
return scale;
}
示例3: BlurRectDirectBench
BlurRectDirectBench(SkScalar rad) : INHERITED(rad) {
SkString name;
if (SkScalarFraction(rad) != 0) {
name.printf("blurrect_direct_%.2f", SkScalarToFloat(rad));
} else {
name.printf("blurrect_direct_%d", SkScalarRoundToInt(rad));
}
this->setName(name);
}
示例4: measure
float Path::length() const
{
SkScalar length = 0;
SkPathMeasure measure(m_path, false);
do {
length += measure.getLength();
} while (measure.nextContour());
return SkScalarToFloat(length);
}
示例5: SkScalarToFloat
void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) {
const float dx = 1 / 255.0f;
const float g = SkScalarToFloat(gamma);
float x = 0;
for (int i = 0; i < 256; i++) {
// float ee = powf(x, g) * 255;
table[i] = SkPin32(sk_float_round2int(powf(x, g) * 255), 0, 255);
x += dx;
}
}
示例6: android_view_MotionEvent_nativeTransform
static void android_view_MotionEvent_nativeTransform(JNIEnv* env, jclass clazz,
jint nativePtr, jobject matrixObj) {
SkMatrix* matrix = android_graphics_Matrix_getSkMatrix(env, matrixObj);
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
float m[9];
m[0] = SkScalarToFloat(matrix->get(SkMatrix::kMScaleX));
m[1] = SkScalarToFloat(matrix->get(SkMatrix::kMSkewX));
m[2] = SkScalarToFloat(matrix->get(SkMatrix::kMTransX));
m[3] = SkScalarToFloat(matrix->get(SkMatrix::kMSkewY));
m[4] = SkScalarToFloat(matrix->get(SkMatrix::kMScaleY));
m[5] = SkScalarToFloat(matrix->get(SkMatrix::kMTransY));
m[6] = SkScalarToFloat(matrix->get(SkMatrix::kMPersp0));
m[7] = SkScalarToFloat(matrix->get(SkMatrix::kMPersp1));
m[8] = SkScalarToFloat(matrix->get(SkMatrix::kMPersp2));
event->transform(m);
}
示例7: measureText_String
static jfloat measureText_String(JNIEnv* env, jobject jpaint, jstring text) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, text);
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
const jchar* textArray = env->GetStringChars(text, NULL);
size_t textLength = env->GetStringLength(text);
jfloat width = SkScalarToFloat(paint->measureText(textArray, textLength << 1));
env->ReleaseStringChars(text, textArray);
return width;
}
示例8: drawGrad
static void drawGrad(SkCanvas* canvas, const SkScalar d0[], const SkScalar d1[]) {
const SkRect bounds = SkRect::MakeXYWH(SkIntToScalar(-50),
SkIntToScalar(-50),
SkIntToScalar(200),
SkIntToScalar(100));
SkPoint c0 = { d0[0], d0[1] };
SkScalar r0 = d0[2];
SkPoint c1 = { d1[0], d1[1] };
SkScalar r1 = d1[2];
SkColor colors[] = { SK_ColorGREEN, SK_ColorRED };
SkPaint paint;
paint.setAntiAlias(true);
SkString str;
str.printf("%g,%g,%g %g,%g,%g",
SkScalarToFloat(c0.fX), SkScalarToFloat(c0.fY), SkScalarToFloat(r0),
SkScalarToFloat(c1.fX), SkScalarToFloat(c1.fY), SkScalarToFloat(r1));
canvas->drawText(str.c_str(), str.size(),
bounds.fLeft, bounds.fTop - paint.getTextSize()/2, paint);
paint.setShader(SkGradientShader::CreateTwoPointConical(c0, r0, c1, r1,
colors, NULL, 2,
SkShader::kClamp_TileMode))->unref();
canvas->drawRect(bounds, paint);
paint.setShader(NULL);
paint.setColor(0x66000000);
paint.setStyle(SkPaint::kStroke_Style);
canvas->drawCircle(c0.fX, c0.fY, r0, paint);
canvas->drawCircle(c1.fX, c1.fY, r1, paint);
canvas->drawRect(bounds, paint);
}
示例9: SkASSERT
// Static function to create a 2D convolution
GrFragmentProcessor*
GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture,
const SkIRect& bounds,
const SkISize& kernelSize,
SkScalar gain,
SkScalar bias,
const SkIPoint& kernelOffset,
GrTextureDomain::Mode tileMode,
bool convolveAlpha,
SkScalar sigmaX,
SkScalar sigmaY) {
float kernel[MAX_KERNEL_SIZE];
int width = kernelSize.width();
int height = kernelSize.height();
SkASSERT(width * height <= MAX_KERNEL_SIZE);
float sum = 0.0f;
float sigmaXDenom = 1.0f / (2.0f * SkScalarToFloat(SkScalarSquare(sigmaX)));
float sigmaYDenom = 1.0f / (2.0f * SkScalarToFloat(SkScalarSquare(sigmaY)));
int xRadius = width / 2;
int yRadius = height / 2;
for (int x = 0; x < width; x++) {
float xTerm = static_cast<float>(x - xRadius);
xTerm = xTerm * xTerm * sigmaXDenom;
for (int y = 0; y < height; y++) {
float yTerm = static_cast<float>(y - yRadius);
float xyTerm = sk_float_exp(-(xTerm + yTerm * yTerm * sigmaYDenom));
// Note that the constant term (1/(sqrt(2*pi*sigma^2)) of the Gaussian
// is dropped here, since we renormalize the kernel below.
kernel[y * width + x] = xyTerm;
sum += xyTerm;
}
}
// Normalize the kernel
float scale = 1.0f / sum;
for (int i = 0; i < width * height; ++i) {
kernel[i] *= scale;
}
return new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
kernelOffset, tileMode, convolveAlpha);
}
示例10: INHERITED
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
const SkIRect& bounds,
const SkISize& kernelSize,
const SkScalar* kernel,
SkScalar gain,
SkScalar bias,
const SkIPoint& kernelOffset,
GrTextureDomain::Mode tileMode,
bool convolveAlpha)
: INHERITED(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture)),
fKernelSize(kernelSize),
fGain(SkScalarToFloat(gain)),
fBias(SkScalarToFloat(bias) / 255.0f),
fConvolveAlpha(convolveAlpha),
fDomain(GrTextureDomain::MakeTexelDomainForMode(texture, bounds, tileMode), tileMode) {
this->initClassID<GrMatrixConvolutionEffect>();
for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) {
fKernel[i] = SkScalarToFloat(kernel[i]);
}
fKernelOffset[0] = static_cast<float>(kernelOffset.x());
fKernelOffset[1] = static_cast<float>(kernelOffset.y());
}
示例11: onGetName
virtual const char* onGetName() {
fName.printf("text_%g", SkScalarToFloat(fPaint.getTextSize()));
if (fDoPos) {
fName.append("_pos");
}
fName.appendf("_%s", fontQualityName(fPaint));
if (SK_ColorBLACK != fPaint.getColor()) {
fName.appendf("_%02X", fPaint.getAlpha());
} else {
fName.append("_BK");
}
return fName.c_str();
}
示例12: SkDebugf
void SkSet::dump(SkAnimateMaker* maker) {
INHERITED::dump(maker);
if (dur != 1) {
#ifdef SK_CAN_USE_FLOAT
SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
#else
SkDebugf("dur=\"%x\" ", SkScalarDiv(dur,1000));
#endif
}
//don't want double />\n's
SkDebugf("/>\n");
}
示例13: SkScalarToFloat
void STDMETHODCALLTYPE SkDWriteGeometrySink::AddBeziers(const D2D1_BEZIER_SEGMENT *beziers, UINT beziersCount) {
SkPoint lastPt;
fPath->getLastPt(&lastPt);
D2D1_POINT_2F prevPt = { SkScalarToFloat(lastPt.fX), SkScalarToFloat(lastPt.fY) };
for (const D2D1_BEZIER_SEGMENT *end = &beziers[beziersCount]; beziers < end; ++beziers) {
Cubic cubic = { { prevPt.x, prevPt.y },
{ beziers->point1.x, beziers->point1.y },
{ beziers->point2.x, beziers->point2.y },
{ beziers->point3.x, beziers->point3.y }, };
Quadratic quadratic;
if (check_quadratic(cubic, quadratic)) {
fPath->quadTo(quadratic[1].x, quadratic[1].y,
quadratic[2].x, quadratic[2].y);
} else {
fPath->cubicTo(beziers->point1.x, beziers->point1.y,
beziers->point2.x, beziers->point2.y,
beziers->point3.x, beziers->point3.y);
}
prevPt = beziers->point3;
}
}
示例14: switch
void SkDumpCanvas::didConcat(const SkMatrix& matrix) {
SkString str;
switch (matrix.getType()) {
case SkMatrix::kTranslate_Mask:
this->dump(kMatrix_Verb, nullptr, "translate(%g %g)",
SkScalarToFloat(matrix.getTranslateX()),
SkScalarToFloat(matrix.getTranslateY()));
break;
case SkMatrix::kScale_Mask:
this->dump(kMatrix_Verb, nullptr, "scale(%g %g)",
SkScalarToFloat(matrix.getScaleX()),
SkScalarToFloat(matrix.getScaleY()));
break;
default:
matrix.toString(&str);
this->dump(kMatrix_Verb, nullptr, "concat(%s)", str.c_str());
break;
}
this->INHERITED::didConcat(matrix);
}
示例15: GrScalarToFloat
void GrGpuGLShaders::flushTextureDomain(int s) {
const GrGLint& uni = fProgramData->fUniLocations.fStages[s].fTexDomUni;
if (GrGLProgram::kUnusedUniform != uni) {
const GrRect &texDom =
fCurrDrawState.fSamplerStates[s].getTextureDomain();
if (((1 << s) & fDirtyFlags.fTextureChangedMask) ||
fProgramData->fTextureDomain[s] != texDom) {
fProgramData->fTextureDomain[s] = texDom;
float values[4] = {
GrScalarToFloat(texDom.left()),
GrScalarToFloat(texDom.top()),
GrScalarToFloat(texDom.right()),
GrScalarToFloat(texDom.bottom())
};
GrGLTexture* texture = (GrGLTexture*) fCurrDrawState.fTextures[s];
GrGLTexture::Orientation orientation = texture->orientation();
// vertical flip if necessary
if (GrGLTexture::kBottomUp_Orientation == orientation) {
values[1] = 1.0f - values[1];
values[3] = 1.0f - values[3];
// The top and bottom were just flipped, so correct the ordering
// of elements so that values = (l, t, r, b).
SkTSwap(values[1], values[3]);
}
values[0] *= SkScalarToFloat(texture->contentScaleX());
values[2] *= SkScalarToFloat(texture->contentScaleX());
values[1] *= SkScalarToFloat(texture->contentScaleY());
values[3] *= SkScalarToFloat(texture->contentScaleY());
GL_CALL(Uniform4fv(uni, 1, values));
}
}
}