[graphite] Add Recorder accessors to SkCanvas and SkSurface
Bug: skia:12845 Change-Id: Ic036dea6b58682a6463f8c34d915730c4bfe677b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/519617 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
5fe4b6faeb
commit
6cb3f3d2c7
@ -38,6 +38,8 @@ public:
|
||||
SkColorType,
|
||||
SkAlphaType);
|
||||
|
||||
Device* asGraphiteDevice() override { return this; }
|
||||
|
||||
Recorder* recorder() { return fRecorder; }
|
||||
// This call is triggered from the Recorder on its registered Devices. It is typically called
|
||||
// when the Recorder is abandoned or deleted.
|
||||
|
@ -21,6 +21,10 @@ Surface::Surface(sk_sp<Device> device)
|
||||
|
||||
Surface::~Surface() {}
|
||||
|
||||
Recorder* Surface::onGetRecorder() {
|
||||
return fDevice->recorder();
|
||||
}
|
||||
|
||||
SkCanvas* Surface::onNewCanvas() { return new SkCanvas(fDevice); }
|
||||
|
||||
sk_sp<SkSurface> Surface::onNewSurface(const SkImageInfo& ii) {
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
Surface(sk_sp<Device>);
|
||||
~Surface() override;
|
||||
|
||||
Recorder* onGetRecorder() override;
|
||||
SkCanvas* onNewCanvas() override;
|
||||
sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
|
||||
sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override;
|
||||
|
@ -66,6 +66,8 @@ class SkSurface_Base;
|
||||
class SkTextBlob;
|
||||
class SkVertices;
|
||||
|
||||
namespace skgpu { class Recorder; }
|
||||
|
||||
/** \class SkCanvas
|
||||
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
|
||||
SkCanvas contains a stack of SkMatrix and clip values.
|
||||
@ -297,6 +299,12 @@ public:
|
||||
*/
|
||||
virtual GrRecordingContext* recordingContext();
|
||||
|
||||
/** Returns Recorder for the GPU surface associated with SkCanvas.
|
||||
|
||||
@return Recorder, if available; nullptr otherwise
|
||||
*/
|
||||
virtual skgpu::Recorder* recorder();
|
||||
|
||||
/** Sometimes a canvas is owned by a surface. If it is, getSurface() will return a bare
|
||||
* pointer to that surface, else this will return nullptr.
|
||||
*/
|
||||
|
@ -38,6 +38,8 @@ class GrRecordingContext;
|
||||
class GrRenderTarget;
|
||||
enum GrSurfaceOrigin: int;
|
||||
|
||||
namespace skgpu { class Recorder; }
|
||||
|
||||
/** \class SkSurface
|
||||
SkSurface is responsible for managing the pixels that a canvas draws into. The pixels can be
|
||||
allocated either in CPU memory (a raster surface) or on the GPU (a GrRenderTarget surface).
|
||||
@ -517,6 +519,12 @@ public:
|
||||
*/
|
||||
GrRecordingContext* recordingContext();
|
||||
|
||||
/** Returns the recorder being used by the SkSurface.
|
||||
|
||||
@return the recorder, if available; nullptr otherwise
|
||||
*/
|
||||
skgpu::Recorder* recorder();
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
enum BackendHandleAccess {
|
||||
kFlushRead_BackendHandleAccess, //!< back-end object is readable
|
||||
|
@ -62,6 +62,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
#include "experimental/graphite/src/Device.h"
|
||||
#endif
|
||||
|
||||
#define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0)
|
||||
#define RETURN_ON_FALSE(pred) do { if (!(pred)) return; } while (0)
|
||||
|
||||
@ -1706,7 +1710,7 @@ GrBackendRenderTarget SkCanvas::topLayerBackendRenderTarget() const {
|
||||
|
||||
GrRecordingContext* SkCanvas::recordingContext() {
|
||||
#if SK_SUPPORT_GPU
|
||||
if (auto gpuDevice = this->topDevice()->asGpuDevice()) {
|
||||
if (auto gpuDevice = this->topDevice()->asGaneshDevice()) {
|
||||
return gpuDevice->recordingContext();
|
||||
}
|
||||
#endif
|
||||
@ -1714,6 +1718,17 @@ GrRecordingContext* SkCanvas::recordingContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
skgpu::Recorder* SkCanvas::recorder() {
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
if (auto graphiteDevice = this->topDevice()->asGraphiteDevice()) {
|
||||
return graphiteDevice->recorder();
|
||||
}
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void SkCanvas::drawDRRect(const SkRRect& outer, const SkRRect& inner,
|
||||
const SkPaint& paint) {
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
|
@ -117,7 +117,7 @@ void SkCanvasPriv::DrawCustomMesh(SkCanvas* canvas,
|
||||
|
||||
#if SK_GPU_V1
|
||||
skgpu::v1::SurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanvas* canvas) {
|
||||
if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
|
||||
if (auto gpuDevice = canvas->topDevice()->asGaneshDevice()) {
|
||||
return gpuDevice->surfaceDrawContext();
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ skgpu::v1::SurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanva
|
||||
#endif // SK_GPU_V1
|
||||
|
||||
skgpu::SurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas) {
|
||||
if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
|
||||
if (auto gpuDevice = canvas->topDevice()->asGaneshDevice()) {
|
||||
return gpuDevice->surfaceFillContext();
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ skgpu::SurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* c
|
||||
#include "src/gpu/BaseDevice.h"
|
||||
|
||||
GrRenderTargetProxy* SkCanvasPriv::TopDeviceTargetProxy(SkCanvas* canvas) {
|
||||
if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
|
||||
if (auto gpuDevice = canvas->topDevice()->asGaneshDevice()) {
|
||||
return gpuDevice->targetProxy();
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,10 @@ class SkRasterHandleAllocator;
|
||||
class SkSpecialImage;
|
||||
|
||||
namespace skif { class Mapping; }
|
||||
namespace skgpu { class BaseDevice; }
|
||||
namespace skgpu {
|
||||
class BaseDevice;
|
||||
class Device;
|
||||
}
|
||||
|
||||
class SkBaseDevice : public SkRefCnt, public SkMatrixProvider {
|
||||
public:
|
||||
@ -188,7 +191,8 @@ public:
|
||||
|
||||
virtual bool android_utils_clipWithStencil() { return false; }
|
||||
|
||||
virtual skgpu::BaseDevice* asGpuDevice() { return nullptr; }
|
||||
virtual skgpu::BaseDevice* asGaneshDevice() { return nullptr; }
|
||||
virtual skgpu::Device* asGraphiteDevice() { return nullptr; }
|
||||
|
||||
// Ensure that non-RSXForm runs are passed to onDrawGlyphRunList.
|
||||
void drawGlyphRunList(SkCanvas*, const SkGlyphRunList& glyphRunList, const SkPaint& paint);
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
|
||||
GrSurfaceProxyView readSurfaceView();
|
||||
|
||||
BaseDevice* asGpuDevice() override { return this; }
|
||||
BaseDevice* asGaneshDevice() override { return this; }
|
||||
|
||||
#if SK_GPU_V1
|
||||
virtual v1::SurfaceDrawContext* surfaceDrawContext() { return nullptr; }
|
||||
|
@ -54,6 +54,10 @@ GrRecordingContext* SkSurface_Base::onGetRecordingContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
skgpu::Recorder* SkSurface_Base::onGetRecorder() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
GrBackendTexture SkSurface_Base::onGetBackendTexture(BackendHandleAccess) {
|
||||
return GrBackendTexture(); // invalid
|
||||
@ -318,6 +322,10 @@ GrRecordingContext* SkSurface::recordingContext() {
|
||||
return asSB(this)->onGetRecordingContext();
|
||||
}
|
||||
|
||||
skgpu::Recorder* SkSurface::recorder() {
|
||||
return asSB(this)->onGetRecorder();
|
||||
}
|
||||
|
||||
bool SkSurface::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
|
||||
bool deleteSemaphoresAfterWait) {
|
||||
return asSB(this)->onWait(numSemaphores, waitSemaphores, deleteSemaphoresAfterWait);
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
~SkSurface_Base() override;
|
||||
|
||||
virtual GrRecordingContext* onGetRecordingContext();
|
||||
virtual skgpu::Recorder* onGetRecorder();
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual GrBackendTexture onGetBackendTexture(BackendHandleAccess);
|
||||
|
Loading…
Reference in New Issue
Block a user