本文整理汇总了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;
}
示例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();
}
示例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
}
}
示例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;
}
示例5: createSurface
static SkSurface* createSurface(SkColor color) {
SkSurface* surface = SkSurface::NewRasterN32Premul(kWidth, kHeight);
surface->getCanvas()->clear(color);
return surface;
}
示例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();
}
示例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();
}
示例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();
}
示例9: createSurface
static SkSurface* createSurface(SkColor color) {
SkSurface* surface = SkSurface::NewRasterPMColor(gWidth, gHeight);
surface->getCanvas()->clear(color);
return surface;
}