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


C++ SkSurface类代码示例

本文整理汇总了C++中SkSurface的典型用法代码示例。如果您正苦于以下问题:C++ SkSurface类的具体用法?C++ SkSurface怎么用?C++ SkSurface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SkSurface类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例3: onPaint

void Window::onPaint() {
    SkSurface* backbuffer = fTestContext->getBackbufferSurface();
    if (backbuffer) {
        // draw into the canvas of this surface
        SkCanvas* canvas = backbuffer->getCanvas();

        fPaintFunc(canvas, fPaintUserData);

        canvas->flush();

        fTestContext->swapBuffers();
    } else {
        // try recreating testcontext
    }

}
开发者ID:BertiKarsunke,项目名称:skia,代码行数:16,代码来源:Window.cpp

示例4: make_surface

static SkSurface* make_surface(SkColorType colorType, const SkIPoint& size,
                               Benchmark::Backend backend, int sampleCount,
                               GrContext* context) {
    SkSurface* surface = NULL;
    SkImageInfo info = SkImageInfo::Make(size.fX, size.fY, colorType,
                                         kPremul_SkAlphaType);

    switch (backend) {
        case Benchmark::kRaster_Backend:
            surface = SkSurface::NewRaster(info);
            surface->getCanvas()->clear(SK_ColorWHITE);
            break;
#if SK_SUPPORT_GPU
        case Benchmark::kGPU_Backend: {
            surface = SkSurface::NewRenderTarget(context, info, sampleCount);
            break;
        }
#endif
        case Benchmark::kPDF_Backend:
        default:
            SkDEBUGFAIL("unsupported");
    }
    return surface;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:24,代码来源:benchmain.cpp

示例5: createSurface

static SkSurface* createSurface(SkColor color) {
    SkSurface* surface = SkSurface::NewRasterN32Premul(kWidth, kHeight);
    surface->getCanvas()->clear(color);
    return surface;
}
开发者ID:mariospr,项目名称:chromium-browser,代码行数:5,代码来源:CanvasTest.cpp

示例6: sk_surface_new_image_snapshot

sk_image_t* sk_surface_new_image_snapshot(sk_surface_t* csurf) {
    SkSurface* surf = (SkSurface*)csurf;
    return (sk_image_t*)surf->newImageSnapshot();
}
开发者ID:mariospr,项目名称:chromium-browser,代码行数:4,代码来源:sk_surface.cpp

示例7: sk_surface_get_canvas

sk_canvas_t* sk_surface_get_canvas(sk_surface_t* csurf) {
    SkSurface* surf = (SkSurface*)csurf;
    return (sk_canvas_t*)surf->getCanvas();
}
开发者ID:mariospr,项目名称:chromium-browser,代码行数:4,代码来源:sk_surface.cpp

示例8: sk_surface_new_image_snapshot

sk_image_t* sk_surface_new_image_snapshot(sk_surface_t* csurf) {
    SkSurface* surf = (SkSurface*)csurf;
    return (sk_image_t*)surf->makeImageSnapshot().release();
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:4,代码来源:sk_surface.cpp

示例9: createSurface

static SkSurface* createSurface(SkColor color) {
    SkSurface* surface = SkSurface::NewRasterPMColor(gWidth, gHeight);
    surface->getCanvas()->clear(color);
    return surface;
}
开发者ID:DXGL,项目名称:skia,代码行数:5,代码来源:DeferredCanvasTest.cpp


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