Lines Matching defs:surface

204             ERRORF(reporter, "Could not make surface of color type %d.", colorType);
215 sk_sp<SkSurface>& surface,
220 surface->getCanvas()->clear(color);
223 bool success = surface->getCanvas()->peekPixels(&pmap);
227 const void* addr2 = surface->peekPixels(&pmap2) ? pmap2.addr() : nullptr;
244 auto surface(surface_func(kPremul_SkAlphaType, &requestInfo));
245 test_canvas_peek(reporter, surface, requestInfo, true);
251 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, &requestInfo));
252 test_canvas_peek(reporter, surface, requestInfo, false);
256 static void test_snapshot_alphatype(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface,
258 REPORTER_ASSERT(reporter, surface);
259 if (surface) {
260 sk_sp<SkImage> image(surface->makeImageSnapshot());
270 auto surface(surface_func(at, nullptr));
271 test_snapshot_alphatype(reporter, surface, at);
279 auto surface(surface_func(ctxInfo.directContext(), at, nullptr));
280 test_snapshot_alphatype(reporter, surface, at);
286 skiatest::Reporter* reporter, SkSurface* surface, SkSurface::BackendHandleAccess access) {
287 GrBackendTexture tex1 = surface->getBackendTexture(access);
288 sk_sp<SkImage> snap1(surface->makeImageSnapshot());
290 GrBackendTexture tex2 = surface->getBackendTexture(access);
291 sk_sp<SkImage> snap2(surface->makeImageSnapshot());
298 skiatest::Reporter* reporter, SkSurface* surface, SkSurface::BackendHandleAccess access) {
299 GrBackendRenderTarget rt1 = surface->getBackendRenderTarget(access);
300 sk_sp<SkImage> snap1(surface->makeImageSnapshot());
302 GrBackendRenderTarget rt2 = surface->getBackendRenderTarget(access);
303 sk_sp<SkImage> snap2(surface->makeImageSnapshot());
320 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
321 test_backend_texture_access_copy_on_write(reporter, surface.get(), accessMode);
324 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
325 test_backend_rendertarget_access_copy_on_write(reporter, surface.get(), accessMode);
332 static void test_backend_unique_id(skiatest::Reporter* reporter, SkSurface* surface) {
333 sk_sp<SkImage> image0(surface->makeImageSnapshot());
335 Type obj = (surface->*func)(SkSurface::kFlushRead_BackendHandleAccess);
337 sk_sp<SkImage> image1(surface->makeImageSnapshot());
341 obj = (surface->*func)(SkSurface::kFlushWrite_BackendHandleAccess);
343 sk_sp<SkImage> image2(surface->makeImageSnapshot());
347 obj = (surface->*func)(SkSurface::kDiscardWrite_BackendHandleAccess);
349 sk_sp<SkImage> image3(surface->makeImageSnapshot());
359 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
361 surface.get());
364 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
366 reporter, surface.get());
374 sk_sp<SkSurface> surface = create_gpu_surface(direct, kPremul_SkAlphaType, nullptr);
375 if (!surface) {
378 // This flush can put command buffer refs on the GrGpuResource for the surface.
379 surface->flush();
381 // We pass the test if we don't hit any asserts or crashes when the ref on the surface goes away
389 sk_sp<SkSurface> surface = create_gpu_surface(dContext, kPremul_SkAlphaType, nullptr);
390 if (!surface) {
395 surface->getBackendRenderTarget(SkSurface::kFlushRead_BackendHandleAccess);
398 surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess);
401 surface->flush();
405 beRT = surface->getBackendRenderTarget(SkSurface::kFlushRead_BackendHandleAccess);
407 beTex = surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess);
412 static void test_copy_on_write(skiatest::Reporter* reporter, SkSurface* surface) {
413 SkCanvas* canvas = surface->getCanvas();
448 sk_sp<SkImage> imageBefore = surface->makeImageSnapshot(); \
451 sk_sp<SkImage> imageAfter = surface->makeImageSnapshot(); \
473 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
474 test_copy_on_write(reporter, surface.get());
479 SkSurface* surface) {
481 // The test verifies that the surface remains writable (usable) after
483 SkCanvas* canvas = surface->getCanvas();
485 surface->makeImageSnapshot(); // Create and destroy SkImage
493 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
494 test_writable_after_snapshot_release(reporter, surface.get());
502 // Bug was caused by onCopyOnWrite releasing the old surface texture
546 auto surface(create_surface());
547 sk_sp<SkImage> image(surface->makeImageSnapshot());
549 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
554 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
555 sk_sp<SkImage> image(surface->makeImageSnapshot());
560 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
582 auto surface(SkSurface::MakeRenderTarget(dContext, budgeted, info));
583 SkASSERT(surface);
584 REPORTER_ASSERT(reporter, budgeted == is_budgeted(surface));
586 sk_sp<SkImage> image(surface->makeImageSnapshot());
588 // Initially the image shares a texture with the surface, and the
590 REPORTER_ASSERT(reporter, budgeted == is_budgeted(surface));
594 surface->getCanvas()->clear(SK_ColorBLUE);
597 REPORTER_ASSERT(reporter, budgeted == is_budgeted(surface));
603 SkSurface* surface,
606 surface->notifyContentWillChange(mode);
609 SkSurface* surface,
613 sk_sp<SkImage> image1 = surface->makeImageSnapshot();
615 surface->notifyContentWillChange(mode);
616 sk_sp<SkImage> image2 = surface->makeImageSnapshot();
635 auto surface(surface_func(ctxInfo.directContext(), kPremul_SkAlphaType, nullptr));
636 test_func(reporter, surface.get(), mode);
642 static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Reporter* reporter) {
644 REPORTER_ASSERT(reporter, surface->peekPixels(&surfacePM));
646 sk_sp<SkImage> image(surface->makeImageSnapshot());
653 surface->getCanvas()->drawPaint(SkPaint());
654 sk_sp<SkImage> image2(surface->makeImageSnapshot());
695 // triggers what appears to be a driver race condition where the 10x10 surface from the
696 // OverdrawSurface_gpu test is reused(?) for this surface created by the SurfacePartialDraw_gpu
699 // Immediately after creation of this surface, readback shows the correct initial solid color.
700 // However, sometime before content is rendered into the upper half of the surface, the driver
702 // top half of the surface is fine after the partially-covering rectangle is drawn, but the
729 static bool supports_readpixels(const GrCaps* caps, SkSurface* surface) {
730 auto surfaceGpu = static_cast<SkSurface_Gpu*>(surface);
791 // Snaps an image from a surface and then makes a SurfaceContext from the image's texture.
792 auto makeImageSurfaceContext = [dContext](SkSurface* surface) {
793 sk_sp<SkImage> i(surface->makeImageSnapshot());
802 auto surface = surface_func(dContext, kPremul_SkAlphaType, nullptr);
803 if (!surface) {
807 auto sfc = SkCanvasPriv::TopDeviceSurfaceFillContext(surface->getCanvas());
809 ERRORF(reporter, "Could access surface context of GPU SkSurface.");
813 auto imageSurfaceCtx = makeImageSurfaceContext(surface.get());
817 // Wrapped RTs are *not* supposed to clear (to allow client to partially update a surface).
821 auto surface = surfaceFunc(dContext, 1, kOrigColor);
822 if (!surface) {
826 auto sfc = SkCanvasPriv::TopDeviceSurfaceFillContext(surface->getCanvas());
828 ERRORF(reporter, "Could access surface context of GPU SkSurface.");
832 auto imageSurfaceCtx = makeImageSurfaceContext(surface.get());
839 skiatest::Reporter* reporter, sk_sp<SkSurface> surface, SkColor origColor) {
840 const int kW = surface->width();
841 const int kH = surface->height();
845 surface->getCanvas()->drawRect(SkRect::MakeIWH(kW, kH/2), paint);
854 REPORTER_ASSERT(reporter, surface->readPixels(readback.info(), readback.writable_addr(),
898 // preserved in pixels that aren't rendered to via the surface.
900 auto surface = surfaceFunc(context, 1, kOrigColor);
901 if (surface && supports_readpixels(context->priv().caps(), surface.get())) {
902 test_surface_draw_partially(reporter, surface, kOrigColor.toSkColor());
926 sk_sp<SkSurface> surface;
940 surface = SkSurface::MakeFromBackendTexture(
947 /*surface props*/ nullptr,
956 surface = SkSurface::MakeFromBackendRenderTarget(ctx, backendRT, texOrigin,
962 if (!surface) {
963 ERRORF(reporter, "Failed to create surface");
967 surface->getCanvas()->clear(SK_ColorRED);
968 surface->flush();
973 surface.reset(nullptr); // force a release of the surface
997 auto surface = surfaceFunc(context, sampleCnt, kOrigColor);
999 if (!surface && sampleCnt > 1) {
1005 // our surface functions.
1006 auto rtp = SkCanvasPriv::TopDeviceTargetProxy(surface->getCanvas());
1062 REPORTER_ASSERT(reporter, !bad, "Could not read surface.");
1079 ERRORF(reporter, "Could not create second surface.");
1083 REPORTER_ASSERT(reporter, !bad, "Could not read second surface.");
1114 static void test_overdraw_surface(skiatest::Reporter* r, SkSurface* surface) {
1115 SkOverdrawCanvas canvas(surface->getCanvas());
1117 sk_sp<SkImage> image = surface->makeImageSnapshot();
1129 sk_sp<SkSurface> surface = create_surface();
1130 test_overdraw_surface(r, surface.get());
1135 sk_sp<SkSurface> surface = create_gpu_surface(context);
1136 test_overdraw_surface(r, surface.get());
1151 // assert: if a given imageinfo is valid for a surface, then it must be valid for an image