当前位置: 首页>>代码示例>>C++>>正文


C++ SkSurface::unref方法代码示例

本文整理汇总了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;
}
开发者ID:zqrtalent,项目名称:MercuryUI,代码行数:31,代码来源:PlatformDeviceContext_Skia.cpp

示例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();
}
开发者ID:Arternis,项目名称:skia,代码行数:36,代码来源:DrawPathTest.cpp


注:本文中的SkSurface::unref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。