本文整理汇总了C++中SkMax32函数的典型用法代码示例。如果您正苦于以下问题:C++ SkMax32函数的具体用法?C++ SkMax32怎么用?C++ SkMax32使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkMax32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: approx_arc_length
SkISize SkPatchUtils::GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix) {
// Approximate length of each cubic.
SkPoint pts[kNumPtsCubic];
SkPatchUtils::getTopCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar topLength = approx_arc_length(pts, kNumPtsCubic);
SkPatchUtils::getBottomCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar bottomLength = approx_arc_length(pts, kNumPtsCubic);
SkPatchUtils::getLeftCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar leftLength = approx_arc_length(pts, kNumPtsCubic);
SkPatchUtils::getRightCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar rightLength = approx_arc_length(pts, kNumPtsCubic);
// Level of detail per axis, based on the larger side between top and bottom or left and right
int lodX = static_cast<int>(SkMaxScalar(topLength, bottomLength) / kPartitionSize);
int lodY = static_cast<int>(SkMaxScalar(leftLength, rightLength) / kPartitionSize);
return SkISize::Make(SkMax32(8, lodX), SkMax32(8, lodY));
}
示例2: toString
static void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc,
SkString* str) {
// FIXME: this code appears to be untested - and probably unused - and probably wrong
switch (enc) {
case SkPaint::kUTF8_TextEncoding:
str->appendf("\"%.*s\"%s", SkMax32(byteLen, 32), (const char*) text,
byteLen > 32 ? "..." : "");
break;
case SkPaint::kUTF16_TextEncoding:
str->appendf("\"%.*ls\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
byteLen > 64 ? "..." : "");
break;
case SkPaint::kUTF32_TextEncoding:
str->appendf("\"%.*ls\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
byteLen > 128 ? "..." : "");
break;
case SkPaint::kGlyphID_TextEncoding:
str->append("<glyphs>");
break;
default:
SkASSERT(false);
break;
}
}
示例3: color_dist16
static unsigned color_dist16(uint16_t a, uint16_t b) {
unsigned dr = SkAbs32(SkPacked16ToR32(a) - SkPacked16ToR32(b));
unsigned dg = SkAbs32(SkPacked16ToG32(a) - SkPacked16ToG32(b));
unsigned db = SkAbs32(SkPacked16ToB32(a) - SkPacked16ToB32(b));
return SkMax32(dr, SkMax32(dg, db));
}
示例4: lighten_modeproc16_255
static uint16_t lighten_modeproc16_255(SkPMColor src, uint16_t dst) {
SkASSERT(require_255(src));
unsigned r = SkMax32(SkPacked32ToR16(src), SkGetPackedR16(dst));
unsigned g = SkMax32(SkPacked32ToG16(src), SkGetPackedG16(dst));
unsigned b = SkMax32(SkPacked32ToB16(src), SkGetPackedB16(dst));
return SkPackRGB16(r, g, b);
}
示例5: SkASSERT
void SkTileGrid::insert(void* data, const SkRect& fbounds, bool) {
SkASSERT(!fbounds.isEmpty());
SkIRect dilatedBounds;
if (fbounds.isLargest()) {
// Dilating the largest SkIRect will overflow. Other nearly-largest rects may overflow too,
// but we don't make active use of them like we do the largest.
dilatedBounds.setLargest();
} else {
fbounds.roundOut(&dilatedBounds);
dilatedBounds.outset(fInfo.fMargin.width(), fInfo.fMargin.height());
dilatedBounds.offset(fInfo.fOffset);
}
const SkIRect gridBounds =
{ 0, 0, fInfo.fTileInterval.width() * fXTiles, fInfo.fTileInterval.height() * fYTiles };
if (!SkIRect::Intersects(dilatedBounds, gridBounds)) {
return;
}
// Note: SkIRects are non-inclusive of the right() column and bottom() row,
// hence the "-1"s in the computations of maxX and maxY.
int minX = SkMax32(0, SkMin32(dilatedBounds.left() / fInfo.fTileInterval.width(), fXTiles - 1));
int minY = SkMax32(0, SkMin32(dilatedBounds.top() / fInfo.fTileInterval.height(), fYTiles - 1));
int maxX = SkMax32(0, SkMin32((dilatedBounds.right() - 1) / fInfo.fTileInterval.width(),
fXTiles - 1));
int maxY = SkMax32(0, SkMin32((dilatedBounds.bottom() - 1) / fInfo.fTileInterval.height(),
fYTiles - 1));
Entry entry = { fCount++, data };
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; x++) {
fTiles[y * fXTiles + x].push(entry);
}
}
}
示例6: SkFindUnitQuadRoots
/** Trim A/B/C down so that they are all <= 32bits
and then call SkFindUnitQuadRoots()
*/
static int Sk64FindFixedQuadRoots(const Sk64& A, const Sk64& B, const Sk64& C, SkFixed roots[2])
{
int na = A.shiftToMake32();
int nb = B.shiftToMake32();
int nc = C.shiftToMake32();
int shift = SkMax32(na, SkMax32(nb, nc));
SkASSERT(shift >= 0);
return SkFindUnitQuadRoots(A.getShiftRight(shift), B.getShiftRight(shift), C.getShiftRight(shift), roots);
}
示例7: color_dist32
// returns 0..255
static unsigned color_dist32(SkPMColor c, U8CPU r, U8CPU g, U8CPU b) {
SkASSERT(r <= 0xFF);
SkASSERT(g <= 0xFF);
SkASSERT(b <= 0xFF);
unsigned dr = SkAbs32(SkGetPackedR32(c) - r);
unsigned dg = SkAbs32(SkGetPackedG32(c) - g);
unsigned db = SkAbs32(SkGetPackedB32(c) - b);
return SkMax32(dr, SkMax32(dg, db));
}
示例8: color_dist16
// returns 0..31
static unsigned color_dist16(uint16_t c, unsigned r, unsigned g, unsigned b) {
SkASSERT(r <= SK_R16_MASK);
SkASSERT(g <= SK_G16_MASK);
SkASSERT(b <= SK_B16_MASK);
unsigned dr = SkAbs32(SkGetPackedR16(c) - r);
unsigned dg = SkAbs32(SkGetPackedG16(c) - g) >> (SK_G16_BITS - SK_R16_BITS);
unsigned db = SkAbs32(SkGetPackedB16(c) - b);
return SkMax32(dr, SkMax32(dg, db));
}
示例9: color_dist4444
// returns 0..15
static unsigned color_dist4444(uint16_t c, unsigned r, unsigned g, unsigned b)
{
SkASSERT(r <= 0xF);
SkASSERT(g <= 0xF);
SkASSERT(b <= 0xF);
unsigned dr = SkAbs32(SkGetPackedR4444(c) - r);
unsigned dg = SkAbs32(SkGetPackedG4444(c) - g);
unsigned db = SkAbs32(SkGetPackedB4444(c) - b);
return SkMax32(dr, SkMax32(dg, db));
}
示例10: SkMax32
void GraphicsContext::drawLineForText(const FloatPoint& pt,
float width,
bool printing)
{
if (paintingDisabled())
return;
if (width <= 0)
return;
int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
SkRect r;
r.fLeft = WebCoreFloatToSkScalar(pt.x());
// Avoid anti-aliasing lines. Currently, these are always horizontal.
r.fTop = WebCoreFloatToSkScalar(floorf(pt.y()));
r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
r.fBottom = r.fTop + SkIntToScalar(thickness);
SkPaint paint;
platformContext()->setupPaintForFilling(&paint);
// Text lines are drawn using the stroke color.
paint.setColor(platformContext()->effectiveStrokeColor());
platformContext()->canvas()->drawRect(r, paint);
platformContext()->didDrawRect(r, paint);
}
示例11: SkNextPow2
SkGLTextCache::Strike::Strike(Strike* next, int width, int height) {
fStrikeWidth = SkNextPow2(SkMax32(kMinStrikeWidth, width));
fStrikeHeight = SkNextPow2(height);
fGlyphCount = 0;
fNextFreeOffsetX = 0;
fNext = next;
fStrikeWidthShift = SkNextLog2(fStrikeWidth);
fStrikeHeightShift = SkNextLog2(fStrikeHeight);
if (next) {
SkASSERT(next->fStrikeHeight == fStrikeHeight);
}
// create an empty texture to receive glyphs
fTexName = 0;
glGenTextures(1, &fTexName);
glBindTexture(GL_TEXTURE_2D, fTexName);
glTexImage2D(GL_TEXTURE_2D, 0, gTextTextureFormat,
fStrikeWidth, fStrikeHeight, 0,
gTextTextureFormat, gTextTextureType, NULL);
SK_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
SK_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
SK_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
SK_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
示例12: SkMax32
void SkProgressView::onDraw(SkCanvas* canvas)
{
if (fMax == 0)
return;
SkFixed percent;
if (fInterp)
{
SkScalar x;
if (fInterp->timeToValues(SkTime::GetMSecs(), &x) == SkInterpolator::kFreezeEnd_Result)
{
delete fInterp;
fInterp = NULL;
}
percent = (SkFixed)x; // now its 16.8
percent = SkMax32(0, SkMin32(percent, fMax << 8)); // now its pinned
percent = SkFixedDiv(percent, fMax << 8); // now its 0.16
this->inval(NULL);
}
else
{
U16CPU value = SkMax32(0, SkMin32(fValue, fMax));
percent = SkFixedDiv(value, fMax);
}
SkRect r;
SkPaint p;
r.set(0, 0, this->width(), this->height());
p.setAntiAlias(true);
r.fRight = r.fLeft + SkScalarMul(r.width(), SkFixedToScalar(percent));
p.setStyle(SkPaint::kFill_Style);
p.setColor(SK_ColorDKGRAY);
p.setShader(fOnShader);
canvas->drawRect(r, p);
p.setColor(SK_ColorWHITE);
p.setShader(fOffShader);
r.fLeft = r.fRight;
r.fRight = this->width() - SK_Scalar1;
if (r.width() > 0)
canvas->drawRect(r, p);
}
示例13: pack3xHToLCD32
static void pack3xHToLCD32(const SkBitmap& src, const SkMask& dst) {
SkASSERT(SkBitmap::kA8_Config == src.config());
SkASSERT(SkMask::kLCD32_Format == dst.fFormat);
const int width = dst.fBounds.width();
const int height = dst.fBounds.height();
SkPMColor* dstP = (SkPMColor*)dst.fImage;
size_t dstRB = dst.fRowBytes;
for (int y = 0; y < height; ++y) {
const uint8_t* srcP = src.getAddr8(0, y);
for (int x = 0; x < width; ++x) {
unsigned r = *srcP++;
unsigned g = *srcP++;
unsigned b = *srcP++;
unsigned a = SkMax32(SkMax32(r, g), b);
dstP[x] = SkPackARGB32(a, r, g, b);
}
dstP = (SkPMColor*)((char*)dstP + dstRB);
}
}
示例14: previousBloc
void* ThreadSafePipeController::requestBlock(size_t minRequest, size_t *actual) {
if (fBlock) {
// Save the previous block for later
PipeBlock previousBloc(fBlock, fBytesWritten);
fBlockList.push(previousBloc);
}
int32_t blockSize = SkMax32(SkToS32(minRequest), kMinBlockSize);
fBlock = fAllocator.allocThrow(blockSize);
fBytesWritten = 0;
*actual = blockSize;
return fBlock;
}
示例15: SkRGBToHSV
void SkRGBToHSV(U8CPU r, U8CPU g, U8CPU b, SkScalar hsv[3]) {
SkASSERT(hsv);
unsigned min = SkMin32(r, SkMin32(g, b));
unsigned max = SkMax32(r, SkMax32(g, b));
unsigned delta = max - min;
SkScalar v = ByteToScalar(max);
SkASSERT(v >= 0 && v <= SK_Scalar1);
if (0 == delta) { // we're a shade of gray
hsv[0] = 0;
hsv[1] = 0;
hsv[2] = v;
return;
}
SkScalar s = ByteDivToScalar(delta, max);
SkASSERT(s >= 0 && s <= SK_Scalar1);
SkScalar h;
if (r == max) {
h = ByteDivToScalar(g - b, delta);
} else if (g == max) {
h = SkIntToScalar(2) + ByteDivToScalar(b - r, delta);
} else { // b == max
h = SkIntToScalar(4) + ByteDivToScalar(r - g, delta);
}
h *= 60;
if (h < 0) {
h += SkIntToScalar(360);
}
SkASSERT(h >= 0 && h < SkIntToScalar(360));
hsv[0] = h;
hsv[1] = s;
hsv[2] = v;
}