Miscellaneous skgpu::v2 backend updates

Bug: skia:11837
Change-Id: I334cdeb75db1a80a35d333faa26aec4999bd6bb6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449677
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2021-09-16 16:31:59 -04:00 committed by SkCQ
parent d0665d9a04
commit b42cea955f
8 changed files with 21 additions and 13 deletions

View File

@ -12,6 +12,7 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceProxyView.h"
#include "src/gpu/SurfaceContext.h"
#include "src/gpu/SurfaceFillContext.h"
#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(fContext->priv().singleOwner())
@ -24,6 +25,10 @@ BaseDevice::BaseDevice(sk_sp<GrRecordingContext> rContext,
, fContext(std::move(rContext)) {
}
GrSurfaceProxyView BaseDevice::readSurfaceView() {
return this->surfaceFillContext()->readSurfaceView();
}
/** Checks that the alpha type is legal and gets constructor flags. Returns false if device creation
should fail. */
bool BaseDevice::CheckAlphaTypeAndGetFlags(SkAlphaType alphaType,

View File

@ -23,6 +23,16 @@ class SurfaceFillContext;
namespace v1 { class SurfaceDrawContext; }
#endif // SK_GPU_V1
/*
* The most important thing to remember about this class hierarchy is there is no skgpu::SDC
* base class so the v1 and v2 Devices privately hold their own version of the SDC. The best
* the BaseDevice can do is to return the SDC-variant as a generic SFC.
*
* skgpu::BaseDevice
* / \
* v1::Device v2::Device
* - v1::SDC - v2::SDC
*/
class BaseDevice : public SkBaseDevice {
public:
enum class InitContents {
@ -32,7 +42,7 @@ public:
BaseDevice(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&);
virtual GrSurfaceProxyView readSurfaceView() = 0;
GrSurfaceProxyView readSurfaceView();
BaseDevice* asGpuDevice() override { return this; }

View File

@ -28,12 +28,8 @@ namespace skgpu::v1 {
/**
* Subclass of BaseDevice, which directs all drawing to the GrGpu owned by the canvas.
*/
class Device : public BaseDevice {
class Device final : public BaseDevice {
public:
GrSurfaceProxyView readSurfaceView() override {
return fSurfaceDrawContext->readSurfaceView();
}
bool wait(int numSemaphores,
const GrBackendSemaphore* waitSemaphores,
bool deleteSemaphoresAfterWait) override;

View File

@ -118,10 +118,6 @@ public:
GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
SkBudgeted = SkBudgeted::kYes);
// These match the definitions in SkSurface & GrSurface.h, for whence they came
typedef void* ReleaseContext;
typedef void (*ReleaseProc)(ReleaseContext);
// Creates a SurfaceDrawContext that wraps the passed in GrBackendTexture.
static std::unique_ptr<SurfaceDrawContext> MakeFromBackendTexture(
GrRecordingContext*,

View File

@ -104,8 +104,6 @@ Device::~Device() {}
skgpu::SurfaceFillContext* Device::surfaceFillContext() { return fSurfaceDrawContext.get(); }
GrSurfaceProxyView Device::readSurfaceView() { return {}; }
void Device::asyncRescaleAndReadPixels(const SkImageInfo& info,
const SkIRect& srcRect,
RescaleGamma rescaleGamma,

View File

@ -41,7 +41,6 @@ public:
~Device() override;
skgpu::SurfaceFillContext* surfaceFillContext() override;
GrSurfaceProxyView readSurfaceView() override;
bool wait(int numSemaphores,
const GrBackendSemaphore* waitSemaphores,

View File

@ -89,4 +89,6 @@ SurfaceDrawContext::SurfaceDrawContext(GrRecordingContext* rContext,
, fSurfaceProps(surfaceProps) {
}
SurfaceDrawContext::~SurfaceDrawContext() {}
} // namespace skgpu::v2

View File

@ -14,6 +14,8 @@ namespace skgpu::v2 {
class SurfaceDrawContext final : public SurfaceFillContext {
public:
~SurfaceDrawContext() override;
static std::unique_ptr<SurfaceDrawContext> Make(GrRecordingContext*,
GrColorType,
sk_sp<GrSurfaceProxy>,