diff options
-rw-r--r-- | dm/DMSrcSink.cpp | 2 | ||||
-rw-r--r-- | docs/SkSurface_Reference.bmh | 57 | ||||
-rw-r--r-- | include/core/SkSurface.h | 28 | ||||
-rw-r--r-- | src/image/SkSurface.cpp | 6 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 57 |
5 files changed, 26 insertions, 124 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 43992a8ff8..3c4ce65f9d 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -1869,7 +1869,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log, nullptr, info.width(), info.height(), info.colorType(), true, GrMipMapped::kNo); surface = SkSurface::MakeFromBackendTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin, fSampleCount, - info.refColorSpace(), &props); + fColorType, info.refColorSpace(), &props); break; case SkCommandLineConfigGpu::SurfType::kBackendRenderTarget: if (1 == fSampleCount) { diff --git a/docs/SkSurface_Reference.bmh b/docs/SkSurface_Reference.bmh index 41c1b79697..e634ad5dd9 100644 --- a/docs/SkSurface_Reference.bmh +++ b/docs/SkSurface_Reference.bmh @@ -349,63 +349,6 @@ void draw(SkCanvas* ) { #Method static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, int sampleCnt, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* surfaceProps) -#In Constructor -#Line # creates Surface from GPU-backed texture ## - -Wraps a GPU-backed texture into Surface. Caller must ensure the texture is -valid for the lifetime of returned Surface. If sampleCnt greater than zero, -creates an intermediate MSAA Surface which is used for drawing backendTexture. - -Surface is returned if all parameters are valid. backendTexture is valid if -its pixel configuration agrees with colorSpace and context; for instance, if -backendTexture has an sRGB configuration, then context must support sRGB, -and colorSpace must be present. Further, backendTexture width and height must -not exceed context capabilities, and the context must be able to support -back-end textures. - -If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. - -#Param context GPU_Context ## -#Param backendTexture texture residing on GPU ## -#Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## -#Param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing ## -#Param colorSpace range of colors ## -#Param surfaceProps LCD striping orientation and setting for device independent - fonts; may be nullptr -## - -#Return Surface if all parameters are valid; otherwise, nullptr ## - -#Example -#ToDo remove !fiddle below once backEndTextureRenderTarget is available ## -#Platform !fiddle gpu cpu - SkPaint paint; - paint.setTextSize(32); - GrContext* context = canvas->getGrContext(); - if (!context) { - canvas->drawString("GPU only!", 20, 40, paint); - return; - } - sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTexture(context, - backEndTextureRenderTarget, kTopLeft_GrSurfaceOrigin, 0, nullptr, nullptr); - auto surfaceCanvas = gpuSurface->getCanvas(); - surfaceCanvas->clear(SK_ColorWHITE); - surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); - sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); - canvas->drawImage(image, 0, 0); -## - -#SeeAlso GrBackendTexture MakeFromBackendRenderTarget MakeRenderTarget - -#Method ## - -# ------------------------------------------------------------------------------ - -#Method static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context, - const GrBackendTexture& backendTexture, - GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps) diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index 456ee362f2..136fc8b846 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -173,34 +173,6 @@ public: @param backendTexture texture residing on GPU @param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing - @param colorSpace range of colors - @param surfaceProps LCD striping orientation and setting for device independent - fonts; may be nullptr - @return SkSurface if all parameters are valid; otherwise, nullptr - */ - static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context, - const GrBackendTexture& backendTexture, - GrSurfaceOrigin origin, int sampleCnt, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* surfaceProps); - - /** Wraps a GPU-backed texture into SkSurface. Caller must ensure the texture is - valid for the lifetime of returned SkSurface. If sampleCnt greater than zero, - creates an intermediate MSAA SkSurface which is used for drawing backendTexture. - - SkSurface is returned if all parameters are valid. backendTexture is valid if - its pixel configuration agrees with colorSpace and context; for instance, if - backendTexture has an sRGB configuration, then context must support sRGB, - and colorSpace must be present. Further, backendTexture width and height must - not exceed context capabilities, and the context must be able to support - back-end textures. - - If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. - - @param context GPU context - @param backendTexture texture residing on GPU - @param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin - @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing @param colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType, kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index 3ff7128014..3d95e9baef 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -279,12 +279,6 @@ sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext*, SkBudgeted, const SkIma sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTexture&, GrSurfaceOrigin origin, int sampleCnt, - sk_sp<SkColorSpace>, const SkSurfaceProps*) { - return nullptr; -} - -sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTexture&, - GrSurfaceOrigin origin, int sampleCnt, SkColorType, sk_sp<SkColorSpace>, const SkSurfaceProps*) { return nullptr; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index c4479a2d24..74169b6548 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -312,37 +312,6 @@ sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(GrContext* context, return sk_make_sp<SkSurface_Gpu>(std::move(device)); } - -sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrBackendTexture& tex, - GrSurfaceOrigin origin, int sampleCnt, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* props) { - if (!context) { - return nullptr; - } - if (!SkSurface_Gpu::Valid(context, tex.config(), colorSpace.get())) { - return nullptr; - } - sampleCnt = SkTMax(1, sampleCnt); - - sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeBackendTextureRenderTargetContext( - tex, - origin, - sampleCnt, - std::move(colorSpace), - props)); - if (!rtc) { - return nullptr; - } - - sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), tex.width(), tex.height(), - SkGpuDevice::kUninit_InitContents)); - if (!device) { - return nullptr; - } - return sk_make_sp<SkSurface_Gpu>(std::move(device)); -} - bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex, GrPixelConfig* config, int sampleCnt, SkColorType ct, sk_sp<SkColorSpace> cs, bool texturable) { @@ -385,7 +354,31 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrB return nullptr; } - return MakeFromBackendTexture(context, texCopy, origin, sampleCnt, colorSpace, props); + if (!context) { + return nullptr; + } + if (!SkSurface_Gpu::Valid(context, texCopy.config(), colorSpace.get())) { + return nullptr; + } + sampleCnt = SkTMax(1, sampleCnt); + + sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeBackendTextureRenderTargetContext( + texCopy, + origin, + sampleCnt, + std::move(colorSpace), + props)); + if (!rtc) { + return nullptr; + } + + sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), texCopy.width(), + texCopy.height(), + SkGpuDevice::kUninit_InitContents)); + if (!device) { + return nullptr; + } + return sk_make_sp<SkSurface_Gpu>(std::move(device)); } sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, |