Remove last two uses of SkGpuDevice's GrSurfaceDrawContext-based factory
Change-Id: Ib286933a1c2c82efbb87799016550086bcbc584f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410817
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index b330c81..1e31b03 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -393,9 +393,9 @@
return nullptr;
}
- return SkSpecialSurface::MakeRenderTarget(fContext, size.width(), size.height(),
- SkColorTypeToGrColorType(colorType),
- sk_ref_sp(colorSpace), props);
+ SkImageInfo ii = SkImageInfo::Make(size, colorType, at, sk_ref_sp(colorSpace));
+
+ return SkSpecialSurface::MakeRenderTarget(fContext, ii, props);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 0fcacfb..97d53a3 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -124,14 +124,9 @@
class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
public:
- SkSpecialSurface_Gpu(std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext, SkIRect subset)
- : INHERITED(subset, surfaceDrawContext->surfaceProps())
- , fReadView(surfaceDrawContext->readSurfaceView()) {
- auto device = SkGpuDevice::Make(std::move(surfaceDrawContext),
- SkBaseGpuDevice::kUninit_InitContents);
- if (!device) {
- return;
- }
+ SkSpecialSurface_Gpu(sk_sp<SkGpuDevice> device, SkIRect subset)
+ : INHERITED(subset, device->surfaceProps())
+ , fReadView(device->readSurfaceView()) {
fCanvas = std::make_unique<SkCanvas>(std::move(device));
fCanvas->clipRect(SkRect::Make(subset));
@@ -161,25 +156,23 @@
using INHERITED = SkSpecialSurface_Base;
};
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrRecordingContext* context,
- int width, int height,
- GrColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrRecordingContext* rContext,
+ const SkImageInfo& ii,
const SkSurfaceProps& props) {
- if (!context) {
- return nullptr;
- }
- auto surfaceDrawContext = GrSurfaceDrawContext::Make(
- context, colorType, std::move(colorSpace), SkBackingFit::kApprox, {width, height},
- props, 1, GrMipmapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin,
- SkBudgeted::kYes);
- if (!surfaceDrawContext) {
+ if (!rContext) {
return nullptr;
}
- const SkIRect subset = SkIRect::MakeWH(width, height);
+ auto device = SkGpuDevice::Make(rContext, SkBudgeted::kYes, ii, SkBackingFit::kApprox, 1,
+ kBottomLeft_GrSurfaceOrigin, &props, GrMipmapped::kNo,
+ GrProtected::kNo, SkGpuDevice::kUninit_InitContents);
+ if (!device) {
+ return nullptr;
+ }
- return sk_make_sp<SkSpecialSurface_Gpu>(std::move(surfaceDrawContext), subset);
+ const SkIRect subset = SkIRect::MakeSize(ii.dimensions());
+
+ return sk_make_sp<SkSpecialSurface_Gpu>(std::move(device), subset);
}
#endif
diff --git a/src/core/SkSpecialSurface.h b/src/core/SkSpecialSurface.h
index fcd20b1..88c5355 100644
--- a/src/core/SkSpecialSurface.h
+++ b/src/core/SkSpecialSurface.h
@@ -60,8 +60,8 @@
* Allocate a new GPU-backed SkSpecialSurface. If the requested surface cannot
* be created, nullptr will be returned.
*/
- static sk_sp<SkSpecialSurface> MakeRenderTarget(GrRecordingContext*, int width, int height,
- GrColorType, sk_sp<SkColorSpace> colorSpace,
+ static sk_sp<SkSpecialSurface> MakeRenderTarget(GrRecordingContext*,
+ const SkImageInfo&,
const SkSurfaceProps&);
#endif
diff --git a/src/gpu/GrSurfaceDrawContext.cpp b/src/gpu/GrSurfaceDrawContext.cpp
index f4f362e..15f2cd1 100644
--- a/src/gpu/GrSurfaceDrawContext.cpp
+++ b/src/gpu/GrSurfaceDrawContext.cpp
@@ -247,23 +247,6 @@
origin, surfaceProps);
}
-std::unique_ptr<GrSurfaceDrawContext> GrSurfaceDrawContext::MakeFromVulkanSecondaryCB(
- GrRecordingContext* context,
- const SkImageInfo& imageInfo,
- const GrVkDrawableInfo& vkInfo,
- const SkSurfaceProps& props) {
- sk_sp<GrSurfaceProxy> proxy(
- context->priv().proxyProvider()->wrapVulkanSecondaryCBAsRenderTarget(imageInfo,
- vkInfo));
- if (!proxy) {
- return nullptr;
- }
-
- return GrSurfaceDrawContext::Make(context, SkColorTypeToGrColorType(imageInfo.colorType()),
- imageInfo.refColorSpace(), std::move(proxy),
- kTopLeft_GrSurfaceOrigin, props);
-}
-
// In MDB mode the reffing of the 'getLastOpsTask' call's result allows in-progress
// GrOpsTask to be picked up and added to by renderTargetContexts lower in the call
// stack. When this occurs with a closed GrOpsTask, a new one will be allocated
diff --git a/src/gpu/GrSurfaceDrawContext.h b/src/gpu/GrSurfaceDrawContext.h
index 65cac64..68cfce1 100644
--- a/src/gpu/GrSurfaceDrawContext.h
+++ b/src/gpu/GrSurfaceDrawContext.h
@@ -123,10 +123,6 @@
int sampleCnt, GrSurfaceOrigin, const SkSurfaceProps&,
sk_sp<GrRefCntedCallback> releaseHelper);
- static std::unique_ptr<GrSurfaceDrawContext> MakeFromVulkanSecondaryCB(
- GrRecordingContext*, const SkImageInfo&, const GrVkDrawableInfo&,
- const SkSurfaceProps&);
-
GrSurfaceDrawContext(GrRecordingContext*,
GrSurfaceProxyView readView,
GrSurfaceProxyView writeView,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 7a21434..1b6c00b 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -114,7 +114,7 @@
}
sk_sp<SkGpuDevice> SkGpuDevice::Make(GrRecordingContext* rContext, SkBudgeted budgeted,
- const SkImageInfo& info, int sampleCount,
+ const SkImageInfo& info, SkBackingFit fit, int sampleCount,
GrSurfaceOrigin origin, const SkSurfaceProps* props,
GrMipmapped mipMapped, GrProtected isProtected,
InitContents init) {
@@ -124,7 +124,7 @@
return nullptr;
}
- auto sdc = MakeSurfaceDrawContext(rContext, budgeted, info, sampleCount, origin,
+ auto sdc = MakeSurfaceDrawContext(rContext, budgeted, info, fit, sampleCount, origin,
props, mipMapped, isProtected);
if (!sdc) {
return nullptr;
@@ -168,6 +168,7 @@
GrRecordingContext* rContext,
SkBudgeted budgeted,
const SkImageInfo& origInfo,
+ SkBackingFit fit,
int sampleCount,
GrSurfaceOrigin origin,
const SkSurfaceProps* surfaceProps,
@@ -181,7 +182,7 @@
// they need to be exact.
return GrSurfaceDrawContext::Make(
rContext, SkColorTypeToGrColorType(origInfo.colorType()), origInfo.refColorSpace(),
- SkBackingFit::kExact, origInfo.dimensions(), SkSurfacePropsCopyOrDefault(surfaceProps),
+ fit, origInfo.dimensions(), SkSurfacePropsCopyOrDefault(surfaceProps),
sampleCount, mipmapped, isProtected, origin, budgeted);
}
@@ -263,6 +264,7 @@
auto newSDC = MakeSurfaceDrawContext(this->recordingContext(),
budgeted,
this->imageInfo(),
+ SkBackingFit::kExact,
fSurfaceDrawContext->numSamples(),
fSurfaceDrawContext->origin(),
&this->surfaceProps(),
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index e23185e..d53e261 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -39,7 +39,7 @@
}
/**
- * This factory uses the origin, surface properties, color space and initialization
+ * This factory uses the color space, origin, surface properties, and initialization
* method along with the provided proxy to create the gpu device.
*/
static sk_sp<SkGpuDevice> Make(GrRecordingContext*,
@@ -51,20 +51,15 @@
InitContents);
/**
- * Creates an SkGpuDevice from a GrSurfaceDrawContext whose backing width/height is
- * different than its actual width/height (e.g., approx-match scratch texture).
- */
- static sk_sp<SkGpuDevice> Make(std::unique_ptr<GrSurfaceDrawContext>, InitContents);
-
- /**
- * This factory uses the budgeted, imageInfo, sampleCount, mipmapped, and isProtected
- * parameters to create and exact-fit proxy to back the gpu device. The origin, surface
- * properties, color space (from the image info) and initialization method are then used
- * (with the created proxy) to create the device.
+ * This factory uses the budgeted, imageInfo, fit, sampleCount, mipmapped, and isProtected
+ * parameters to create a proxy to back the gpu device. The color space (from the image info),
+ * origin, surface properties, and initialization method are then used (with the created proxy)
+ * to create the device.
*/
static sk_sp<SkGpuDevice> Make(GrRecordingContext*,
SkBudgeted,
const SkImageInfo&,
+ SkBackingFit,
int sampleCount,
GrSurfaceOrigin,
const SkSurfaceProps*,
@@ -186,6 +181,8 @@
static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init,
unsigned* flags);
+ static sk_sp<SkGpuDevice> Make(std::unique_ptr<GrSurfaceDrawContext>, InitContents);
+
SkGpuDevice(std::unique_ptr<GrSurfaceDrawContext>, unsigned flags);
SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
@@ -217,6 +214,7 @@
static std::unique_ptr<GrSurfaceDrawContext> MakeSurfaceDrawContext(GrRecordingContext*,
SkBudgeted,
const SkImageInfo&,
+ SkBackingFit,
int sampleCount,
GrSurfaceOrigin,
const SkSurfaceProps*,
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
index d36b6a6..f33d2bb 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
@@ -16,6 +16,8 @@
#include "src/core/SkSurfacePriv.h"
#include "src/gpu/GrContextThreadSafeProxyPriv.h"
#include "src/gpu/GrDirectContextPriv.h"
+#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceDrawContext.h"
#include "src/gpu/SkGpuDevice.h"
@@ -31,11 +33,22 @@
return nullptr;
}
- auto rtc = GrSurfaceDrawContext::MakeFromVulkanSecondaryCB(rContext, imageInfo, vkInfo,
- SkSurfacePropsCopyOrDefault(props));
- SkASSERT(rtc->asSurfaceProxy()->isInstantiated());
+ sk_sp<GrSurfaceProxy> proxy(
+ rContext->priv().proxyProvider()->wrapVulkanSecondaryCBAsRenderTarget(imageInfo,
+ vkInfo));
+ if (!proxy) {
+ return nullptr;
+ }
- auto device = SkGpuDevice::Make(std::move(rtc), SkBaseGpuDevice::kUninit_InitContents);
+ SkASSERT(proxy->isInstantiated());
+
+ auto device = SkGpuDevice::Make(rContext,
+ SkColorTypeToGrColorType(imageInfo.colorType()),
+ imageInfo.refColorSpace(),
+ std::move(proxy),
+ kTopLeft_GrSurfaceOrigin,
+ SkSurfacePropsCopyOrDefault(props),
+ SkGpuDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 808facf..433da1b 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -413,9 +413,10 @@
return nullptr;
}
- auto device = SkGpuDevice::Make(rContext, budgeted, c.imageInfo(), c.sampleCount(),
- c.origin(), &c.surfaceProps(), GrMipmapped(c.isMipMapped()),
- c.isProtected(), SkBaseGpuDevice::kClear_InitContents);
+ auto device = SkGpuDevice::Make(rContext, budgeted, c.imageInfo(), SkBackingFit::kExact,
+ c.sampleCount(), c.origin(), &c.surfaceProps(),
+ GrMipmapped(c.isMipMapped()), c.isProtected(),
+ SkBaseGpuDevice::kClear_InitContents);
if (!device) {
return nullptr;
}
@@ -471,8 +472,9 @@
mipMapped = GrMipmapped::kNo;
}
- sk_sp<SkGpuDevice> device(SkGpuDevice::Make(rContext, budgeted, info, sampleCount, origin,
- props, mipMapped, GrProtected::kNo,
+ sk_sp<SkGpuDevice> device(SkGpuDevice::Make(rContext, budgeted, info, SkBackingFit::kExact,
+ sampleCount, origin, props, mipMapped,
+ GrProtected::kNo,
SkBaseGpuDevice::kClear_InitContents));
if (!device) {
return nullptr;
diff --git a/tests/DeviceTest.cpp b/tests/DeviceTest.cpp
index 9dccbc8..9d3db89 100644
--- a/tests/DeviceTest.cpp
+++ b/tests/DeviceTest.cpp
@@ -84,7 +84,7 @@
SkImageInfo ii = SkImageInfo::MakeN32Premul(2*kWidth, 2*kHeight);
- sk_sp<SkBaseDevice> gpuDev(SkGpuDevice::Make(context, SkBudgeted::kNo, ii,
+ sk_sp<SkBaseDevice> gpuDev(SkGpuDevice::Make(context, SkBudgeted::kNo, ii, SkBackingFit::kExact,
1, kBottomLeft_GrSurfaceOrigin, nullptr,
GrMipmapped::kNo, GrProtected::kNo,
SkBaseGpuDevice::kClear_InitContents));
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index e5730b77..743489b 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -331,14 +331,15 @@
static sk_sp<SkSpecialSurface> create_empty_special_surface(GrRecordingContext* rContext,
int widthHeight) {
+
+ const SkImageInfo ii = SkImageInfo::Make({ widthHeight, widthHeight },
+ kRGBA_8888_SkColorType,
+ kPremul_SkAlphaType);
+
if (rContext) {
- return SkSpecialSurface::MakeRenderTarget(rContext, widthHeight, widthHeight,
- GrColorType::kRGBA_8888, nullptr,
- SkSurfaceProps());
+ return SkSpecialSurface::MakeRenderTarget(rContext, ii, SkSurfaceProps());
} else {
- const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight,
- kOpaque_SkAlphaType);
- return SkSpecialSurface::MakeRaster(info, SkSurfaceProps());
+ return SkSpecialSurface::MakeRaster(ii, SkSurfaceProps());
}
}
diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp
index 0182ae3..b309a5a 100644
--- a/tests/SpecialSurfaceTest.cpp
+++ b/tests/SpecialSurfaceTest.cpp
@@ -77,14 +77,17 @@
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, ctxInfo) {
- auto direct = ctxInfo.directContext();
+ auto dContext = ctxInfo.directContext();
- for (auto colorType : {GrColorType::kRGBA_8888, GrColorType::kRGBA_1010102}) {
- if (!direct->colorTypeSupportedAsSurface(GrColorTypeToSkColorType(colorType))) {
+ for (auto colorType : { kRGBA_8888_SkColorType, kRGBA_1010102_SkColorType }) {
+ if (!dContext->colorTypeSupportedAsSurface(colorType)) {
continue;
}
- sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(
- direct, kSmallerSize, kSmallerSize, colorType, nullptr, SkSurfaceProps()));
+
+ SkImageInfo ii = SkImageInfo::Make({ kSmallerSize, kSmallerSize }, colorType,
+ kPremul_SkAlphaType);
+
+ auto surf(SkSpecialSurface::MakeRenderTarget(dContext, ii, SkSurfaceProps()));
test_surface(surf, reporter, 0);
}
}