本文整理汇总了C++中sk_bzero函数的典型用法代码示例。如果您正苦于以下问题:C++ sk_bzero函数的具体用法?C++ sk_bzero怎么用?C++ sk_bzero使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sk_bzero函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sk_bzero
bool GrSWMaskHelper::init(const GrIRect& pathDevBounds, const GrPoint* translate) {
fMatrix = fContext->getMatrix();
if (NULL != translate) {
fMatrix.postTranslate(translate->fX, translate->fY);
}
fMatrix.postTranslate(-pathDevBounds.fLeft * SK_Scalar1,
-pathDevBounds.fTop * SK_Scalar1);
GrIRect bounds = GrIRect::MakeWH(pathDevBounds.width(),
pathDevBounds.height());
fBM.setConfig(SkBitmap::kA8_Config, bounds.fRight, bounds.fBottom);
if (!fBM.allocPixels()) {
return false;
}
sk_bzero(fBM.getPixels(), fBM.getSafeSize());
sk_bzero(&fDraw, sizeof(fDraw));
fRasterClip.setRect(bounds);
fDraw.fRC = &fRasterClip;
fDraw.fClip = &fRasterClip.bwRgn();
fDraw.fMatrix = &fMatrix;
fDraw.fBitmap = &fBM;
return true;
}
示例2: sk_bzero
bool GrSWMaskHelper::init(const SkIRect& resultBounds,
const SkMatrix* matrix) {
if (NULL != matrix) {
fMatrix = *matrix;
} else {
fMatrix.setIdentity();
}
// Now translate so the bound's UL corner is at the origin
fMatrix.postTranslate(-resultBounds.fLeft * SK_Scalar1,
-resultBounds.fTop * SK_Scalar1);
SkIRect bounds = SkIRect::MakeWH(resultBounds.width(),
resultBounds.height());
if (!fBM.allocPixels(SkImageInfo::MakeA8(bounds.fRight, bounds.fBottom))) {
return false;
}
sk_bzero(fBM.getPixels(), fBM.getSafeSize());
sk_bzero(&fDraw, sizeof(fDraw));
fRasterClip.setRect(bounds);
fDraw.fRC = &fRasterClip;
fDraw.fClip = &fRasterClip.bwRgn();
fDraw.fMatrix = &fMatrix;
fDraw.fBitmap = &fBM;
return true;
}
示例3: init
void init(int dirNo) {
fResult.init(dirNo);
fFoundCount = 0;
fSmallestError = 0;
sk_bzero(fFilesFound, sizeof(fFilesFound));
sk_bzero(fDirsFound, sizeof(fDirsFound));
sk_bzero(fError, sizeof(fError));
}
示例4: generateFontMetrics
virtual void generateFontMetrics(SkPaint::FontMetrics* mx,
SkPaint::FontMetrics* my) {
if (mx) {
sk_bzero(mx, sizeof(*mx));
}
if (my) {
sk_bzero(my, sizeof(*my));
}
}
示例5: init
void init(int dirNo, skiatest::Reporter* reporter) {
fReporter = reporter;
fResult.init(dirNo);
fFoundCount = 0;
TestState::fSmallCount = 0;
fSmallestError = 0;
sk_bzero(fFilesFound, sizeof(fFilesFound));
sk_bzero(fDirsFound, sizeof(fDirsFound));
sk_bzero(fError, sizeof(fError));
}
示例6: INHERITED
SkTestFont::SkTestFont(const SkTestFontData& fontData)
: INHERITED()
, fCharCodes(fontData.fCharCodes)
, fCharCodesCount(fontData.fCharCodes ? fontData.fCharCodesCount : 0)
, fWidths(fontData.fWidths)
, fMetrics(fontData.fMetrics)
, fName(fontData.fName)
, fPaths(nullptr)
{
init(fontData.fPoints, fontData.fVerbs);
#ifdef SK_DEBUG
sk_bzero(fDebugBits, sizeof(fDebugBits));
sk_bzero(fDebugOverage, sizeof(fDebugOverage));
#endif
}
示例7: testLineIntersect
static void testLineIntersect(skiatest::Reporter* reporter, const SkDQuad& quad,
const SkDLine& line, const double x, const double y) {
char pathStr[1024];
sk_bzero(pathStr, sizeof(pathStr));
char* str = pathStr;
str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", quad[0].fX, quad[0].fY);
str += sprintf(str, " path.quadTo(%1.9g, %1.9g, %1.9g, %1.9g);\n", quad[1].fX,
quad[1].fY, quad[2].fX, quad[2].fY);
str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", line[0].fX, line[0].fY);
str += sprintf(str, " path.lineTo(%1.9g, %1.9g);\n", line[1].fX, line[1].fY);
SkIntersections intersections;
bool flipped = false;
int result = doIntersect(intersections, quad, line, flipped);
bool found = false;
for (int index = 0; index < result; ++index) {
double quadT = intersections[0][index];
SkDPoint quadXY = quad.ptAtT(quadT);
double lineT = intersections[1][index];
SkDPoint lineXY = line.ptAtT(lineT);
if (quadXY.approximatelyEqual(lineXY)) {
found = true;
}
}
REPORTER_ASSERT(reporter, found);
}
示例8: sizeof
sk_sp<GrTextBlob> GrTextBlob::Make(int glyphCount, int runCount) {
// We allocate size for the GrTextBlob itself, plus size for the vertices array,
// and size for the glyphIds array.
size_t verticesCount = glyphCount * kVerticesPerGlyph * kMaxVASize;
size_t blob = 0;
size_t vertex = sk_align<alignof(char)> (blob + sizeof(GrTextBlob) * 1);
size_t glyphs = sk_align<alignof(GrGlyph*)> (vertex + sizeof(char) * verticesCount);
size_t runs = sk_align<alignof(GrTextBlob::Run)>(glyphs + sizeof(GrGlyph*) * glyphCount);
size_t size = (runs + sizeof(GrTextBlob::Run) * runCount);
void* allocation = ::operator new (size);
if (CACHE_SANITY_CHECK) {
sk_bzero(allocation, size);
}
sk_sp<GrTextBlob> cacheBlob(new (allocation) GrTextBlob);
cacheBlob->fSize = size;
// setup offsets for vertices / glyphs
cacheBlob->fVertices = SkTAddOffset<char>(cacheBlob.get(), vertex);
cacheBlob->fGlyphs = SkTAddOffset<GrGlyph*>(cacheBlob.get(), glyphs);
cacheBlob->fRuns = SkTAddOffset<GrTextBlob::Run>(cacheBlob.get(), runs);
// Initialize runs
for (int i = 0; i < runCount; i++) {
new (&cacheBlob->fRuns[i]) GrTextBlob::Run;
}
cacheBlob->fRunCount = runCount;
return cacheBlob;
}
示例9: sk_bzero
void SkTypefacePlayback::setCount(int count) {
this->reset(nullptr);
fCount = count;
fArray = new SkRefCnt* [count];
sk_bzero(fArray, count * sizeof(SkRefCnt*));
}
示例10: if
/*
* Return a valid set of output dimensions for this decoder, given an input scale
*/
SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const {
// libjpeg supports scaling by 1/1, 1/2, 1/4, and 1/8, so we will support these as well
long scale;
if (desiredScale > 0.75f) {
scale = 1;
} else if (desiredScale > 0.375f) {
scale = 2;
} else if (desiredScale > 0.1875f) {
scale = 4;
} else {
scale = 8;
}
// Set up a fake decompress struct in order to use libjpeg to calculate output dimensions
jpeg_decompress_struct dinfo;
sk_bzero(&dinfo, sizeof(dinfo));
dinfo.image_width = this->getInfo().width();
dinfo.image_height = this->getInfo().height();
dinfo.global_state = DSTATE_READY;
dinfo.num_components = 0;
dinfo.scale_num = 1;
dinfo.scale_denom = scale;
jpeg_calc_output_dimensions(&dinfo);
// Return the calculated output dimensions for the given scale
return SkISize::Make(dinfo.output_width, dinfo.output_height);
}
示例11: test_font
static void test_font(skiatest::Reporter* reporter) {
uint32_t flags = 0;
SkAutoTUnref<SkFont> font(SkFont::Create(nullptr, 24, SkFont::kA8_MaskType, flags));
REPORTER_ASSERT(reporter, font->getTypeface());
REPORTER_ASSERT(reporter, 24 == font->getSize());
REPORTER_ASSERT(reporter, 1 == font->getScaleX());
REPORTER_ASSERT(reporter, 0 == font->getSkewX());
REPORTER_ASSERT(reporter, SkFont::kA8_MaskType == font->getMaskType());
uint16_t glyphs[5];
sk_bzero(glyphs, sizeof(glyphs));
int count = font->textToGlyphs("Hello", 5, kUTF8_SkTextEncoding, glyphs, SK_ARRAY_COUNT(glyphs));
REPORTER_ASSERT(reporter, 5 == count);
for (int i = 0; i < count; ++i) {
REPORTER_ASSERT(reporter, 0 != glyphs[i]);
}
REPORTER_ASSERT(reporter, glyphs[0] != glyphs[1]); // 'h' != 'e'
REPORTER_ASSERT(reporter, glyphs[2] == glyphs[3]); // 'l' == 'l'
SkAutoTUnref<SkFont> newFont(font->cloneWithSize(36));
REPORTER_ASSERT(reporter, newFont.get());
REPORTER_ASSERT(reporter, font->getTypeface() == newFont->getTypeface());
REPORTER_ASSERT(reporter, 36 == newFont->getSize()); // double check we haven't changed
REPORTER_ASSERT(reporter, 24 == font->getSize()); // double check we haven't changed
SkPaint paint;
paint.setTextSize(18);
font.reset(SkFont::Testing_CreateFromPaint(paint));
REPORTER_ASSERT(reporter, font.get());
REPORTER_ASSERT(reporter, font->getSize() == paint.getTextSize());
REPORTER_ASSERT(reporter, SkFont::kBW_MaskType == font->getMaskType());
}
示例12: testSimplifyQuadralateralsMain
static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
{
SkASSERT(data);
PathOpsThreadState& state = *data;
char pathStr[1024];
sk_bzero(pathStr, sizeof(pathStr));
int ax = state.fA & 0x03;
int ay = state.fA >> 2;
int bx = state.fB & 0x03;
int by = state.fB >> 2;
int cx = state.fC & 0x03;
int cy = state.fC >> 2;
int dx = state.fD & 0x03;
int dy = state.fD >> 2;
for (int e = 0 ; e < 16; ++e) {
int ex = e & 0x03;
int ey = e >> 2;
for (int f = e ; f < 16; ++f) {
int fx = f & 0x03;
int fy = f >> 2;
for (int g = f ; g < 16; ++g) {
int gx = g & 0x03;
int gy = g >> 2;
for (int h = g ; h < 16; ++h) {
int hx = h & 0x03;
int hy = h >> 2;
SkPath path, out;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
path.close();
path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
path.close();
// gdb: set print elements 400
char* str = pathStr;
str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by);
str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy);
str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy);
str += sprintf(str, " path.close();\n");
str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey);
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
str += sprintf(str, " path.lineTo(%d, %d);\n", gx, gy);
str += sprintf(str, " path.lineTo(%d, %d);\n", hx, hy);
str += sprintf(str, " path.close();\n");
outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
testSimplify(path, false, out, state, pathStr);
path.setFillType(SkPath::kEvenOdd_FillType);
outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
testSimplify(path, true, out, state, pathStr);
}
}
}
}
}
示例13: onCharsToGlyphs
virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
uint16_t glyphs[], int glyphCount) const override {
if (glyphs && glyphCount > 0) {
sk_bzero(glyphs, glyphCount * sizeof(glyphs[0]));
}
return 0;
}
示例14: copyToMask
static void copyToMask(const SkRegion& rgn, SkMask* mask) {
mask->fFormat = SkMask::kA8_Format;
if (rgn.isEmpty()) {
mask->fBounds.setEmpty();
mask->fRowBytes = 0;
mask->fImage = nullptr;
return;
}
mask->fBounds = rgn.getBounds();
mask->fRowBytes = mask->fBounds.width();
mask->fImage = SkMask::AllocImage(mask->computeImageSize());
sk_bzero(mask->fImage, mask->computeImageSize());
SkImageInfo info = SkImageInfo::Make(mask->fBounds.width(),
mask->fBounds.height(),
kAlpha_8_SkColorType,
kPremul_SkAlphaType);
SkBitmap bitmap;
bitmap.installPixels(info, mask->fImage, mask->fRowBytes);
// canvas expects its coordinate system to always be 0,0 in the top/left
// so we translate the rgn to match that before drawing into the mask.
//
SkRegion tmpRgn(rgn);
tmpRgn.translate(-rgn.getBounds().fLeft, -rgn.getBounds().fTop);
SkCanvas canvas(bitmap);
canvas.clipRegion(tmpRgn);
canvas.drawColor(SK_ColorBLACK);
}
示例15: Create
// We use this static factory function instead of the regular constructor so
// that we can create the pixel data before calling the constructor. This is
// required so that we can call the base class' constructor with the pixel
// data.
static bool Create(int width, int height, bool is_opaque, SkRasterHandleAllocator::Rec* rec) {
BITMAPINFOHEADER hdr = { 0 };
hdr.biSize = sizeof(BITMAPINFOHEADER);
hdr.biWidth = width;
hdr.biHeight = -height; // Minus means top-down bitmap.
hdr.biPlanes = 1;
hdr.biBitCount = 32;
hdr.biCompression = BI_RGB; // No compression.
hdr.biSizeImage = 0;
hdr.biXPelsPerMeter = 1;
hdr.biYPelsPerMeter = 1;
void* pixels;
HBITMAP hbitmap = CreateDIBSection(nullptr, (const BITMAPINFO*)&hdr, 0, &pixels, 0, 0);
if (!hbitmap) {
return false;
}
size_t row_bytes = width * sizeof(SkPMColor);
sk_bzero(pixels, row_bytes * height);
HDC hdc = CreateCompatibleDC(nullptr);
if (!hdc) {
DeleteObject(hbitmap);
return false;
}
SetGraphicsMode(hdc, GM_ADVANCED);
SelectObject(hdc, hbitmap);
rec->fReleaseProc = DeleteHDCCallback;
rec->fReleaseCtx = hdc;
rec->fPixels = pixels;
rec->fRowBytes = row_bytes;
rec->fHandle = hdc;
return true;
}