Revert "Feed all top-level GPU accessors through skgpu::BaseDevice"
This reverts commit 5de8b1950422d002f9c1a1ebdf545364d7d1dcfe.
Reason for revert: blocking Android roll
Original change's description:
> Feed all top-level GPU accessors through skgpu::BaseDevice
>
> This pulls the GPU-specific accessors off of SkCanvas and SkDevice - moving them all to skgpu::BaseDevice and SkCanvasPriv.
>
> This will allow us to more easily change the gpu class hierarchy (esp. changing GrSurfaceDrawContext to skgpu::v1:SurfaceDrawContext) w/o churning the public API.
>
> Bug: skia:11837
> Change-Id: I4e205255706680ac58ffe40f714884c2ee7ac799
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431036
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
TBR=robertphillips@google.com,brianosman@google.com,michaelludwig@google.com
Change-Id: I8a015be4edbe21d63db09d5593af13cc89df4217
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431538
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 50efaa8..61bbead 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -53,7 +53,6 @@
#if SK_SUPPORT_GPU
#include "include/gpu/GrDirectContext.h"
-#include "src/gpu/BaseDevice.h"
#include "src/gpu/SkGr.h"
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
# include "src/gpu/GrRenderTarget.h"
@@ -559,6 +558,14 @@
return fMCRec->fDevice;
}
+GrSurfaceDrawContext* SkCanvas::topDeviceSurfaceDrawContext() {
+ return this->topDevice()->surfaceDrawContext();
+}
+
+GrRenderTargetProxy* SkCanvas::topDeviceTargetProxy() {
+ return this->topDevice()->targetProxy();
+}
+
bool SkCanvas::readPixels(const SkPixmap& pm, int x, int y) {
return pm.addr() && this->baseDevice()->readPixels(pm, x, y);
}
@@ -1664,13 +1671,7 @@
#endif
GrRecordingContext* SkCanvas::recordingContext() {
-#if SK_SUPPORT_GPU
- if (auto gpuDevice = this->topDevice()->asGpuDevice()) {
- return gpuDevice->recordingContext();
- }
-#endif
-
- return nullptr;
+ return this->topDevice()->recordingContext();
}
void SkCanvas::drawDRRect(const SkRRect& outer, const SkRRect& inner,
diff --git a/src/core/SkCanvasPriv.cpp b/src/core/SkCanvasPriv.cpp
index 09398d7..888e06c 100644
--- a/src/core/SkCanvasPriv.cpp
+++ b/src/core/SkCanvasPriv.cpp
@@ -118,44 +118,26 @@
return true;
}
-#if GR_TEST_UTILS
-
#if SK_SUPPORT_GPU
-#include "src/gpu/BaseDevice.h"
+#include "src/gpu/GrSurfaceDrawContext.h"
-#if SK_GPU_V1
GrSurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanvas* canvas) {
- if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
- return gpuDevice->surfaceDrawContext();
- }
-
- return nullptr;
+ return canvas->topDeviceSurfaceDrawContext();
}
-#endif // SK_GPU_V1
GrSurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas) {
- if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
- return gpuDevice->surfaceFillContext();
- }
-
- return nullptr;
+ return canvas->topDeviceSurfaceDrawContext();
}
GrRenderTargetProxy* SkCanvasPriv::TopDeviceTargetProxy(SkCanvas* canvas) {
- if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
- return gpuDevice->targetProxy();
- }
-
- return nullptr;
+ return canvas->topDeviceTargetProxy();
}
-#else // SK_SUPPORT_GPU
+#else
-#if SK_GPU_V1
GrSurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanvas* canvas) {
return nullptr;
}
-#endif // SK_GPU_V1
GrSurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas) {
return nullptr;
@@ -165,6 +147,4 @@
return nullptr;
}
-#endif // SK_SUPPORT_GPU
-
-#endif // GR_TEST_UTILS
+#endif
diff --git a/src/core/SkCanvasPriv.h b/src/core/SkCanvasPriv.h
index 34cb065..35158ec 100644
--- a/src/core/SkCanvasPriv.h
+++ b/src/core/SkCanvasPriv.h
@@ -14,16 +14,8 @@
class SkReadBuffer;
class SkWriteBuffer;
-#if GR_TEST_UTILS
-// This declaration must match the one in SkDeferredDisplayList.h
-#if SK_SUPPORT_GPU
-class GrRenderTargetProxy;
-#else
-using GrRenderTargetProxy = SkRefCnt;
-#endif
class GrSurfaceDrawContext;
class GrSurfaceFillContext;
-#endif // GR_TEST_UTILS
class SkAutoCanvasMatrixPaint : SkNoncopyable {
public:
@@ -58,13 +50,9 @@
canvas->androidFramework_replaceClip(rect);
}
-#if GR_TEST_UTILS
-#if SK_GPU_V1
static GrSurfaceDrawContext* TopDeviceSurfaceDrawContext(SkCanvas*);
-#endif
static GrSurfaceFillContext* TopDeviceSurfaceFillContext(SkCanvas*);
static GrRenderTargetProxy* TopDeviceTargetProxy(SkCanvas*);
-#endif // GR_TEST_UTILS
// The experimental_DrawEdgeAAImageSet API accepts separate dstClips and preViewMatrices arrays,
// where entries refer into them, but no explicit size is provided. Given a set of entries,
diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h
index b00a485..9c99e19 100644
--- a/src/core/SkDevice.h
+++ b/src/core/SkDevice.h
@@ -31,8 +31,9 @@
class SkRasterHandleAllocator;
class SkSpecialImage;
-namespace skif { class Mapping; }
-namespace skgpu { class BaseDevice; }
+namespace skif {
+ class Mapping;
+} // namespace skif
class SkBaseDevice : public SkRefCnt, public SkMatrixProvider {
public:
@@ -197,7 +198,9 @@
virtual bool android_utils_clipWithStencil() { return false; }
- virtual skgpu::BaseDevice* asGpuDevice() { return nullptr; }
+ virtual GrRecordingContext* recordingContext() const { return nullptr; }
+ virtual GrSurfaceDrawContext* surfaceDrawContext() { return nullptr; }
+ virtual GrRenderTargetProxy* targetProxy() { return nullptr; }
// Ensure that non-RSXForm runs are passed to onDrawGlyphRunList.
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint);
diff --git a/src/gpu/BaseDevice.cpp b/src/gpu/BaseDevice.cpp
index efeea35..4da8e99 100644
--- a/src/gpu/BaseDevice.cpp
+++ b/src/gpu/BaseDevice.cpp
@@ -16,13 +16,6 @@
namespace skgpu {
-BaseDevice::BaseDevice(sk_sp<GrRecordingContext> rContext,
- const SkImageInfo& ii,
- const SkSurfaceProps& props)
- : INHERITED(ii, props)
- , fContext(std::move(rContext)) {
-}
-
GrRenderTargetProxy* BaseDevice::targetProxy() {
return this->readSurfaceView().asRenderTargetProxy();
}
diff --git a/src/gpu/BaseDevice.h b/src/gpu/BaseDevice.h
index 1427921..fbd28c5 100644
--- a/src/gpu/BaseDevice.h
+++ b/src/gpu/BaseDevice.h
@@ -11,9 +11,6 @@
#include "include/core/SkImage.h"
#include "include/private/GrTypesPriv.h"
-class GrRenderTargetProxy;
-class GrSurfaceDrawContext;
-class GrSurfaceFillContext;
class GrSurfaceProxyView;
// NOTE: when not defined, SkGpuDevice extends SkBaseDevice directly and manages its clip stack
@@ -43,20 +40,17 @@
kUninit_InitContents
};
- BaseDevice(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&);
+ BaseDevice(sk_sp<GrRecordingContext> rContext,
+ const SkImageInfo& ii,
+ const SkSurfaceProps& props)
+ : INHERITED(ii, props)
+ , fContext(std::move(rContext)) {
+ }
virtual GrSurfaceProxyView readSurfaceView() = 0;
+ GrRenderTargetProxy* targetProxy() override;
- BaseDevice* asGpuDevice() override { return this; }
-
-#if SK_GPU_V1
- // TODO: make this return a skgpu::v1:SurfaceDrawContext
- virtual GrSurfaceDrawContext* surfaceDrawContext() { return nullptr; }
-#endif
-
- virtual GrSurfaceFillContext* surfaceFillContext() = 0;
- GrRenderTargetProxy* targetProxy();
- GrRecordingContext* recordingContext() const { return fContext.get(); }
+ GrRecordingContext* recordingContext() const override { return fContext.get(); }
virtual bool wait(int numSemaphores,
const GrBackendSemaphore* waitSemaphores,
diff --git a/src/gpu/v1/Device.cpp b/src/gpu/v1/Device.cpp
index 05e23fb..b7af9cd 100644
--- a/src/gpu/v1/Device.cpp
+++ b/src/gpu/v1/Device.cpp
@@ -291,11 +291,6 @@
return fSurfaceDrawContext.get();
}
-GrSurfaceFillContext* Device::surfaceFillContext() {
- ASSERT_SINGLE_OWNER
- return fSurfaceDrawContext.get();
-}
-
void Device::clearAll() {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::v1::Device", "clearAll", fContext.get());
diff --git a/src/gpu/v1/Device_v1.h b/src/gpu/v1/Device_v1.h
index 5c7fd1e..203307a 100644
--- a/src/gpu/v1/Device_v1.h
+++ b/src/gpu/v1/Device_v1.h
@@ -106,7 +106,6 @@
GrSurfaceDrawContext* surfaceDrawContext() override;
const GrSurfaceDrawContext* surfaceDrawContext() const;
- GrSurfaceFillContext* surfaceFillContext() override;
// set all pixels to 0
void clearAll();
diff --git a/src/gpu/v2/Device.cpp b/src/gpu/v2/Device.cpp
index bb1f365..d9bedfc 100644
--- a/src/gpu/v2/Device.cpp
+++ b/src/gpu/v2/Device.cpp
@@ -26,10 +26,6 @@
GrSurfaceProxyView Device::readSurfaceView() { return {}; }
-GrSurfaceFillContext* Device::surfaceFillContext() {
- return nullptr;
-}
-
void Device::asyncRescaleAndReadPixels(const SkImageInfo& info,
const SkIRect& srcRect,
RescaleGamma rescaleGamma,
diff --git a/src/gpu/v2/Device_v2.h b/src/gpu/v2/Device_v2.h
index f3f1a6e..b4431f4 100644
--- a/src/gpu/v2/Device_v2.h
+++ b/src/gpu/v2/Device_v2.h
@@ -44,8 +44,6 @@
GrSurfaceProxyView readSurfaceView() override;
- GrSurfaceFillContext* surfaceFillContext() override;
-
bool wait(int numSemaphores,
const GrBackendSemaphore* waitSemaphores,
bool deleteSemaphoresAfterWait) override {
@@ -79,6 +77,8 @@
ReadPixelsCallback,
ReadPixelsContext) override;
+ GrSurfaceDrawContext* surfaceDrawContext() override { return nullptr; }
+
protected:
void onSave() override;
void onRestore() override;
diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp
index 982c2e3..156c4e6 100644
--- a/src/utils/SkPaintFilterCanvas.cpp
+++ b/src/utils/SkPaintFilterCanvas.cpp
@@ -279,3 +279,11 @@
bool SkPaintFilterCanvas::onGetProps(SkSurfaceProps* props) const {
return this->proxy()->getProps(props);
}
+
+GrSurfaceDrawContext* SkPaintFilterCanvas::topDeviceSurfaceDrawContext() {
+ return SkCanvasPriv::TopDeviceSurfaceDrawContext(this->proxy());
+}
+
+GrRenderTargetProxy* SkPaintFilterCanvas::topDeviceTargetProxy() {
+ return SkCanvasPriv::TopDeviceTargetProxy(this->proxy());
+}