本文整理汇总了C++中SkSurface::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SkSurface::unref方法的具体用法?C++ SkSurface::unref怎么用?C++ SkSurface::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkSurface
的用法示例。
在下文中一共展示了SkSurface::unref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
_DC::CreateMemoryBitmapDC(int nBPP, UINT width, UINT height){
if (context_ != NULL)
return false;
BITMAP bmp;
_Image img;
//if (!img.CreateDIBBitmap(24, RGB(0, 0, 0), width, height, &bmp))
if (!img.CreateDIBBitmap(32, RGB(0, 0, 0), width, height, &bmp))
return false;
SkImageInfo imageInfo;
imageInfo.fAlphaType = SkAlphaType::kOpaque_SkAlphaType;
imageInfo.fColorType = SkColorType::kN32_SkColorType;
imageInfo.fHeight = height;
imageInfo.fWidth = width;
SkSurface* rasterSurface = SkSurface::NewRasterDirect(imageInfo, bmp.bmBits, bmp.bmWidthBytes);
SkCanvas* rasterCanvas = rasterSurface->getCanvas();
if (rasterCanvas && rasterCanvas) {
_surface = rasterSurface;
_canvas = rasterCanvas;
}
else
rasterSurface->unref();
image_ = img.Detach();
context_ = ::CreateCompatibleDC(NULL);
::SelectObject(context_, image_);
return true;
}
示例2: test_big_aa_rect
// test that we can draw an aa-rect at coordinates > 32K (bigger than fixedpoint)
static void test_big_aa_rect(skiatest::Reporter* reporter) {
SkBitmap output;
SkPMColor pixel[1];
output.installPixels(SkImageInfo::MakeN32Premul(1, 1), pixel, 4);
SkSurface* surf = SkSurface::NewRasterN32Premul(300, 33300);
SkCanvas* canvas = surf->getCanvas();
SkRect r = { 0, 33000, 300, 33300 };
int x = SkScalarRoundToInt(r.left());
int y = SkScalarRoundToInt(r.top());
// check that the pixel in question starts as transparent (by the surface)
if (canvas->readPixels(&output, x, y)) {
REPORTER_ASSERT(reporter, 0 == pixel[0]);
} else {
REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed");
}
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorWHITE);
canvas->drawRect(r, paint);
// Now check that it is BLACK
if (canvas->readPixels(&output, x, y)) {
// don't know what swizzling PMColor did, but white should always
// appear the same.
REPORTER_ASSERT(reporter, 0xFFFFFFFF == pixel[0]);
} else {
REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed");
}
surf->unref();
}