Make SkSurface_Gpu::getDevice return a SkBaseGpuDevice

Change-Id: Ib678324849a15204c910df3361d7fd061cae1bb8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411900
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2021-05-24 15:35:08 -04:00 committed by Skia Commit-Bot
parent 37cf46f0e5
commit 5ccb4c1b1d
4 changed files with 14 additions and 12 deletions

View File

@ -43,6 +43,10 @@ GrRecordingContext* SkSurface_Gpu::onGetRecordingContext() {
return fDevice->recordingContext();
}
SkBaseGpuDevice* SkSurface_Gpu::getDevice() {
return fDevice.get();
}
static GrRenderTarget* prepare_rt_for_external_access(SkSurface_Gpu* surface,
SkSurface::BackendHandleAccess access) {
auto dContext = surface->recordingContext()->asDirectContext();

View File

@ -14,6 +14,7 @@
#if SK_SUPPORT_GPU
class GrBackendFormat;
class SkBaseGpuDevice;
class SkGpuDevice;
class SkSurface_Gpu : public SkSurface_Base {
@ -57,7 +58,7 @@ public:
const SkPaint* paint) override;
bool onDraw(sk_sp<const SkDeferredDisplayList>, SkIPoint offset) override;
SkGpuDevice* getDevice() { return fDevice.get(); }
SkBaseGpuDevice* getDevice();
private:
sk_sp<SkGpuDevice> fDevice;

View File

@ -78,8 +78,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
sk_gpu_test::ManagedBackendTexture::ReleaseProc,
mbet->releaseContext());
SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
proxy = device->surfaceDrawContext()->asTextureProxyRef();
SkBaseGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
proxy = device->readSurfaceView().asTextureProxyRef();
} else {
image = SkImage::MakeFromTexture(dContext,
mbet->texture(),
@ -310,8 +310,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
willUseMips);
}
REPORTER_ASSERT(reporter, surface);
SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
GrTextureProxy* texProxy = device->surfaceDrawContext()->asTextureProxy();
SkBaseGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
GrTextureProxy* texProxy = device->readSurfaceView().asTextureProxy();
REPORTER_ASSERT(reporter, mipmapped == texProxy->mipmapped());
texProxy->instantiate(resourceProvider);

View File

@ -204,10 +204,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, repo
ERRORF(reporter, "Could not make surface of color type %d.", colorType);
continue;
}
int sampleCnt = ((SkSurface_Gpu*)(surf.get()))
->getDevice()
->surfaceDrawContext()
->numSamples();
int sampleCnt =
((SkSurface_Gpu*)(surf.get()))->getDevice()->targetProxy()->numSamples();
REPORTER_ASSERT(reporter, sampleCnt == maxSampleCnt, "Exected: %d, actual: %d",
maxSampleCnt, sampleCnt);
}
@ -569,7 +567,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) {
static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) {
SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get();
GrRenderTargetProxy* proxy = gsurf->getDevice()->surfaceDrawContext()->asRenderTargetProxy();
GrRenderTargetProxy* proxy = gsurf->getDevice()->targetProxy();
return proxy->isBudgeted();
}
@ -730,8 +728,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture(GrDirectContext* dCon
static bool supports_readpixels(const GrCaps* caps, SkSurface* surface) {
auto surfaceGpu = static_cast<SkSurface_Gpu*>(surface);
GrSurfaceDrawContext* context = surfaceGpu->getDevice()->surfaceDrawContext();
GrRenderTarget* rt = context->accessRenderTarget();
GrRenderTarget* rt = surfaceGpu->getDevice()->targetProxy()->peekRenderTarget();
if (!rt) {
return false;
}