Move GrRecordingContext pointer to SkBaseGpuDevice

Both SkGpuDevice and SkGpuDevice_nga have this pointer so, share it.

Change-Id: Iafabc51c344d9bdaead0a645ec54aec83fa508d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414441
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2021-06-01 13:12:51 -04:00 committed by Skia Commit-Bot
parent d51fbe1a78
commit 42754922fb
5 changed files with 13 additions and 14 deletions

View File

@ -35,8 +35,11 @@ public:
kUninit_InitContents
};
SkBaseGpuDevice(const SkImageInfo& ii, const SkSurfaceProps& props)
: INHERITED(ii, props) {
SkBaseGpuDevice(sk_sp<GrRecordingContext> rContext,
const SkImageInfo& ii,
const SkSurfaceProps& props)
: INHERITED(ii, props)
, fContext(std::move(rContext)) {
}
virtual GrSurfaceProxyView readSurfaceView() = 0;
@ -44,11 +47,14 @@ public:
return this->readSurfaceView().asRenderTargetProxy();
}
GrRecordingContext* recordingContext() const override { return fContext.get(); }
virtual bool wait(int numSemaphores,
const GrBackendSemaphore* waitSemaphores,
bool deleteSemaphoresAfterWait) = 0;
protected:
sk_sp<GrRecordingContext> fContext;
private:
using INHERITED = BASE_DEVICE;

View File

@ -149,9 +149,9 @@ static bool force_aa_clip(const GrSurfaceDrawContext* sdc) {
#endif
SkGpuDevice::SkGpuDevice(std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext, unsigned flags)
: INHERITED(make_info(surfaceDrawContext.get(), SkToBool(flags & kIsOpaque_Flag)),
: INHERITED(sk_ref_sp(surfaceDrawContext->recordingContext()),
make_info(surfaceDrawContext.get(), SkToBool(flags & kIsOpaque_Flag)),
surfaceDrawContext->surfaceProps())
, fContext(sk_ref_sp(surfaceDrawContext->recordingContext()))
, fSurfaceDrawContext(std::move(surfaceDrawContext))
#if !defined(SK_DISABLE_NEW_GR_CLIP_STACK)
, fClip(SkIRect::MakeSize(fSurfaceDrawContext->dimensions()),

View File

@ -73,7 +73,6 @@ public:
~SkGpuDevice() override {}
GrRecordingContext* recordingContext() const override { return fContext.get(); }
GrSurfaceDrawContext* surfaceDrawContext() override;
const GrSurfaceDrawContext* surfaceDrawContext() const;
@ -168,8 +167,6 @@ protected:
#endif
private:
// We want these unreffed in SurfaceDrawContext, GrContext order.
sk_sp<GrRecordingContext> fContext;
std::unique_ptr<GrSurfaceDrawContext> fSurfaceDrawContext;
GR_CLIP_STACK fClip;

View File

@ -16,11 +16,10 @@
#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(fContext->priv().singleOwner())
SkGpuDevice_nga::SkGpuDevice_nga(GrRecordingContext* rContext,
SkGpuDevice_nga::SkGpuDevice_nga(sk_sp<GrRecordingContext> rContext,
const SkImageInfo& ii,
const SkSurfaceProps& props)
: INHERITED(ii, props)
, fContext(SkRef(rContext)) {
: INHERITED(std::move(rContext), ii, props) {
}
SkGpuDevice_nga::~SkGpuDevice_nga() {}

View File

@ -29,7 +29,6 @@ public:
return false;
}
GrRecordingContext* recordingContext() const override { return fContext.get(); }
GrSurfaceDrawContext* surfaceDrawContext() override { return nullptr; }
protected:
@ -95,14 +94,12 @@ protected:
/* isNoPixelsDevice */
private:
SkGpuDevice_nga(GrRecordingContext*, const SkImageInfo&, const SkSurfaceProps&);
SkGpuDevice_nga(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&);
/* replaceBitmapBackendForRasterSurface */
bool forceConservativeRasterClip() const override;
SkImageFilterCache* getImageFilterCache() override;
sk_sp<GrRecordingContext> fContext;
using INHERITED = SkBaseGpuDevice;
};