Don't pass GrRecordingContext and GrSurfaceDraw to SkGpuDevice
SkGpuDevice still needs to separately ref the context as
GrSurfaceContext has a bare GrRecordingContext pointer. However, it
doesn't need to be separately specified.
Also rm unused SkSpecialSurface_Gpu() width/height params.
Change-Id: Ia24bbce2a85e21277aff2c1c9e1fd37a29246a6e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404236
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 10b5d74..571b4ba 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -124,12 +124,10 @@
class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
public:
- SkSpecialSurface_Gpu(GrRecordingContext* context,
- std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext,
- int width, int height, const SkIRect& subset)
+ SkSpecialSurface_Gpu(std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext, SkIRect subset)
: INHERITED(subset, surfaceDrawContext->surfaceProps())
, fReadView(surfaceDrawContext->readSurfaceView()) {
- auto device = SkGpuDevice::Make(context, std::move(surfaceDrawContext),
+ auto device = SkGpuDevice::Make(std::move(surfaceDrawContext),
SkGpuDevice::kUninit_InitContents);
if (!device) {
return;
@@ -181,8 +179,7 @@
const SkIRect subset = SkIRect::MakeWH(width, height);
- return sk_make_sp<SkSpecialSurface_Gpu>(context, std::move(surfaceDrawContext),
- width, height, subset);
+ return sk_make_sp<SkSpecialSurface_Gpu>(std::move(surfaceDrawContext), subset);
}
#endif
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 8543eac..b9b1637 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -72,21 +72,25 @@
return true;
}
-sk_sp<SkGpuDevice> SkGpuDevice::Make(GrRecordingContext* context,
- std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext,
+sk_sp<SkGpuDevice> SkGpuDevice::Make(std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext,
InitContents init) {
- if (!surfaceDrawContext || context->abandoned()) {
+ if (!surfaceDrawContext) {
+ return nullptr;
+ }
+
+ GrRecordingContext* rContext = surfaceDrawContext->recordingContext();
+ if (rContext->abandoned()) {
return nullptr;
}
SkColorType ct = GrColorTypeToSkColorType(surfaceDrawContext->colorInfo().colorType());
unsigned flags;
- if (!context->colorTypeSupportedAsSurface(ct) ||
+ if (!rContext->colorTypeSupportedAsSurface(ct) ||
!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
return nullptr;
}
- return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(surfaceDrawContext), flags));
+ return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(surfaceDrawContext), flags));
}
sk_sp<SkGpuDevice> SkGpuDevice::Make(GrRecordingContext* context, SkBudgeted budgeted,
@@ -105,7 +109,7 @@
return nullptr;
}
- return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(surfaceDrawContext), flags));
+ return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(surfaceDrawContext), flags));
}
static SkImageInfo make_info(GrSurfaceDrawContext* context, bool opaque) {
@@ -122,12 +126,10 @@
}
#endif
-SkGpuDevice::SkGpuDevice(GrRecordingContext* context,
- std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext,
- unsigned flags)
+SkGpuDevice::SkGpuDevice(std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext, unsigned flags)
: INHERITED(make_info(surfaceDrawContext.get(), SkToBool(flags & kIsOpaque_Flag)),
surfaceDrawContext->surfaceProps())
- , fContext(SkRef(context))
+ , fContext(sk_ref_sp(surfaceDrawContext->recordingContext()))
, fSurfaceDrawContext(std::move(surfaceDrawContext))
#if !defined(SK_DISABLE_NEW_GR_CLIP_STACK)
, fClip(SkIRect::MakeSize(fSurfaceDrawContext->dimensions()),
@@ -989,7 +991,7 @@
// Skia's convention is to only clear a device if it is non-opaque.
InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_InitContents;
- return SkGpuDevice::Make(fContext.get(), std::move(sdc), init).release();
+ return SkGpuDevice::Make(std::move(sdc), init).release();
}
sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index e62fc3c..e1e7e68 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -57,9 +57,7 @@
* 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(GrRecordingContext*,
- std::unique_ptr<GrSurfaceDrawContext>,
- InitContents);
+ static sk_sp<SkGpuDevice> Make(std::unique_ptr<GrSurfaceDrawContext>, InitContents);
/**
* New device that will create an offscreen renderTarget based on the ImageInfo and
@@ -186,7 +184,7 @@
static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init,
unsigned* flags);
- SkGpuDevice(GrRecordingContext*, std::unique_ptr<GrSurfaceDrawContext>, unsigned flags);
+ SkGpuDevice(std::unique_ptr<GrSurfaceDrawContext>, unsigned flags);
SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
index 5e68d50..bbe48b4 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
@@ -35,8 +35,7 @@
SkSurfacePropsCopyOrDefault(props));
SkASSERT(rtc->asSurfaceProxy()->isInstantiated());
- sk_sp<SkGpuDevice> device(
- SkGpuDevice::Make(ctx, std::move(rtc), SkGpuDevice::kUninit_InitContents));
+ auto device = SkGpuDevice::Make(std::move(rtc), SkGpuDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 50dcbf2..4a7dfcb 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -426,8 +426,7 @@
return nullptr;
}
- sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(sdc),
- SkGpuDevice::kClear_InitContents));
+ auto device = SkGpuDevice::Make(std::move(sdc), SkGpuDevice::kClear_InitContents);
if (!device) {
return nullptr;
}
@@ -498,7 +497,7 @@
return nullptr;
}
- auto device = SkGpuDevice::Make(context, std::move(sdc), SkGpuDevice::kUninit_InitContents);
+ auto device = SkGpuDevice::Make(std::move(sdc), SkGpuDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
@@ -538,7 +537,7 @@
return nullptr;
}
- auto device = SkGpuDevice::Make(context, std::move(sdc), SkGpuDevice::kUninit_InitContents);
+ auto device = SkGpuDevice::Make(std::move(sdc), SkGpuDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
@@ -652,7 +651,7 @@
return nullptr;
}
- auto device = SkGpuDevice::Make(context, std::move(sdc), SkGpuDevice::kUninit_InitContents);
+ auto device = SkGpuDevice::Make(std::move(sdc), SkGpuDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}