aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-23 15:31:32 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-23 20:44:50 +0000
commit49edccd775a38d93701ae376df28463d7848fd16 (patch)
treea8b9c58bc7440adfa745ba721b712b6a8cb4a33d
parentf4a00e4b4a0642a9f3e69705632f9cd6e9d1cd4d (diff)
Remove legacy SkSurface::MakeFromBackendRenderTarget that does not take SkColorType
Bug: skia:6718 Change-Id: Iefec5be49bf7450426c5ddb668f5525876f8ec2d Reviewed-on: https://skia-review.googlesource.com/116194 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
-rw-r--r--dm/DMSrcSink.cpp6
-rw-r--r--docs/SkSurface_Reference.bmh82
-rw-r--r--include/core/SkSurface.h26
-rw-r--r--src/image/SkSurface.cpp8
-rw-r--r--src/image/SkSurface_Gpu.cpp55
5 files changed, 40 insertions, 137 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 2d8d949e7b..1d8aab1fc1 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1855,9 +1855,9 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
auto colorType = SkColorTypeToGrColorType(info.colorType());
backendRT = context->contextPriv().getGpu()->createTestingOnlyBackendRenderTarget(
info.width(), info.height(), colorType, srgbEncoded);
- surface = SkSurface::MakeFromBackendRenderTarget(context, backendRT,
- kBottomLeft_GrSurfaceOrigin,
- info.refColorSpace(), &props);
+ surface = SkSurface::MakeFromBackendRenderTarget(
+ context, backendRT, kBottomLeft_GrSurfaceOrigin, info.colorType(),
+ info.refColorSpace(), &props);
}
break;
}
diff --git a/docs/SkSurface_Reference.bmh b/docs/SkSurface_Reference.bmh
index c579ec49af..a7053f69d3 100644
--- a/docs/SkSurface_Reference.bmh
+++ b/docs/SkSurface_Reference.bmh
@@ -409,60 +409,6 @@ If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
#Method static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context,
const GrBackendRenderTarget& backendRenderTarget,
GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps)
-#In Constructor
-#Line # creates Surface from GPU memory buffer ##
-
-Wraps a GPU-backed buffer into Surface. Caller must ensure render target is
-valid for the lifetime of returned Surface.
-
-Surface is returned if all parameters are valid. backendRenderTarget is valid if
-its pixel configuration agrees with colorSpace and context; for instance, if
-backendRenderTarget has an sRGB configuration, then context must support sRGB,
-and colorSpace must be present. Further, backendRenderTarget width and height must
-not exceed context capabilities, and the context must be able to support
-back-end render targets.
-
-If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
-
-#Param context GPU_Context ##
-#Param backendRenderTarget GPU intermediate memory buffer ##
-#Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ##
-#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
- SkPaint paint;
- paint.setTextSize(32);
- GrContext* context = canvas->getGrContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, paint);
- return;
- }
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendRenderTarget(context,
- backEndRenderTarget, kTopLeft_GrSurfaceOrigin, nullptr, nullptr);
- auto surfaceCanvas = gpuSurface->getCanvas();
- surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
- sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
- canvas->drawImage(image, 0, 0);
-##
-
-#SeeAlso MakeFromBackendTexture MakeRenderTarget
-
-#Method ##
-
-# ------------------------------------------------------------------------------
-
-#Method static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context,
- const GrBackendRenderTarget& backendRenderTarget,
- GrSurfaceOrigin origin,
SkColorType colorType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* surfaceProps)
@@ -558,20 +504,20 @@ If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
#ToDo example is bogus; gpuSurface should not make image ##
#Platform gpu
#Image 3
- SkPaint paint;
- paint.setTextSize(32);
- GrContext* context = canvas->getGrContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, paint);
- return;
- }
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTextureAsRenderTarget(
- context, backEndTexture, kTopLeft_GrSurfaceOrigin, 0,
- kRGBA_8888_SkColorType, nullptr, nullptr);
- auto surfaceCanvas = gpuSurface->getCanvas();
- surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
- sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
- canvas->drawImage(image, 0, 0);
+ SkPaint paint;
+ paint.setTextSize(32);
+ GrContext* context = canvas->getGrContext();
+ if (!context) {
+ canvas->drawString("GPU only!", 20, 40, paint);
+ return;
+ }
+ sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTextureAsRenderTarget(
+ context, backEndTexture, kTopLeft_GrSurfaceOrigin, 0,
+ kRGBA_8888_SkColorType, nullptr, nullptr);
+ auto surfaceCanvas = gpuSurface->getCanvas();
+ surfaceCanvas->drawString("GPU rocks!", 20, 40, paint);
+ sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
+ canvas->drawImage(image, 0, 0);
##
#SeeAlso MakeFromBackendRenderTarget MakeRenderTarget
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 136fc8b846..419e548f48 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -204,32 +204,6 @@ public:
@param context GPU context
@param backendRenderTarget GPU intermediate memory buffer
@param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
- @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> MakeFromBackendRenderTarget(GrContext* context,
- const GrBackendRenderTarget& backendRenderTarget,
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps);
-
- /** Wraps a GPU-backed buffer into SkSurface. Caller must ensure render target is
- valid for the lifetime of returned SkSurface.
-
- SkSurface is returned if all parameters are valid. backendRenderTarget is valid if
- its pixel configuration agrees with colorSpace and context; for instance, if
- backendRenderTarget has an sRGB configuration, then context must support sRGB,
- and colorSpace must be present. Further, backendRenderTarget width and height must
- not exceed context capabilities, and the context must be able to support
- back-end render targets.
-
- If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
-
- @param context GPU context
- @param backendRenderTarget GPU intermediate memory buffer
- @param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
@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 3d95e9baef..30a1fa464c 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -287,14 +287,6 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTe
sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext*,
const GrBackendRenderTarget&,
GrSurfaceOrigin origin,
- sk_sp<SkColorSpace>,
- const SkSurfaceProps*) {
- return nullptr;
-}
-
-sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext*,
- const GrBackendRenderTarget&,
- GrSurfaceOrigin origin,
SkColorType,
sk_sp<SkColorSpace>,
const SkSurfaceProps*) {
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 74169b6548..ace1981bf7 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -381,37 +381,6 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrB
return sk_make_sp<SkSurface_Gpu>(std::move(device));
}
-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));
-}
-
bool validate_backend_render_target(GrContext* ctx, const GrBackendRenderTarget& rt,
GrPixelConfig* config, SkColorType ct, sk_sp<SkColorSpace> cs) {
// TODO: Create a SkImageColorInfo struct for color, alpha, and color space so we don't need to
@@ -446,12 +415,34 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
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 MakeFromBackendRenderTarget(context, rtCopy, origin, colorSpace, props);
+ return sk_make_sp<SkSurface_Gpu>(std::move(device));
}
sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* context,