Remove SkDevice::accessRenderTarget virtual
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2167723002
Review-Url: https://codereview.chromium.org/2167723002
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 827897c..76d4644 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -105,16 +105,6 @@
bool peekPixels(SkPixmap*);
/**
- * Return the device's associated gpu render target, or NULL.
- */
- virtual GrRenderTarget* accessRenderTarget() { return nullptr; }
-
- /**
- * Don't call this!
- */
- virtual GrDrawContext* accessDrawContext() { return nullptr; }
-
- /**
* Return the device's origin: its offset in device coordinates from
* the default origin in its canvas' matrix/clip
*/
@@ -385,6 +375,11 @@
virtual bool forceConservativeRasterClip() const { return false; }
+ /**
+ * Don't call this!
+ */
+ virtual GrDrawContext* accessDrawContext() { return nullptr; }
+
// just called by SkCanvas when built as a layer
void setOrigin(int x, int y) { fOrigin.set(x, y); }
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 8ce4b30..9357568 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -341,11 +341,6 @@
fClip.reset(fClipStack, &this->getOrigin());
}
-GrRenderTarget* SkGpuDevice::accessRenderTarget() {
- ASSERT_SINGLE_OWNER
- return fRenderTarget.get();
-}
-
GrDrawContext* SkGpuDevice::accessDrawContext() {
ASSERT_SINGLE_OWNER
return fDrawContext.get();
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 8fec082..b72e917 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -78,7 +78,6 @@
void replaceDrawContext(bool shouldRetainContent);
- GrRenderTarget* accessRenderTarget() override;
GrDrawContext* accessDrawContext() override;
SkImageInfo imageInfo() const override {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 7c08b13..de67d6c 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -38,7 +38,7 @@
}
extern void SkTextureImageApplyBudgetedDecision(SkImage* image) {
- if (as_IB(image)->peekTexture()) {
+ if (image->isTextureBacked()) {
((SkImage_Gpu*)image)->applyBudgetDecision();
}
}
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 5b4bfaf..5d1555f 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -40,9 +40,9 @@
}
// Grab the render target *after* firing notifications, as it may get switched if CoW kicks in.
- GrRenderTarget* rt = surface->getDevice()->accessRenderTarget();
- rt->prepareForExternalIO();
- return rt;
+ surface->getDevice()->flush();
+ GrDrawContext* dc = surface->getDevice()->accessDrawContext();
+ return dc->accessRenderTarget();
}
GrBackendObject SkSurface_Gpu::onGetTextureHandle(BackendHandleAccess access) {
@@ -76,7 +76,7 @@
}
sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode forceCopyMode) {
- GrRenderTarget* rt = fDevice->accessRenderTarget();
+ GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget();
SkASSERT(rt);
GrTexture* tex = rt->asTexture();
SkAutoTUnref<GrTexture> copy;
@@ -109,7 +109,7 @@
// render target into it. Note that this flushes the SkGpuDevice but
// doesn't force an OpenGL flush.
void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
- GrRenderTarget* rt = fDevice->accessRenderTarget();
+ GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget();
// are we sharing our render target with the image? Note this call should never create a new
// image because onCopyOnWrite is only called when there is a cached image.
sk_sp<SkImage> image(this->refCachedImage(SkBudgeted::kNo, kNo_ForceUnique));
@@ -127,7 +127,7 @@
}
void SkSurface_Gpu::onPrepareForExternalIO() {
- fDevice->accessRenderTarget()->prepareForExternalIO();
+ fDevice->flush();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 2a322ea..3996ab7 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -627,7 +627,7 @@
static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) {
SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get();
- return gsurf->getDevice()->accessRenderTarget()->resourcePriv().isBudgeted();
+ return gsurf->getDevice()->accessDrawContext()->accessRenderTarget()->resourcePriv().isBudgeted();
}
static SkBudgeted is_budgeted(SkImage* image) {
@@ -856,10 +856,6 @@
[] (SkSurface* s){
GrDrawContext* dc = s->getCanvas()->internal_private_accessTopLayerDrawContext();
return dc->accessRenderTarget(); },
- [] (SkSurface* s){
- SkBaseDevice* d =
- s->getCanvas()->getDevice_just_for_deprecated_compatibility_testing();
- return d->accessRenderTarget(); },
[] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot());
return as_IB(i)->peekTexture(); }
};
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp
index ae934a1..062445b 100644
--- a/tools/debugger/SkDebugCanvas.cpp
+++ b/tools/debugger/SkDebugCanvas.cpp
@@ -345,7 +345,7 @@
// get the render target of the top device so we can ignore batches drawn offscreen
SkBaseDevice* bd = canvas->getDevice_just_for_deprecated_compatibility_testing();
SkGpuDevice* gbd = reinterpret_cast<SkGpuDevice*>(bd);
- uint32_t rtID = gbd->accessRenderTarget()->getUniqueID();
+ uint32_t rtID = gbd->accessDrawContext()->accessRenderTarget()->getUniqueID();
// get the bounding boxes to draw
SkTArray<GrAuditTrail::BatchInfo> childrenBounds;