sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, const GrBackendRenderTarget& backendRT, GrSurfaceOrigin origin, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) { if (!context) { return nullptr; } if (!SkSurface_Gpu::Valid(context, backendRT.config(), colorSpace.get())) { return nullptr; } sk_sp<GrRenderTargetContext> rtc( context->contextPriv().makeBackendRenderTargetRenderTargetContext(backendRT, origin, std::move(colorSpace), props)); if (!rtc) { return nullptr; } sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), backendRT.width(), backendRT.height(), SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; } return sk_make_sp<SkSurface_Gpu>(std::move(device)); }
sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) { if (0 == this->caps()->getRenderTargetSampleCount(backendRT.sampleCnt(), backendRT.config())) { return nullptr; } this->handleDirtyContext(); return this->onWrapBackendRenderTarget(backendRT); }
sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, const GrBackendRenderTarget& rt, GrSurfaceOrigin origin, SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) { if (!context) { return nullptr; } GrBackendRenderTarget rtCopy = rt; if (!validate_backend_render_target(context, rtCopy, &rtCopy.fConfig, colorType, colorSpace)) { return nullptr; } if (!SkSurface_Gpu::Valid(context, rtCopy.config(), colorSpace.get())) { return nullptr; } if (!context) { return nullptr; } sk_sp<GrRenderTargetContext> rtc( context->contextPriv().makeBackendRenderTargetRenderTargetContext( rtCopy, origin, std::move(colorSpace), props)); if (!rtc) { return nullptr; } sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), rtCopy.width(), rtCopy.height(), SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; } return sk_make_sp<SkSurface_Gpu>(std::move(device)); }