Start using skgpu::v1 and skgpu::v2 namespaces
Bug: skia:11837
Change-Id: I042775dae34c99c20048d6d70aa6f06b2a6a268b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424117
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/gm/trickycubicstrokes.cpp b/gm/trickycubicstrokes.cpp
index f09f03c..059edea 100644
--- a/gm/trickycubicstrokes.cpp
+++ b/gm/trickycubicstrokes.cpp
@@ -20,6 +20,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/utils/SkRandom.h"
#include "src/core/SkGeometry.h"
+#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrDrawingManager.h"
#include "src/gpu/GrRecordingContextPriv.h"
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 4ba87a4..bedc370 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -477,8 +477,8 @@
"$_src/gpu/mock/GrMockTypes.cpp",
# Sk files
- "$_src/gpu/SkBaseGpuDevice.cpp",
- "$_src/gpu/SkBaseGpuDevice.h",
+ "$_src/gpu/BaseDevice.cpp",
+ "$_src/gpu/BaseDevice.h",
"$_src/gpu/SkGr.cpp",
"$_src/gpu/SkGr.h",
"$_src/image/SkImage_Gpu.cpp",
@@ -553,8 +553,8 @@
skia_skgpu_v2_sources = [
# Sk files
- "$_src/gpu/SkGpuDevice_nga.cpp",
- "$_src/gpu/SkGpuDevice_nga.h",
+ "$_src/gpu/v2/Device.cpp",
+ "$_src/gpu/v2/Device_v2.h",
]
skia_skgpu_v1_sources = [
@@ -594,9 +594,9 @@
"$_src/gpu/tessellate/GrTessellationPathRenderer.cpp",
# Sk files
- "$_src/gpu/SkGpuDevice.cpp",
- "$_src/gpu/SkGpuDevice.h",
- "$_src/gpu/SkGpuDevice_drawTexture.cpp",
+ "$_src/gpu/v1/Device.cpp",
+ "$_src/gpu/v1/Device_drawTexture.cpp",
+ "$_src/gpu/v1/Device_v1.h",
]
skia_gpu_sources += skia_skgpu_v1_sources
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index f442ca3..bae4681 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -188,7 +188,7 @@
fCharacterization.refColorSpace(),
fCharacterization.origin(),
fCharacterization.surfaceProps(),
- SkBaseGpuDevice::kUninit_InitContents);
+ skgpu::BaseDevice::kUninit_InitContents);
if (!device) {
return false;
}
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 964670b..2234b3c 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -123,7 +123,7 @@
class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
public:
- SkSpecialSurface_Gpu(sk_sp<SkBaseGpuDevice> device, SkIRect subset)
+ SkSpecialSurface_Gpu(sk_sp<skgpu::BaseDevice> device, SkIRect subset)
: INHERITED(subset, device->surfaceProps())
, fReadView(device->readSurfaceView()) {
@@ -165,7 +165,7 @@
auto device = rContext->priv().createDevice(SkBudgeted::kYes, ii, SkBackingFit::kApprox, 1,
GrMipmapped::kNo, GrProtected::kNo,
kBottomLeft_GrSurfaceOrigin, props,
- SkBaseGpuDevice::kUninit_InitContents);
+ skgpu::BaseDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
diff --git a/src/gpu/SkBaseGpuDevice.cpp b/src/gpu/BaseDevice.cpp
similarity index 86%
rename from src/gpu/SkBaseGpuDevice.cpp
rename to src/gpu/BaseDevice.cpp
index 35e3fdf..4da8e99 100644
--- a/src/gpu/SkBaseGpuDevice.cpp
+++ b/src/gpu/BaseDevice.cpp
@@ -5,15 +5,22 @@
* found in the LICENSE file.
*/
-#include "src/gpu/SkBaseGpuDevice.h"
+#include "src/gpu/BaseDevice.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
+#include "src/gpu/GrSurfaceProxyView.h"
#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(fContext->priv().singleOwner())
-bool SkBaseGpuDevice::replaceBackingProxy(SkSurface::ContentChangeMode mode) {
+namespace skgpu {
+
+GrRenderTargetProxy* BaseDevice::targetProxy() {
+ return this->readSurfaceView().asRenderTargetProxy();
+}
+
+bool BaseDevice::replaceBackingProxy(SkSurface::ContentChangeMode mode) {
ASSERT_SINGLE_OWNER
const SkImageInfo& ii = this->imageInfo();
@@ -45,3 +52,5 @@
grColorType, ii.refColorSpace(), oldView.origin(),
this->surfaceProps());
}
+
+} // namespace skgpu
diff --git a/src/gpu/SkBaseGpuDevice.h b/src/gpu/BaseDevice.h
similarity index 88%
rename from src/gpu/SkBaseGpuDevice.h
rename to src/gpu/BaseDevice.h
index b448922..fbd28c5 100644
--- a/src/gpu/SkBaseGpuDevice.h
+++ b/src/gpu/BaseDevice.h
@@ -5,12 +5,13 @@
* found in the LICENSE file.
*/
-#ifndef SkBaseGpuDevice_DEFINED
-#define SkBaseGpuDevice_DEFINED
-
-#include "src/gpu/GrSurfaceProxyView.h"
+#ifndef BaseDevice_DEFINED
+#define BaseDevice_DEFINED
#include "include/core/SkImage.h"
+#include "include/private/GrTypesPriv.h"
+
+class GrSurfaceProxyView;
// NOTE: when not defined, SkGpuDevice extends SkBaseDevice directly and manages its clip stack
// using GrClipStack. When false, SkGpuDevice continues to extend SkClipStackDevice and uses
@@ -30,24 +31,24 @@
#define BASE_DEVICE SkClipStackDevice
#endif
-class SkBaseGpuDevice : public BASE_DEVICE {
+namespace skgpu {
+
+class BaseDevice : public BASE_DEVICE {
public:
enum InitContents {
kClear_InitContents,
kUninit_InitContents
};
- SkBaseGpuDevice(sk_sp<GrRecordingContext> rContext,
- const SkImageInfo& ii,
- const SkSurfaceProps& props)
+ 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 {
- return this->readSurfaceView().asRenderTargetProxy();
- }
+ GrRenderTargetProxy* targetProxy() override;
GrRecordingContext* recordingContext() const override { return fContext.get(); }
@@ -92,6 +93,8 @@
using INHERITED = BASE_DEVICE;
};
+} // namespace skgpu
+
#undef BASE_DEVICE
-#endif
+#endif // BaseDevice_DEFINED
diff --git a/src/gpu/GrDirectContextPriv.cpp b/src/gpu/GrDirectContextPriv.cpp
index b00a1a2..7e52bb6 100644
--- a/src/gpu/GrDirectContextPriv.cpp
+++ b/src/gpu/GrDirectContextPriv.cpp
@@ -227,26 +227,26 @@
return GrConfigConversionEffect::Make(std::move(fp), PMConversion::kToPremul);
}
-sk_sp<SkBaseGpuDevice> GrDirectContextPriv::createDevice(GrColorType colorType,
- sk_sp<GrSurfaceProxy> proxy,
- sk_sp<SkColorSpace> colorSpace,
- GrSurfaceOrigin origin,
- const SkSurfaceProps& props,
- SkBaseGpuDevice::InitContents init) {
+sk_sp<skgpu::BaseDevice> GrDirectContextPriv::createDevice(GrColorType colorType,
+ sk_sp<GrSurfaceProxy> proxy,
+ sk_sp<SkColorSpace> colorSpace,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps& props,
+ skgpu::BaseDevice::InitContents init) {
return fContext->GrRecordingContext::priv().createDevice(colorType, std::move(proxy),
std::move(colorSpace),
origin, props, init);
}
-sk_sp<SkBaseGpuDevice> GrDirectContextPriv::createDevice(SkBudgeted budgeted,
- const SkImageInfo& ii,
- SkBackingFit fit,
- int sampleCount,
- GrMipmapped mipmapped,
- GrProtected isProtected,
- GrSurfaceOrigin origin,
- const SkSurfaceProps& props,
- SkBaseGpuDevice::InitContents init) {
+sk_sp<skgpu::BaseDevice> GrDirectContextPriv::createDevice(SkBudgeted budgeted,
+ const SkImageInfo& ii,
+ SkBackingFit fit,
+ int sampleCount,
+ GrMipmapped mipmapped,
+ GrProtected isProtected,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps& props,
+ skgpu::BaseDevice::InitContents init) {
return fContext->GrRecordingContext::priv().createDevice(budgeted, ii, fit, sampleCount,
mipmapped, isProtected,
origin, props, init);
diff --git a/src/gpu/GrDirectContextPriv.h b/src/gpu/GrDirectContextPriv.h
index fd8f9af..c3cb84a 100644
--- a/src/gpu/GrDirectContextPriv.h
+++ b/src/gpu/GrDirectContextPriv.h
@@ -11,7 +11,7 @@
#include "include/core/SkSpan.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrDirectContext.h"
-#include "src/gpu/SkBaseGpuDevice.h"
+#include "src/gpu/BaseDevice.h"
class GrAtlasManager;
class GrBackendFormat;
@@ -146,21 +146,21 @@
return fContext->fMappedBufferManager.get();
}
- sk_sp<SkBaseGpuDevice> createDevice(GrColorType,
- sk_sp<GrSurfaceProxy>,
- sk_sp<SkColorSpace>,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- SkBaseGpuDevice::InitContents);
- sk_sp<SkBaseGpuDevice> createDevice(SkBudgeted,
- const SkImageInfo&,
- SkBackingFit,
- int sampleCount,
- GrMipmapped,
- GrProtected,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- SkBaseGpuDevice::InitContents);
+ sk_sp<skgpu::BaseDevice> createDevice(GrColorType,
+ sk_sp<GrSurfaceProxy>,
+ sk_sp<SkColorSpace>,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ skgpu::BaseDevice::InitContents);
+ sk_sp<skgpu::BaseDevice> createDevice(SkBudgeted,
+ const SkImageInfo&,
+ SkBackingFit,
+ int sampleCount,
+ GrMipmapped,
+ GrProtected,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ skgpu::BaseDevice::InitContents);
#if GR_TEST_UTILS
/** Reset GPU stats */
diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp
index b4c673f..bf7ddd1 100644
--- a/src/gpu/GrProcessorUnitTest.cpp
+++ b/src/gpu/GrProcessorUnitTest.cpp
@@ -12,6 +12,7 @@
#include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrRecordingContextPriv.h"
+#include "src/gpu/GrSurfaceProxyView.h"
#if GR_TEST_UTILS
diff --git a/src/gpu/GrRecordingContextPriv.cpp b/src/gpu/GrRecordingContextPriv.cpp
index 5e032ff..47a0911 100644
--- a/src/gpu/GrRecordingContextPriv.cpp
+++ b/src/gpu/GrRecordingContextPriv.cpp
@@ -11,23 +11,23 @@
#include "src/gpu/GrDrawingManager.h"
#if SK_GPU_V1
-#include "src/gpu/SkGpuDevice.h"
+#include "src/gpu/v1/Device_v1.h"
#endif
#if SK_GPU_V2
-#include "src/gpu/SkGpuDevice_nga.h"
+#include "src/gpu/v2/Device_v2.h"
#endif
-sk_sp<SkBaseGpuDevice> GrRecordingContextPriv::createDevice(GrColorType colorType,
- sk_sp<GrSurfaceProxy> proxy,
- sk_sp<SkColorSpace> colorSpace,
- GrSurfaceOrigin origin,
- const SkSurfaceProps& props,
- SkBaseGpuDevice::InitContents init) {
+sk_sp<skgpu::BaseDevice> GrRecordingContextPriv::createDevice(GrColorType colorType,
+ sk_sp<GrSurfaceProxy> proxy,
+ sk_sp<SkColorSpace> colorSpace,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps& props,
+ skgpu::BaseDevice::InitContents init) {
#if GR_TEST_UTILS
if (this->options().fUseNGA == GrContextOptions::Enable::kYes) {
#if SK_GPU_V2
- return SkGpuDevice_nga::Make(fContext, colorType, std::move(proxy), std::move(colorSpace),
- origin, props, init);
+ return skgpu::v2::Device::Make(fContext, colorType, std::move(proxy), std::move(colorSpace),
+ origin, props, init);
#else
return nullptr;
#endif
@@ -35,28 +35,28 @@
#endif
{
#if SK_GPU_V1
- return SkGpuDevice::Make(fContext, colorType, std::move(proxy), std::move(colorSpace),
- origin, props, init);
+ return skgpu::v1::Device::Make(fContext, colorType, std::move(proxy), std::move(colorSpace),
+ origin, props, init);
#else
return nullptr;
#endif
}
}
-sk_sp<SkBaseGpuDevice> GrRecordingContextPriv::createDevice(SkBudgeted budgeted,
- const SkImageInfo& ii,
- SkBackingFit fit,
- int sampleCount,
- GrMipmapped mipmapped,
- GrProtected isProtected,
- GrSurfaceOrigin origin,
- const SkSurfaceProps& props,
- SkBaseGpuDevice::InitContents init) {
+sk_sp<skgpu::BaseDevice> GrRecordingContextPriv::createDevice(SkBudgeted budgeted,
+ const SkImageInfo& ii,
+ SkBackingFit fit,
+ int sampleCount,
+ GrMipmapped mipmapped,
+ GrProtected isProtected,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps& props,
+ skgpu::BaseDevice::InitContents init) {
#if GR_TEST_UTILS
if (this->options().fUseNGA == GrContextOptions::Enable::kYes) {
#if SK_GPU_V2
- return SkGpuDevice_nga::Make(fContext, budgeted, ii, fit, sampleCount,
- mipmapped, isProtected, origin, props, init);
+ return skgpu::v2::Device::Make(fContext, budgeted, ii, fit, sampleCount,
+ mipmapped, isProtected, origin, props, init);
#else
return nullptr;
#endif
@@ -64,8 +64,8 @@
#endif
{
#if SK_GPU_V1
- return SkGpuDevice::Make(fContext, budgeted, ii, fit, sampleCount,
- mipmapped, isProtected, origin, props, init);
+ return skgpu::v1::Device::Make(fContext, budgeted, ii, fit, sampleCount,
+ mipmapped, isProtected, origin, props, init);
#else
return nullptr;
#endif
diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h
index cf3205e..21f5467 100644
--- a/src/gpu/GrRecordingContextPriv.h
+++ b/src/gpu/GrRecordingContextPriv.h
@@ -10,7 +10,7 @@
#include "include/core/SkPaint.h"
#include "include/gpu/GrRecordingContext.h"
-#include "src/gpu/SkBaseGpuDevice.h"
+#include "src/gpu/BaseDevice.h"
#include "src/gpu/text/GrSDFTControl.h"
class SkDeferredDisplayList;
@@ -118,21 +118,21 @@
*/
static sk_sp<GrRecordingContext> MakeDDL(sk_sp<GrContextThreadSafeProxy>);
- sk_sp<SkBaseGpuDevice> createDevice(GrColorType,
- sk_sp<GrSurfaceProxy>,
- sk_sp<SkColorSpace>,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- SkBaseGpuDevice::InitContents);
- sk_sp<SkBaseGpuDevice> createDevice(SkBudgeted,
- const SkImageInfo&,
- SkBackingFit,
- int sampleCount,
- GrMipmapped,
- GrProtected,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- SkBaseGpuDevice::InitContents);
+ sk_sp<skgpu::BaseDevice> createDevice(GrColorType,
+ sk_sp<GrSurfaceProxy>,
+ sk_sp<SkColorSpace>,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ skgpu::BaseDevice::InitContents);
+ sk_sp<skgpu::BaseDevice> createDevice(SkBudgeted,
+ const SkImageInfo&,
+ SkBackingFit,
+ int sampleCount,
+ GrMipmapped,
+ GrProtected,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ skgpu::BaseDevice::InitContents);
private:
explicit GrRecordingContextPriv(GrRecordingContext* context) : fContext(context) {}
diff --git a/src/gpu/SkGpuDevice_nga.cpp b/src/gpu/SkGpuDevice_nga.cpp
deleted file mode 100644
index 51e6017..0000000
--- a/src/gpu/SkGpuDevice_nga.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright 2021 Google LLC
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "src/gpu/SkGpuDevice_nga.h"
-
-#include "include/gpu/GrRecordingContext.h"
-#include "src/core/SkImageFilterCache.h"
-#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/GrTracing.h"
-
-#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(fContext->priv().singleOwner())
-
-SkGpuDevice_nga::SkGpuDevice_nga(sk_sp<GrRecordingContext> rContext,
- const SkImageInfo& ii,
- const SkSurfaceProps& props)
- : INHERITED(std::move(rContext), ii, props) {
-}
-
-SkGpuDevice_nga::~SkGpuDevice_nga() {}
-
-void SkGpuDevice_nga::asyncRescaleAndReadPixels(const SkImageInfo& info,
- const SkIRect& srcRect,
- RescaleGamma rescaleGamma,
- RescaleMode rescaleMode,
- ReadPixelsCallback callback,
- ReadPixelsContext context) {
- // Context TODO: Elevate direct context requirement to public API.
- auto dContext = this->recordingContext()->asDirectContext();
- if (!dContext) {
- return;
- }
-}
-
-void SkGpuDevice_nga::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
- sk_sp<SkColorSpace> dstColorSpace,
- const SkIRect& srcRect,
- SkISize dstSize,
- RescaleGamma rescaleGamma,
- RescaleMode,
- ReadPixelsCallback callback,
- ReadPixelsContext context) {
- // Context TODO: Elevate direct context requirement to public API.
- auto dContext = this->recordingContext()->asDirectContext();
- if (!dContext) {
- return;
- }
-}
-
-void SkGpuDevice_nga::onSave() {
-}
-
-void SkGpuDevice_nga::onRestore() {
-}
-
-void SkGpuDevice_nga::onClipRect(const SkRect& rect, SkClipOp op, bool aa) {
-}
-
-void SkGpuDevice_nga::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
-}
-
-void SkGpuDevice_nga::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
- SkASSERT(op == SkClipOp::kIntersect || op == SkClipOp::kDifference);
-}
-
-void SkGpuDevice_nga::onClipShader(sk_sp<SkShader> shader) {
-}
-
-void SkGpuDevice_nga::onClipRegion(const SkRegion& globalRgn, SkClipOp op) {
- SkASSERT(op == SkClipOp::kIntersect || op == SkClipOp::kDifference);
-}
-
-void SkGpuDevice_nga::onReplaceClip(const SkIRect& rect) {
-}
-
-void SkGpuDevice_nga::onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) {
-}
-
-bool SkGpuDevice_nga::onClipIsAA() const {
- return false;
-}
-
-bool SkGpuDevice_nga::onClipIsWideOpen() const {
- return false;
-}
-
-void SkGpuDevice_nga::onAsRgnClip(SkRegion* region) const {
-}
-
-SkBaseDevice::ClipType SkGpuDevice_nga::onGetClipType() const {
- return ClipType::kEmpty;
-}
-
-SkIRect SkGpuDevice_nga::onDevClipBounds() const {
- return SkIRect::MakeEmpty();
-}
-
-void SkGpuDevice_nga::drawPaint(const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawPaint", fContext.get());
-}
-
-void SkGpuDevice_nga::drawPoints(SkCanvas::PointMode mode,
- size_t count,
- const SkPoint points[],
- const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawPoints", fContext.get());
-
-}
-
-void SkGpuDevice_nga::drawRect(const SkRect& rect, const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawRect", fContext.get());
-}
-
-void SkGpuDevice_nga::drawRegion(const SkRegion& r, const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawRegion", fContext.get());
-}
-
-void SkGpuDevice_nga::drawOval(const SkRect& oval, const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawOval", fContext.get());
-}
-
-void SkGpuDevice_nga::drawArc(const SkRect& oval,
- SkScalar startAngle,
- SkScalar sweepAngle,
- bool useCenter,
- const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawArc", fContext.get());
-}
-
-void SkGpuDevice_nga::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawRRect", fContext.get());
-}
-
-void SkGpuDevice_nga::drawDRRect(const SkRRect& outer,
- const SkRRect& inner,
- const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawDRRect", fContext.get());
-}
-
-void SkGpuDevice_nga::drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawPath", fContext.get());
-}
-
-void SkGpuDevice_nga::drawImageRect(const SkImage* image,
- const SkRect* src,
- const SkRect& dst,
- const SkSamplingOptions& sampling,
- const SkPaint& paint,
- SkCanvas::SrcRectConstraint constraint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawImageRect", fContext.get());
-}
-
-void SkGpuDevice_nga::drawImageLattice(const SkImage* image,
- const SkCanvas::Lattice& lattice,
- const SkRect& dst,
- SkFilterMode filter,
- const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawImageLattice", fContext.get());
-}
-
-void SkGpuDevice_nga::drawVertices(const SkVertices* vertices,
- SkBlendMode mode,
- const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawVertices", fContext.get());
-}
-
-void SkGpuDevice_nga::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawShadow", fContext.get());
-}
-
-void SkGpuDevice_nga::drawAtlas(const SkImage* atlas,
- const SkRSXform xform[],
- const SkRect texRect[],
- const SkColor colors[],
- int count,
- SkBlendMode mode,
- const SkSamplingOptions& sampling,
- const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawAtlas", fContext.get());
-}
-
-void SkGpuDevice_nga::drawEdgeAAQuad(const SkRect& rect,
- const SkPoint clip[4],
- SkCanvas::QuadAAFlags aaFlags,
- const SkColor4f& color,
- SkBlendMode mode) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawEdgeAAQuad", fContext.get());
-}
-
-void SkGpuDevice_nga::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[],
- int count,
- const SkPoint dstClips[],
- const SkMatrix preViewMatrices[],
- const SkSamplingOptions& sampling,
- const SkPaint& paint,
- SkCanvas::SrcRectConstraint constraint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawEdgeAAImageSet", fContext.get());
-}
-
-void SkGpuDevice_nga::drawDrawable(SkDrawable* drawable,
- const SkMatrix* matrix,
- SkCanvas* canvas) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawDrawable", fContext.get());
-
- this->INHERITED::drawDrawable(drawable, matrix, canvas);
-}
-
-void SkGpuDevice_nga::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "onDrawGlyphRunList", fContext.get());
-}
-
-void SkGpuDevice_nga::drawDevice(SkBaseDevice* device,
- const SkSamplingOptions& sampling,
- const SkPaint& paint) {
- ASSERT_SINGLE_OWNER
- GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawDevice", fContext.get());
-}
-
-void SkGpuDevice_nga::drawSpecial(SkSpecialImage* special,
- const SkMatrix& localToDevice,
- const SkSamplingOptions& sampling,
- const SkPaint& paint) {
-}
-
-sk_sp<SkSpecialImage> SkGpuDevice_nga::makeSpecial(const SkBitmap& bitmap) {
- ASSERT_SINGLE_OWNER
- return nullptr;
-}
-
-sk_sp<SkSpecialImage> SkGpuDevice_nga::makeSpecial(const SkImage* image) {
- ASSERT_SINGLE_OWNER
- return nullptr;
-}
-
-sk_sp<SkSpecialImage> SkGpuDevice_nga::snapSpecial(const SkIRect& subset, bool forceCopy) {
- ASSERT_SINGLE_OWNER
- return nullptr;
-}
-
-sk_sp<SkSurface> SkGpuDevice_nga::makeSurface(const SkImageInfo& ii,
- const SkSurfaceProps& props) {
- ASSERT_SINGLE_OWNER
- return nullptr;
-}
-
-bool SkGpuDevice_nga::onReadPixels(const SkPixmap& pm, int x, int y) {
- ASSERT_SINGLE_OWNER
- return false;
-}
-
-bool SkGpuDevice_nga::onWritePixels(const SkPixmap& pm, int x, int y) {
- ASSERT_SINGLE_OWNER
- return false;
-}
-
-bool SkGpuDevice_nga::onAccessPixels(SkPixmap*) {
- ASSERT_SINGLE_OWNER
- return false;
-}
-
-SkBaseDevice* SkGpuDevice_nga::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) {
- ASSERT_SINGLE_OWNER
- return nullptr;
-}
-
-bool SkGpuDevice_nga::forceConservativeRasterClip() const {
- return true;
-}
-
-SkImageFilterCache* SkGpuDevice_nga::getImageFilterCache() {
- ASSERT_SINGLE_OWNER
-
- // We always return a transient cache, so it is freed after each filter traversal.
- return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize);
-}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/v1/Device.cpp
similarity index 81%
rename from src/gpu/SkGpuDevice.cpp
rename to src/gpu/v1/Device.cpp
index caead27..a73463a 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/v1/Device.cpp
@@ -5,9 +5,10 @@
* found in the LICENSE file.
*/
-#include "src/gpu/SkGpuDevice.h"
+#include "src/gpu/v1/Device_v1.h"
#include "include/core/SkImageFilter.h"
+#include "include/core/SkMaskFilter.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkPicture.h"
#include "include/core/SkSurface.h"
@@ -50,17 +51,92 @@
///////////////////////////////////////////////////////////////////////////////
+namespace {
+
+SkImageInfo make_info(GrSurfaceDrawContext* context, bool opaque) {
+ SkColorType colorType = GrColorTypeToSkColorType(context->colorInfo().colorType());
+ return SkImageInfo::Make(context->width(), context->height(), colorType,
+ opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
+ context->colorInfo().refColorSpace());
+}
+
+#if !defined(SK_DISABLE_NEW_GR_CLIP_STACK)
+bool force_aa_clip(const GrSurfaceDrawContext* sdc) {
+ return (sdc->numSamples() > 1 && !sdc->caps()->multisampleDisableSupport()) ||
+ sdc->alwaysAntialias();
+}
+#endif
+
+inline GrPrimitiveType point_mode_to_primitive_type(SkCanvas::PointMode mode) {
+ switch (mode) {
+ case SkCanvas::kPoints_PointMode:
+ return GrPrimitiveType::kPoints;
+ case SkCanvas::kLines_PointMode:
+ return GrPrimitiveType::kLines;
+ case SkCanvas::kPolygon_PointMode:
+ return GrPrimitiveType::kLineStrip;
+ }
+ SK_ABORT("Unexpected mode");
+}
+
+std::unique_ptr<GrFragmentProcessor> make_inverse_rrect_fp(const SkMatrix& viewMatrix,
+ const SkRRect& rrect, GrAA aa,
+ const GrShaderCaps& shaderCaps) {
+ SkTCopyOnFirstWrite<SkRRect> devRRect(rrect);
+ if (viewMatrix.isIdentity() || rrect.transform(viewMatrix, devRRect.writable())) {
+ auto edgeType = (aa == GrAA::kYes) ? GrClipEdgeType::kInverseFillAA
+ : GrClipEdgeType::kInverseFillBW;
+ auto [success, fp] = GrRRectEffect::Make(/*inputFP=*/nullptr, edgeType, *devRRect,
+ shaderCaps);
+ return (success) ? std::move(fp) : nullptr;
+ }
+ return nullptr;
+}
+
+bool init_vertices_paint(GrRecordingContext* context,
+ const GrColorInfo& colorInfo,
+ const SkPaint& skPaint,
+ const SkMatrixProvider& matrixProvider,
+ SkBlendMode bmode,
+ bool hasColors,
+ GrPaint* grPaint) {
+ if (skPaint.getShader()) {
+ if (hasColors) {
+ // When there are colors and a shader, the shader and colors are combined using bmode.
+ return SkPaintToGrPaintWithBlend(context, colorInfo, skPaint, matrixProvider, bmode,
+ grPaint);
+ } else {
+ // We have a shader, but no colors to blend it against.
+ return SkPaintToGrPaint(context, colorInfo, skPaint, matrixProvider, grPaint);
+ }
+ } else {
+ if (hasColors) {
+ // We have colors, but no shader.
+ return SkPaintToGrPaintWithPrimitiveColor(context, colorInfo, skPaint, matrixProvider,
+ grPaint);
+ } else {
+ // No colors and no shader. Just draw with the paint color.
+ return SkPaintToGrPaintNoShader(context, colorInfo, skPaint, matrixProvider, grPaint);
+ }
+ }
+}
+
+} // anonymous namespace
+
+namespace skgpu::v1 {
+
/** Checks that the alpha type is legal and gets constructor flags. Returns false if device creation
should fail. */
-bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
- const SkImageInfo* info, SkGpuDevice::InitContents init, unsigned* flags) {
+bool Device::CheckAlphaTypeAndGetFlags(const SkImageInfo* info,
+ Device::InitContents init,
+ unsigned* flags) {
*flags = 0;
if (info) {
switch (info->alphaType()) {
case kPremul_SkAlphaType:
break;
case kOpaque_SkAlphaType:
- *flags |= SkGpuDevice::kIsOpaque_Flag;
+ *flags |= Device::kIsOpaque_Flag;
break;
default: // If it is unpremul or unknown don't try to render
return false;
@@ -72,13 +148,13 @@
return true;
}
-sk_sp<SkBaseGpuDevice> SkGpuDevice::Make(GrRecordingContext* rContext,
- GrColorType colorType,
- sk_sp<GrSurfaceProxy> proxy,
- sk_sp<SkColorSpace> colorSpace,
- GrSurfaceOrigin origin,
- const SkSurfaceProps& surfaceProps,
- InitContents init) {
+sk_sp<BaseDevice> Device::Make(GrRecordingContext* rContext,
+ GrColorType colorType,
+ sk_sp<GrSurfaceProxy> proxy,
+ sk_sp<SkColorSpace> colorSpace,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps& surfaceProps,
+ InitContents init) {
auto sdc = GrSurfaceDrawContext::Make(rContext,
colorType,
std::move(proxy),
@@ -86,12 +162,12 @@
origin,
surfaceProps);
- return SkGpuDevice::Make(std::move(sdc), nullptr, init);
+ return Device::Make(std::move(sdc), nullptr, init);
}
-sk_sp<SkBaseGpuDevice> SkGpuDevice::Make(std::unique_ptr<GrSurfaceDrawContext> sdc,
- const SkImageInfo* ii,
- InitContents init) {
+sk_sp<BaseDevice> Device::Make(std::unique_ptr<GrSurfaceDrawContext> sdc,
+ const SkImageInfo* ii,
+ InitContents init) {
if (!sdc) {
return nullptr;
}
@@ -108,19 +184,19 @@
!CheckAlphaTypeAndGetFlags(ii, init, &flags)) {
return nullptr;
}
- return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(sdc), flags));
+ return sk_sp<Device>(new Device(std::move(sdc), flags));
}
-sk_sp<SkBaseGpuDevice> SkGpuDevice::Make(GrRecordingContext* rContext,
- SkBudgeted budgeted,
- const SkImageInfo& ii,
- SkBackingFit fit,
- int sampleCount,
- GrMipmapped mipMapped,
- GrProtected isProtected,
- GrSurfaceOrigin origin,
- const SkSurfaceProps& props,
- InitContents init) {
+sk_sp<BaseDevice> Device::Make(GrRecordingContext* rContext,
+ SkBudgeted budgeted,
+ const SkImageInfo& ii,
+ SkBackingFit fit,
+ int sampleCount,
+ GrMipmapped mipMapped,
+ GrProtected isProtected,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps& props,
+ InitContents init) {
auto sdc = MakeSurfaceDrawContext(rContext,
budgeted,
ii,
@@ -131,24 +207,10 @@
origin,
props);
- return SkGpuDevice::Make(std::move(sdc), &ii, init);
+ return Device::Make(std::move(sdc), &ii, init);
}
-static SkImageInfo make_info(GrSurfaceDrawContext* context, bool opaque) {
- SkColorType colorType = GrColorTypeToSkColorType(context->colorInfo().colorType());
- return SkImageInfo::Make(context->width(), context->height(), colorType,
- opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
- context->colorInfo().refColorSpace());
-}
-
-#if !defined(SK_DISABLE_NEW_GR_CLIP_STACK)
-static bool force_aa_clip(const GrSurfaceDrawContext* sdc) {
- return (sdc->numSamples() > 1 && !sdc->caps()->multisampleDisableSupport()) ||
- sdc->alwaysAntialias();
-}
-#endif
-
-SkGpuDevice::SkGpuDevice(std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext, unsigned flags)
+Device::Device(std::unique_ptr<GrSurfaceDrawContext> surfaceDrawContext, unsigned flags)
: INHERITED(sk_ref_sp(surfaceDrawContext->recordingContext()),
make_info(surfaceDrawContext.get(), SkToBool(flags & kIsOpaque_Flag)),
surfaceDrawContext->surfaceProps())
@@ -165,7 +227,7 @@
}
}
-std::unique_ptr<GrSurfaceDrawContext> SkGpuDevice::MakeSurfaceDrawContext(
+std::unique_ptr<GrSurfaceDrawContext> Device::MakeSurfaceDrawContext(
GrRecordingContext* rContext,
SkBudgeted budgeted,
const SkImageInfo& origInfo,
@@ -189,7 +251,7 @@
///////////////////////////////////////////////////////////////////////////////
-bool SkGpuDevice::onReadPixels(const SkPixmap& pm, int x, int y) {
+bool Device::onReadPixels(const SkPixmap& pm, int x, int y) {
ASSERT_SINGLE_OWNER
// Context TODO: Elevate direct context requirement to public API
@@ -201,7 +263,7 @@
return fSurfaceDrawContext->readPixels(dContext, pm, {x, y});
}
-bool SkGpuDevice::onWritePixels(const SkPixmap& pm, int x, int y) {
+bool Device::onWritePixels(const SkPixmap& pm, int x, int y) {
ASSERT_SINGLE_OWNER
// Context TODO: Elevate direct context requirement to public API
@@ -213,22 +275,22 @@
return fSurfaceDrawContext->writePixels(dContext, pm, {x, y});
}
-bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) {
+bool Device::onAccessPixels(SkPixmap* pmap) {
ASSERT_SINGLE_OWNER
return false;
}
-GrSurfaceDrawContext* SkGpuDevice::surfaceDrawContext() {
+GrSurfaceDrawContext* Device::surfaceDrawContext() {
ASSERT_SINGLE_OWNER
return fSurfaceDrawContext.get();
}
-const GrSurfaceDrawContext* SkGpuDevice::surfaceDrawContext() const {
+const GrSurfaceDrawContext* Device::surfaceDrawContext() const {
ASSERT_SINGLE_OWNER
return fSurfaceDrawContext.get();
}
-void SkGpuDevice::clearAll() {
+void Device::clearAll() {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext.get());
@@ -240,7 +302,7 @@
#if !defined(SK_DISABLE_NEW_GR_CLIP_STACK)
-void SkGpuDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
+void Device::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
#if GR_TEST_UTILS
if (fContext->priv().options().fAllPathsVolatile && !path.isVolatile()) {
this->onClipPath(SkPath(path).setIsVolatile(true), op, aa);
@@ -251,7 +313,7 @@
fClip.clipPath(this->localToDevice(), path, GrAA(aa), op);
}
-void SkGpuDevice::onClipRegion(const SkRegion& globalRgn, SkClipOp op) {
+void Device::onClipRegion(const SkRegion& globalRgn, SkClipOp op) {
SkASSERT(op == SkClipOp::kIntersect || op == SkClipOp::kDifference);
// Regions don't actually need AA, but in DMSAA mode every clip element is antialiased.
@@ -268,7 +330,7 @@
}
}
-void SkGpuDevice::onAsRgnClip(SkRegion* region) const {
+void Device::onAsRgnClip(SkRegion* region) const {
SkRegion deviceBounds(fClip.getConservativeBounds());
for (const GrClipStack::Element& e : fClip) {
SkRegion tmp;
@@ -285,7 +347,7 @@
}
}
-bool SkGpuDevice::onClipIsAA() const {
+bool Device::onClipIsAA() const {
for (const GrClipStack::Element& e : fClip) {
if (e.fAA == GrAA::kYes) {
return true;
@@ -295,7 +357,7 @@
return false;
}
-SkBaseDevice::ClipType SkGpuDevice::onGetClipType() const {
+SkBaseDevice::ClipType Device::onGetClipType() const {
GrClipStack::ClipState state = fClip.clipState();
if (state == GrClipStack::ClipState::kEmpty) {
return ClipType::kEmpty;
@@ -311,7 +373,7 @@
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawPaint(const SkPaint& paint) {
+void Device::drawPaint(const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext.get());
@@ -324,20 +386,10 @@
fSurfaceDrawContext->drawPaint(this->clip(), std::move(grPaint), this->localToDevice());
}
-static inline GrPrimitiveType point_mode_to_primitive_type(SkCanvas::PointMode mode) {
- switch (mode) {
- case SkCanvas::kPoints_PointMode:
- return GrPrimitiveType::kPoints;
- case SkCanvas::kLines_PointMode:
- return GrPrimitiveType::kLines;
- case SkCanvas::kPolygon_PointMode:
- return GrPrimitiveType::kLineStrip;
- }
- SK_ABORT("Unexpected mode");
-}
-
-void SkGpuDevice::drawPoints(SkCanvas::PointMode mode,
- size_t count, const SkPoint pts[], const SkPaint& paint) {
+void Device::drawPoints(SkCanvas::PointMode mode,
+ size_t count,
+ const SkPoint pts[],
+ const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPoints", fContext.get());
SkScalar width = paint.getStrokeWidth();
@@ -408,7 +460,7 @@
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawRect(const SkRect& rect, const SkPaint& paint) {
+void Device::drawRect(const SkRect& rect, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRect", fContext.get());
@@ -434,9 +486,11 @@
&style);
}
-void SkGpuDevice::drawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
- SkCanvas::QuadAAFlags aaFlags, const SkColor4f& color,
- SkBlendMode mode) {
+void Device::drawEdgeAAQuad(const SkRect& rect,
+ const SkPoint clip[4],
+ SkCanvas::QuadAAFlags aaFlags,
+ const SkColor4f& color,
+ SkBlendMode mode) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawEdgeAAQuad", fContext.get());
@@ -463,7 +517,7 @@
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
+void Device::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext.get());
@@ -498,21 +552,7 @@
rrect, style);
}
-static std::unique_ptr<GrFragmentProcessor> make_inverse_rrect_fp(const SkMatrix& viewMatrix,
- const SkRRect& rrect, GrAA aa,
- const GrShaderCaps& shaderCaps) {
- SkTCopyOnFirstWrite<SkRRect> devRRect(rrect);
- if (viewMatrix.isIdentity() || rrect.transform(viewMatrix, devRRect.writable())) {
- auto edgeType = (aa == GrAA::kYes) ? GrClipEdgeType::kInverseFillAA
- : GrClipEdgeType::kInverseFillBW;
- auto [success, fp] = GrRRectEffect::Make(/*inputFP=*/nullptr, edgeType, *devRRect,
- shaderCaps);
- return (success) ? std::move(fp) : nullptr;
- }
- return nullptr;
-}
-
-void SkGpuDevice::drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
+void Device::drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext.get());
if (outer.isEmpty()) {
@@ -561,7 +601,7 @@
/////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
+void Device::drawRegion(const SkRegion& region, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
if (paint.getMaskFilter()) {
@@ -582,7 +622,7 @@
region, GrStyle(paint));
}
-void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
+void Device::drawOval(const SkRect& oval, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext.get());
@@ -603,8 +643,11 @@
GrStyle(paint));
}
-void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle,
- SkScalar sweepAngle, bool useCenter, const SkPaint& paint) {
+void Device::drawArc(const SkRect& oval,
+ SkScalar startAngle,
+ SkScalar sweepAngle,
+ bool useCenter,
+ const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawArc", fContext.get());
if (paint.getMaskFilter()) {
@@ -622,11 +665,9 @@
startAngle, sweepAngle, useCenter, GrStyle(paint));
}
-#include "include/core/SkMaskFilter.h"
-
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawPath(const SkPath& origSrcPath, const SkPaint& paint, bool pathIsMutable) {
+void Device::drawPath(const SkPath& origSrcPath, const SkPaint& paint, bool pathIsMutable) {
#if GR_TEST_UTILS
if (fContext->priv().options().fAllPathsVolatile && !origSrcPath.isVolatile()) {
this->drawPath(SkPath(origSrcPath).setIsVolatile(true), paint, true);
@@ -654,7 +695,7 @@
paint, this->asMatrixProvider(), shape);
}
-sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
+sk_sp<SkSpecialImage> Device::makeSpecial(const SkBitmap& bitmap) {
ASSERT_SINGLE_OWNER
// TODO: this makes a tight copy of 'bitmap' but it doesn't have to be (given SkSpecialImage's
@@ -677,7 +718,7 @@
this->surfaceProps());
}
-sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) {
+sk_sp<SkSpecialImage> Device::makeSpecial(const SkImage* image) {
ASSERT_SINGLE_OWNER
SkPixmap pm;
@@ -702,7 +743,7 @@
}
}
-sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial(const SkIRect& subset, bool forceCopy) {
+sk_sp<SkSpecialImage> Device::snapSpecial(const SkIRect& subset, bool forceCopy) {
ASSERT_SINGLE_OWNER
GrSurfaceDrawContext* sdc = fSurfaceDrawContext.get();
@@ -747,17 +788,21 @@
this->surfaceProps());
}
-void SkGpuDevice::drawDevice(SkBaseDevice* device, const SkSamplingOptions& sampling,
- const SkPaint& paint) {
+void Device::drawDevice(SkBaseDevice* device,
+ const SkSamplingOptions& sampling,
+ const SkPaint& paint) {
ASSERT_SINGLE_OWNER
// clear of the source device must occur before CHECK_SHOULD_DRAW
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext.get());
this->INHERITED::drawDevice(device, sampling, paint);
}
-void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkSamplingOptions& sampling, const SkPaint& paint,
- SkCanvas::SrcRectConstraint constraint) {
+void Device::drawImageRect(const SkImage* image,
+ const SkRect* src,
+ const SkRect& dst,
+ const SkSamplingOptions& sampling,
+ const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint) {
ASSERT_SINGLE_OWNER
GrAA aa = fSurfaceDrawContext->chooseAA(paint);
GrQuadAAFlags aaFlags = (aa == GrAA::kYes) ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
@@ -765,12 +810,12 @@
constraint);
}
-void SkGpuDevice::drawViewLattice(GrSurfaceProxyView view,
- const GrColorInfo& info,
- std::unique_ptr<SkLatticeIter> iter,
- const SkRect& dst,
- SkFilterMode filter,
- const SkPaint& origPaint) {
+void Device::drawViewLattice(GrSurfaceProxyView view,
+ const GrColorInfo& info,
+ std::unique_ptr<SkLatticeIter> iter,
+ const SkRect& dst,
+ SkFilterMode filter,
+ const SkPaint& origPaint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawViewLattice", fContext.get());
SkASSERT(view);
@@ -798,9 +843,11 @@
filter, std::move(iter), dst);
}
-void SkGpuDevice::drawImageLattice(const SkImage* image,
- const SkCanvas::Lattice& lattice, const SkRect& dst,
- SkFilterMode filter, const SkPaint& paint) {
+void Device::drawImageLattice(const SkImage* image,
+ const SkCanvas::Lattice& lattice,
+ const SkRect& dst,
+ SkFilterMode filter,
+ const SkPaint& paint) {
ASSERT_SINGLE_OWNER
auto iter = std::make_unique<SkLatticeIter>(lattice, dst);
if (auto [view, ct] = as_IB(image)->asView(this->recordingContext(), GrMipmapped::kNo); view) {
@@ -814,35 +861,7 @@
}
}
-static bool init_vertices_paint(GrRecordingContext* context,
- const GrColorInfo& colorInfo,
- const SkPaint& skPaint,
- const SkMatrixProvider& matrixProvider,
- SkBlendMode bmode,
- bool hasColors,
- GrPaint* grPaint) {
- if (skPaint.getShader()) {
- if (hasColors) {
- // When there are colors and a shader, the shader and colors are combined using bmode.
- return SkPaintToGrPaintWithBlend(context, colorInfo, skPaint, matrixProvider, bmode,
- grPaint);
- } else {
- // We have a shader, but no colors to blend it against.
- return SkPaintToGrPaint(context, colorInfo, skPaint, matrixProvider, grPaint);
- }
- } else {
- if (hasColors) {
- // We have colors, but no shader.
- return SkPaintToGrPaintWithPrimitiveColor(context, colorInfo, skPaint, matrixProvider,
- grPaint);
- } else {
- // No colors and no shader. Just draw with the paint color.
- return SkPaintToGrPaintNoShader(context, colorInfo, skPaint, matrixProvider, grPaint);
- }
- }
-}
-
-void SkGpuDevice::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) {
+void Device::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawVertices", fContext.get());
SkASSERT(vertices);
@@ -864,7 +883,7 @@
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
+void Device::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
#if GR_TEST_UTILS
if (fContext->priv().options().fAllPathsVolatile && !path.isVolatile()) {
this->drawShadow(SkPath(path).setIsVolatile(true), rec);
@@ -882,10 +901,10 @@
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
- const SkRect texRect[], const SkColor colors[], int count,
- SkBlendMode mode, const SkSamplingOptions& sampling,
- const SkPaint& paint) {
+void Device::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
+ const SkRect texRect[], const SkColor colors[], int count,
+ SkBlendMode mode, const SkSamplingOptions& sampling,
+ const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawAtlas", fContext.get());
@@ -924,7 +943,7 @@
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
+void Device::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawGlyphRunList", fContext.get());
SkASSERT(!glyphRunList.hasRSXForm());
@@ -935,7 +954,7 @@
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix, SkCanvas* canvas) {
+void Device::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix, SkCanvas* canvas) {
ASSERT_SINGLE_OWNER
GrBackendApi api = this->recordingContext()->backend();
@@ -956,20 +975,21 @@
///////////////////////////////////////////////////////////////////////////////
-bool SkGpuDevice::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
- bool deleteSemaphoresAfterWait) {
+bool Device::wait(int numSemaphores,
+ const GrBackendSemaphore* waitSemaphores,
+ bool deleteSemaphoresAfterWait) {
ASSERT_SINGLE_OWNER
return fSurfaceDrawContext->waitOnSemaphores(numSemaphores, waitSemaphores,
deleteSemaphoresAfterWait);
}
-bool SkGpuDevice::replaceBackingProxy(SkSurface::ContentChangeMode mode,
- sk_sp<GrRenderTargetProxy> newRTP,
- GrColorType grColorType,
- sk_sp<SkColorSpace> colorSpace,
- GrSurfaceOrigin origin,
- const SkSurfaceProps& props) {
+bool Device::replaceBackingProxy(SkSurface::ContentChangeMode mode,
+ sk_sp<GrRenderTargetProxy> newRTP,
+ GrColorType grColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps& props) {
auto sdc = GrSurfaceDrawContext::Make(fContext.get(), grColorType, std::move(newRTP),
std::move(colorSpace), origin, props);
if (!sdc) {
@@ -994,12 +1014,12 @@
return true;
}
-void SkGpuDevice::asyncRescaleAndReadPixels(const SkImageInfo& info,
- const SkIRect& srcRect,
- RescaleGamma rescaleGamma,
- RescaleMode rescaleMode,
- ReadPixelsCallback callback,
- ReadPixelsContext context) {
+void Device::asyncRescaleAndReadPixels(const SkImageInfo& info,
+ const SkIRect& srcRect,
+ RescaleGamma rescaleGamma,
+ RescaleMode rescaleMode,
+ ReadPixelsCallback callback,
+ ReadPixelsContext context) {
auto* sdc = fSurfaceDrawContext.get();
// Context TODO: Elevate direct context requirement to public API.
auto dContext = sdc->recordingContext()->asDirectContext();
@@ -1010,14 +1030,14 @@
context);
}
-void SkGpuDevice::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
- sk_sp<SkColorSpace> dstColorSpace,
- const SkIRect& srcRect,
- SkISize dstSize,
- RescaleGamma rescaleGamma,
- RescaleMode rescaleMode,
- ReadPixelsCallback callback,
- ReadPixelsContext context) {
+void Device::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
+ sk_sp<SkColorSpace> dstColorSpace,
+ const SkIRect& srcRect,
+ SkISize dstSize,
+ RescaleGamma rescaleGamma,
+ RescaleMode rescaleMode,
+ ReadPixelsCallback callback,
+ ReadPixelsContext context) {
auto* sdc = fSurfaceDrawContext.get();
// Context TODO: Elevate direct context requirement to public API.
auto dContext = sdc->recordingContext()->asDirectContext();
@@ -1037,7 +1057,7 @@
///////////////////////////////////////////////////////////////////////////////
-SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) {
+SkBaseDevice* Device::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) {
ASSERT_SINGLE_OWNER
SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry);
@@ -1062,10 +1082,10 @@
// Skia's convention is to only clear a device if it is non-opaque.
InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_InitContents;
- return SkGpuDevice::Make(std::move(sdc), &cinfo.fInfo, init).release();
+ return Device::Make(std::move(sdc), &cinfo.fInfo, init).release();
}
-sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
+sk_sp<SkSurface> Device::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
ASSERT_SINGLE_OWNER
// TODO: Change the signature of newSurface to take a budgeted parameter.
static const SkBudgeted kBudgeted = SkBudgeted::kNo;
@@ -1074,7 +1094,7 @@
fSurfaceDrawContext->origin(), &props);
}
-SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
+SkImageFilterCache* Device::getImageFilterCache() {
ASSERT_SINGLE_OWNER
// We always return a transient cache, so it is freed after each
// filter traversal.
@@ -1083,7 +1103,7 @@
////////////////////////////////////////////////////////////////////////////////////
-bool SkGpuDevice::android_utils_clipWithStencil() {
+bool Device::android_utils_clipWithStencil() {
SkRegion clipRegion;
this->onAsRgnClip(&clipRegion);
if (clipRegion.isEmpty()) {
@@ -1108,3 +1128,5 @@
GrStyle::SimpleFill(), &kDrawToStencil);
return true;
}
+
+} // namespace skgpu::v1
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/v1/Device_drawTexture.cpp
similarity index 87%
rename from src/gpu/SkGpuDevice_drawTexture.cpp
rename to src/gpu/v1/Device_drawTexture.cpp
index 09124a9..d14db10 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/v1/Device_drawTexture.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "src/gpu/SkGpuDevice.h"
+#include "src/gpu/v1/Device_v1.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
@@ -30,7 +30,7 @@
namespace {
-static inline bool use_shader(bool textureIsAlphaOnly, const SkPaint& paint) {
+inline bool use_shader(bool textureIsAlphaOnly, const SkPaint& paint) {
return textureIsAlphaOnly && paint.getShader();
}
@@ -39,7 +39,7 @@
static const SkScalar kColorBleedTolerance = 0.001f;
-static bool has_aligned_samples(const SkRect& srcRect, const SkRect& transformedRect) {
+bool has_aligned_samples(const SkRect& srcRect, const SkRect& transformedRect) {
// detect pixel disalignment
if (SkScalarAbs(SkScalarRoundToScalar(transformedRect.left()) - transformedRect.left()) < kColorBleedTolerance &&
SkScalarAbs(SkScalarRoundToScalar(transformedRect.top()) - transformedRect.top()) < kColorBleedTolerance &&
@@ -50,10 +50,10 @@
return false;
}
-static bool may_color_bleed(const SkRect& srcRect,
- const SkRect& transformedRect,
- const SkMatrix& m,
- int numSamples) {
+bool may_color_bleed(const SkRect& srcRect,
+ const SkRect& transformedRect,
+ const SkMatrix& m,
+ int numSamples) {
// Only gets called if has_aligned_samples returned false.
// So we can assume that sampling is axis aligned but not texel aligned.
SkASSERT(!has_aligned_samples(srcRect, transformedRect));
@@ -79,9 +79,9 @@
return inner != outer;
}
-static bool can_ignore_linear_filtering_subset(const SkRect& srcSubset,
- const SkMatrix& srcRectToDeviceSpace,
- int numSamples) {
+bool can_ignore_linear_filtering_subset(const SkRect& srcSubset,
+ const SkMatrix& srcRectToDeviceSpace,
+ int numSamples) {
if (srcRectToDeviceSpace.rectStaysRect()) {
// sampling is axis-aligned
SkRect transformedRect;
@@ -100,13 +100,13 @@
static const int kBmpSmallTileSize = 1 << 10;
-static inline int get_tile_count(const SkIRect& srcRect, int tileSize) {
+inline int get_tile_count(const SkIRect& srcRect, int tileSize) {
int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1;
int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1;
return tilesX * tilesY;
}
-static int determine_tile_size(const SkIRect& src, int maxTileSize) {
+int determine_tile_size(const SkIRect& src, int maxTileSize) {
if (maxTileSize <= kBmpSmallTileSize) {
return maxTileSize;
}
@@ -126,12 +126,12 @@
// Given a bitmap, an optional src rect, and a context with a clip and matrix determine what
// pixels from the bitmap are necessary.
-static SkIRect determine_clipped_src_rect(int width, int height,
- const GrClip* clip,
- const SkMatrix& viewMatrix,
- const SkMatrix& srcToDstRect,
- const SkISize& imageDimensions,
- const SkRect* srcRectPtr) {
+SkIRect determine_clipped_src_rect(int width, int height,
+ const GrClip* clip,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& srcToDstRect,
+ const SkISize& imageDimensions,
+ const SkRect* srcRectPtr) {
SkIRect clippedSrcIRect = clip ? clip->getConservativeBounds()
: SkIRect::MakeWH(width, height);
SkMatrix inv = SkMatrix::Concat(viewMatrix, srcToDstRect);
@@ -155,17 +155,17 @@
}
// tileSize and clippedSubset are valid if true is returned
-static bool should_tile_image_id(GrRecordingContext* context,
- SkISize rtSize,
- const GrClip* clip,
- uint32_t imageID,
- const SkISize& imageSize,
- const SkMatrix& ctm,
- const SkMatrix& srcToDst,
- const SkRect* src,
- int maxTileSize,
- int* tileSize,
- SkIRect* clippedSubset) {
+bool should_tile_image_id(GrRecordingContext* context,
+ SkISize rtSize,
+ const GrClip* clip,
+ uint32_t imageID,
+ const SkISize& imageSize,
+ const SkMatrix& ctm,
+ const SkMatrix& srcToDst,
+ const SkRect* src,
+ int maxTileSize,
+ int* tileSize,
+ SkIRect* clippedSubset) {
// if it's larger than the max tile size, then we have no choice but tiling.
if (imageSize.width() > maxTileSize || imageSize.height() > maxTileSize) {
*clippedSubset = determine_clipped_src_rect(rtSize.width(), rtSize.height(), clip, ctm,
@@ -215,8 +215,8 @@
// This method outsets 'iRect' by 'outset' all around and then clamps its extents to
// 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner
// of 'iRect' for all possible outsets/clamps.
-static inline void clamped_outset_with_offset(SkIRect* iRect, int outset, SkPoint* offset,
- const SkIRect& clamp) {
+inline void clamped_outset_with_offset(SkIRect* iRect, int outset, SkPoint* offset,
+ const SkIRect& clamp) {
iRect->outset(outset, outset);
int leftClampDelta = clamp.fLeft - iRect->fLeft;
@@ -265,10 +265,10 @@
* If 'origSrcRect' is null, implicitly use the image bounds. If 'origDstRect' is null, use the
* original src rect. 'dstClip' should be null when there is no additional clipping.
*/
-static ImageDrawMode optimize_sample_area(const SkISize& image, const SkRect* origSrcRect,
- const SkRect* origDstRect, const SkPoint dstClip[4],
- SkRect* outSrcRect, SkRect* outDstRect,
- SkMatrix* srcToDst) {
+ImageDrawMode optimize_sample_area(const SkISize& image, const SkRect* origSrcRect,
+ const SkRect* origDstRect, const SkPoint dstClip[4],
+ SkRect* outSrcRect, SkRect* outDstRect,
+ SkMatrix* srcToDst) {
SkRect srcBounds = SkRect::MakeIWH(image.fWidth, image.fHeight);
SkRect src = origSrcRect ? *origSrcRect : srcBounds;
@@ -317,14 +317,14 @@
* Checks whether the paint is compatible with using GrSurfaceDrawContext::drawTexture. It is more
* efficient than the SkImage general case.
*/
-static bool can_use_draw_texture(const SkPaint& paint, bool useCubicResampler, SkMipmapMode mm) {
+bool can_use_draw_texture(const SkPaint& paint, bool useCubicResampler, SkMipmapMode mm) {
return (!paint.getColorFilter() && !paint.getShader() && !paint.getMaskFilter() &&
!paint.getImageFilter() && !paint.getBlender() && !useCubicResampler &&
mm == SkMipmapMode::kNone);
}
-static SkPMColor4f texture_color(SkColor4f paintColor, float entryAlpha, GrColorType srcColorType,
- const GrColorInfo& dstColorInfo) {
+SkPMColor4f texture_color(SkColor4f paintColor, float entryAlpha, GrColorType srcColorType,
+ const GrColorInfo& dstColorInfo) {
paintColor.fA *= entryAlpha;
if (GrColorTypeIsAlphaOnly(srcColorType)) {
return SkColor4fPrepForDst(paintColor, dstColorInfo).premul();
@@ -335,19 +335,19 @@
}
// Assumes srcRect and dstRect have already been optimized to fit the proxy
-static void draw_texture(GrSurfaceDrawContext* rtc,
- const GrClip* clip,
- const SkMatrix& ctm,
- const SkPaint& paint,
- GrSamplerState::Filter filter,
- const SkRect& srcRect,
- const SkRect& dstRect,
- const SkPoint dstClip[4],
- GrAA aa,
- GrQuadAAFlags aaFlags,
- SkCanvas::SrcRectConstraint constraint,
- GrSurfaceProxyView view,
- const GrColorInfo& srcColorInfo) {
+void draw_texture(GrSurfaceDrawContext* rtc,
+ const GrClip* clip,
+ const SkMatrix& ctm,
+ const SkPaint& paint,
+ GrSamplerState::Filter filter,
+ const SkRect& srcRect,
+ const SkRect& dstRect,
+ const SkPoint dstClip[4],
+ GrAA aa,
+ GrQuadAAFlags aaFlags,
+ SkCanvas::SrcRectConstraint constraint,
+ GrSurfaceProxyView view,
+ const GrColorInfo& srcColorInfo) {
if (GrColorTypeIsAlphaOnly(srcColorInfo.colorType())) {
view.concatSwizzle(GrSwizzle("aaaa"));
}
@@ -408,21 +408,21 @@
}
// Assumes srcRect and dstRect have already been optimized to fit the proxy.
-static void draw_image(GrRecordingContext* context,
- GrSurfaceDrawContext* rtc,
- const GrClip* clip,
- const SkMatrixProvider& matrixProvider,
- const SkPaint& paint,
- const SkImage_Base& image,
- const SkRect& src,
- const SkRect& dst,
- const SkPoint dstClip[4],
- const SkMatrix& srcToDst,
- GrAA aa,
- GrQuadAAFlags aaFlags,
- SkCanvas::SrcRectConstraint constraint,
- SkSamplingOptions sampling,
- SkTileMode tm = SkTileMode::kClamp) {
+void draw_image(GrRecordingContext* context,
+ GrSurfaceDrawContext* rtc,
+ const GrClip* clip,
+ const SkMatrixProvider& matrixProvider,
+ const SkPaint& paint,
+ const SkImage_Base& image,
+ const SkRect& src,
+ const SkRect& dst,
+ const SkPoint dstClip[4],
+ const SkMatrix& srcToDst,
+ GrAA aa,
+ GrQuadAAFlags aaFlags,
+ SkCanvas::SrcRectConstraint constraint,
+ SkSamplingOptions sampling,
+ SkTileMode tm = SkTileMode::kClamp) {
const SkMatrix& ctm(matrixProvider.localToDevice());
if (tm == SkTileMode::kClamp &&
!image.isYUVA() &&
@@ -666,11 +666,7 @@
}
}
-} // anonymous namespace
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkFilterMode downgrade_to_filter(const SkSamplingOptions& sampling) {
+SkFilterMode downgrade_to_filter(const SkSamplingOptions& sampling) {
SkFilterMode filter = sampling.filter;
if (sampling.useCubic || sampling.mipmap != SkMipmapMode::kNone) {
// if we were "fancier" than just bilerp, only do bilerp
@@ -679,10 +675,34 @@
return filter;
}
-void SkGpuDevice::drawSpecial(SkSpecialImage* special,
- const SkMatrix& localToDevice,
- const SkSamplingOptions& origSampling,
- const SkPaint& paint) {
+bool can_disable_mipmap(const SkMatrix& viewM,
+ const SkMatrix& localM,
+ bool sharpenMipmappedTextures) {
+ SkMatrix matrix;
+ matrix.setConcat(viewM, localM);
+ // With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until
+ // the computed LOD is >= 0.5. At what scale factor does a texture get an LOD of
+ // 0.5?
+ //
+ // Want: 0 = log2(1/s) - 0.5
+ // 0.5 = log2(1/s)
+ // 2^0.5 = 1/s
+ // 1/2^0.5 = s
+ // 2^0.5/2 = s
+ SkScalar mipScale = sharpenMipmappedTextures ? SK_ScalarRoot2Over2 : SK_Scalar1;
+ return matrix.getMinScale() >= mipScale;
+}
+
+} // anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace skgpu::v1 {
+
+void Device::drawSpecial(SkSpecialImage* special,
+ const SkMatrix& localToDevice,
+ const SkSamplingOptions& origSampling,
+ const SkPaint& paint) {
SkASSERT(!paint.getMaskFilter() && !paint.getImageFilter());
SkASSERT(special->isTextureBacked());
@@ -722,34 +742,16 @@
sampling);
}
-static bool can_disable_mipmap(const SkMatrix& viewM,
- const SkMatrix& localM,
- bool sharpenMipmappedTextures) {
- SkMatrix matrix;
- matrix.setConcat(viewM, localM);
- // With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until
- // the computed LOD is >= 0.5. At what scale factor does a texture get an LOD of
- // 0.5?
- //
- // Want: 0 = log2(1/s) - 0.5
- // 0.5 = log2(1/s)
- // 2^0.5 = 1/s
- // 1/2^0.5 = s
- // 2^0.5/2 = s
- SkScalar mipScale = sharpenMipmappedTextures ? SK_ScalarRoot2Over2 : SK_Scalar1;
- return matrix.getMinScale() >= mipScale;
-}
-
-void SkGpuDevice::drawImageQuad(const SkImage* image,
- const SkRect* srcRect,
- const SkRect* dstRect,
- const SkPoint dstClip[4],
- GrAA aa,
- GrQuadAAFlags aaFlags,
- const SkMatrix* preViewMatrix,
- const SkSamplingOptions& origSampling,
- const SkPaint& paint,
- SkCanvas::SrcRectConstraint constraint) {
+void Device::drawImageQuad(const SkImage* image,
+ const SkRect* srcRect,
+ const SkRect* dstRect,
+ const SkPoint dstClip[4],
+ GrAA aa,
+ GrQuadAAFlags aaFlags,
+ const SkMatrix* preViewMatrix,
+ const SkSamplingOptions& origSampling,
+ const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint) {
SkRect src;
SkRect dst;
SkMatrix srcToDst;
@@ -840,10 +842,10 @@
return;
}
-void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
- const SkPoint dstClips[], const SkMatrix preViewMatrices[],
- const SkSamplingOptions& sampling, const SkPaint& paint,
- SkCanvas::SrcRectConstraint constraint) {
+void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
+ const SkPoint dstClips[], const SkMatrix preViewMatrices[],
+ const SkSamplingOptions& sampling, const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint) {
SkASSERT(count > 0);
if (!can_use_draw_texture(paint, sampling.useCubic, sampling.mipmap)) {
// Send every entry through drawImageQuad() to handle the more complicated paint
@@ -978,3 +980,5 @@
}
draw(count);
}
+
+} // namespace skgpu::v1
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/v1/Device_v1.h
similarity index 85%
rename from src/gpu/SkGpuDevice.h
rename to src/gpu/v1/Device_v1.h
index e9f6cd4..203307a 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/v1/Device_v1.h
@@ -13,12 +13,13 @@
#include "include/core/SkRegion.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrTypes.h"
+#include "src/gpu/BaseDevice.h"
#include "src/gpu/GrSurfaceDrawContext.h"
-#include "src/gpu/SkBaseGpuDevice.h"
#include "src/gpu/SkGr.h"
class SkSpecialImage;
class SkSurface;
+class SkSurface_Gpu;
class SkVertices;
#if !defined(SK_DISABLE_NEW_GR_CLIP_STACK)
@@ -29,10 +30,12 @@
#define GR_CLIP_STACK GrClipStackClip
#endif
+namespace skgpu::v1 {
+
/**
- * Subclass of SkBaseGpuDevice, which directs all drawing to the GrGpu owned by the canvas.
+ * Subclass of BaseDevice, which directs all drawing to the GrGpu owned by the canvas.
*/
-class SkGpuDevice : public SkBaseGpuDevice {
+class Device : public BaseDevice {
public:
GrSurfaceProxyView readSurfaceView() override {
return fSurfaceDrawContext->readSurfaceView();
@@ -52,7 +55,7 @@
sk_sp<SkColorSpace>,
GrSurfaceOrigin,
const SkSurfaceProps&) override;
- using SkBaseGpuDevice::replaceBackingProxy;
+ using BaseDevice::replaceBackingProxy;
void asyncRescaleAndReadPixels(const SkImageInfo& info,
const SkIRect& srcRect,
@@ -74,13 +77,13 @@
* This factory uses the color space, origin, surface properties, and initialization
* method along with the provided proxy to create the gpu device.
*/
- static sk_sp<SkBaseGpuDevice> Make(GrRecordingContext*,
- GrColorType,
- sk_sp<GrSurfaceProxy>,
- sk_sp<SkColorSpace>,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- InitContents);
+ static sk_sp<BaseDevice> Make(GrRecordingContext*,
+ GrColorType,
+ sk_sp<GrSurfaceProxy>,
+ sk_sp<SkColorSpace>,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ InitContents);
/**
* This factory uses the budgeted, imageInfo, fit, sampleCount, mipmapped, and isProtected
@@ -88,18 +91,18 @@
* origin, surface properties, and initialization method are then used (with the created proxy)
* to create the device.
*/
- static sk_sp<SkBaseGpuDevice> Make(GrRecordingContext*,
- SkBudgeted,
- const SkImageInfo&,
- SkBackingFit,
- int sampleCount,
- GrMipmapped,
- GrProtected,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- InitContents);
+ static sk_sp<BaseDevice> Make(GrRecordingContext*,
+ SkBudgeted,
+ const SkImageInfo&,
+ SkBackingFit,
+ int sampleCount,
+ GrMipmapped,
+ GrProtected,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ InitContents);
- ~SkGpuDevice() override {}
+ ~Device() override {}
GrSurfaceDrawContext* surfaceDrawContext() override;
const GrSurfaceDrawContext* surfaceDrawContext() const;
@@ -203,11 +206,11 @@
static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init,
unsigned* flags);
- static sk_sp<SkBaseGpuDevice> Make(std::unique_ptr<GrSurfaceDrawContext>,
- const SkImageInfo*,
- InitContents);
+ static sk_sp<BaseDevice> Make(std::unique_ptr<GrSurfaceDrawContext>,
+ const SkImageInfo*,
+ InitContents);
- SkGpuDevice(std::unique_ptr<GrSurfaceDrawContext>, unsigned flags);
+ Device(std::unique_ptr<GrSurfaceDrawContext>, unsigned flags);
SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
@@ -245,10 +248,12 @@
GrSurfaceOrigin,
const SkSurfaceProps&);
- friend class SkSurface_Gpu; // for access to surfaceProps
- using INHERITED = SkBaseGpuDevice;
+ friend class ::SkSurface_Gpu; // for access to surfaceProps
+ using INHERITED = BaseDevice;
};
+} // namespace skgpu::v1
+
#undef GR_CLIP_STACK
#endif
diff --git a/src/gpu/v2/Device.cpp b/src/gpu/v2/Device.cpp
new file mode 100644
index 0000000..8c190d0
--- /dev/null
+++ b/src/gpu/v2/Device.cpp
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2021 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/gpu/v2/Device_v2.h"
+
+#include "include/gpu/GrRecordingContext.h"
+#include "src/core/SkImageFilterCache.h"
+#include "src/gpu/GrRecordingContextPriv.h"
+#include "src/gpu/GrTracing.h"
+
+#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(fContext->priv().singleOwner())
+
+namespace skgpu::v2 {
+
+Device::Device(sk_sp<GrRecordingContext> rContext,
+ const SkImageInfo& ii,
+ const SkSurfaceProps& props)
+ : INHERITED(std::move(rContext), ii, props) {
+}
+
+Device::~Device() {}
+
+GrSurfaceProxyView Device::readSurfaceView() { return {}; }
+
+void Device::asyncRescaleAndReadPixels(const SkImageInfo& info,
+ const SkIRect& srcRect,
+ RescaleGamma rescaleGamma,
+ RescaleMode rescaleMode,
+ ReadPixelsCallback callback,
+ ReadPixelsContext context) {
+ // Context TODO: Elevate direct context requirement to public API.
+ auto dContext = this->recordingContext()->asDirectContext();
+ if (!dContext) {
+ return;
+ }
+}
+
+void Device::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
+ sk_sp<SkColorSpace> dstColorSpace,
+ const SkIRect& srcRect,
+ SkISize dstSize,
+ RescaleGamma rescaleGamma,
+ RescaleMode,
+ ReadPixelsCallback callback,
+ ReadPixelsContext context) {
+ // Context TODO: Elevate direct context requirement to public API.
+ auto dContext = this->recordingContext()->asDirectContext();
+ if (!dContext) {
+ return;
+ }
+}
+
+void Device::onSave() {
+}
+
+void Device::onRestore() {
+}
+
+void Device::onClipRect(const SkRect& rect, SkClipOp op, bool aa) {
+}
+
+void Device::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
+}
+
+void Device::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
+ SkASSERT(op == SkClipOp::kIntersect || op == SkClipOp::kDifference);
+}
+
+void Device::onClipShader(sk_sp<SkShader> shader) {
+}
+
+void Device::onClipRegion(const SkRegion& globalRgn, SkClipOp op) {
+ SkASSERT(op == SkClipOp::kIntersect || op == SkClipOp::kDifference);
+}
+
+void Device::onReplaceClip(const SkIRect& rect) {
+}
+
+void Device::onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) {
+}
+
+bool Device::onClipIsAA() const {
+ return false;
+}
+
+bool Device::onClipIsWideOpen() const {
+ return false;
+}
+
+void Device::onAsRgnClip(SkRegion* region) const {
+}
+
+SkBaseDevice::ClipType Device::onGetClipType() const {
+ return ClipType::kEmpty;
+}
+
+SkIRect Device::onDevClipBounds() const {
+ return SkIRect::MakeEmpty();
+}
+
+void Device::drawPaint(const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawPaint", fContext.get());
+}
+
+void Device::drawPoints(SkCanvas::PointMode mode,
+ size_t count,
+ const SkPoint points[],
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawPoints", fContext.get());
+
+}
+
+void Device::drawRect(const SkRect& rect, const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawRect", fContext.get());
+}
+
+void Device::drawRegion(const SkRegion& r, const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawRegion", fContext.get());
+}
+
+void Device::drawOval(const SkRect& oval, const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawOval", fContext.get());
+}
+
+void Device::drawArc(const SkRect& oval,
+ SkScalar startAngle,
+ SkScalar sweepAngle,
+ bool useCenter,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawArc", fContext.get());
+}
+
+void Device::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawRRect", fContext.get());
+}
+
+void Device::drawDRRect(const SkRRect& outer,
+ const SkRRect& inner,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawDRRect", fContext.get());
+}
+
+void Device::drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawPath", fContext.get());
+}
+
+void Device::drawImageRect(const SkImage* image,
+ const SkRect* src,
+ const SkRect& dst,
+ const SkSamplingOptions& sampling,
+ const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawImageRect", fContext.get());
+}
+
+void Device::drawImageLattice(const SkImage* image,
+ const SkCanvas::Lattice& lattice,
+ const SkRect& dst,
+ SkFilterMode filter,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawImageLattice", fContext.get());
+}
+
+void Device::drawVertices(const SkVertices* vertices,
+ SkBlendMode mode,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawVertices", fContext.get());
+}
+
+void Device::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawShadow", fContext.get());
+}
+
+void Device::drawAtlas(const SkImage* atlas,
+ const SkRSXform xform[],
+ const SkRect texRect[],
+ const SkColor colors[],
+ int count,
+ SkBlendMode mode,
+ const SkSamplingOptions& sampling,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawAtlas", fContext.get());
+}
+
+void Device::drawEdgeAAQuad(const SkRect& rect,
+ const SkPoint clip[4],
+ SkCanvas::QuadAAFlags aaFlags,
+ const SkColor4f& color,
+ SkBlendMode mode) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawEdgeAAQuad", fContext.get());
+}
+
+void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[],
+ int count,
+ const SkPoint dstClips[],
+ const SkMatrix preViewMatrices[],
+ const SkSamplingOptions& sampling,
+ const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawEdgeAAImageSet", fContext.get());
+}
+
+void Device::drawDrawable(SkDrawable* drawable,
+ const SkMatrix* matrix,
+ SkCanvas* canvas) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawDrawable", fContext.get());
+
+ this->INHERITED::drawDrawable(drawable, matrix, canvas);
+}
+
+void Device::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "onDrawGlyphRunList", fContext.get());
+}
+
+void Device::drawDevice(SkBaseDevice* device,
+ const SkSamplingOptions& sampling,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice_nga", "drawDevice", fContext.get());
+}
+
+void Device::drawSpecial(SkSpecialImage* special,
+ const SkMatrix& localToDevice,
+ const SkSamplingOptions& sampling,
+ const SkPaint& paint) {
+}
+
+sk_sp<SkSpecialImage> Device::makeSpecial(const SkBitmap& bitmap) {
+ ASSERT_SINGLE_OWNER
+ return nullptr;
+}
+
+sk_sp<SkSpecialImage> Device::makeSpecial(const SkImage* image) {
+ ASSERT_SINGLE_OWNER
+ return nullptr;
+}
+
+sk_sp<SkSpecialImage> Device::snapSpecial(const SkIRect& subset, bool forceCopy) {
+ ASSERT_SINGLE_OWNER
+ return nullptr;
+}
+
+sk_sp<SkSurface> Device::makeSurface(const SkImageInfo& ii,
+ const SkSurfaceProps& props) {
+ ASSERT_SINGLE_OWNER
+ return nullptr;
+}
+
+bool Device::onReadPixels(const SkPixmap& pm, int x, int y) {
+ ASSERT_SINGLE_OWNER
+ return false;
+}
+
+bool Device::onWritePixels(const SkPixmap& pm, int x, int y) {
+ ASSERT_SINGLE_OWNER
+ return false;
+}
+
+bool Device::onAccessPixels(SkPixmap*) {
+ ASSERT_SINGLE_OWNER
+ return false;
+}
+
+SkBaseDevice* Device::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) {
+ ASSERT_SINGLE_OWNER
+ return nullptr;
+}
+
+bool Device::forceConservativeRasterClip() const {
+ return true;
+}
+
+SkImageFilterCache* Device::getImageFilterCache() {
+ ASSERT_SINGLE_OWNER
+
+ // We always return a transient cache, so it is freed after each filter traversal.
+ return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize);
+}
+
+} // namespace skgpu::v2
diff --git a/src/gpu/SkGpuDevice_nga.h b/src/gpu/v2/Device_v2.h
similarity index 78%
rename from src/gpu/SkGpuDevice_nga.h
rename to src/gpu/v2/Device_v2.h
index ddb4872..b4431f4 100644
--- a/src/gpu/SkGpuDevice_nga.h
+++ b/src/gpu/v2/Device_v2.h
@@ -5,42 +5,44 @@
* found in the LICENSE file.
*/
-#ifndef SkGpuDevice_nga_DEFINED
-#define SkGpuDevice_nga_DEFINED
+#ifndef Device_v2_DEFINED
+#define Device_v2_DEFINED
-#include "src/gpu/SkBaseGpuDevice.h"
+#include "src/gpu/BaseDevice.h"
+
+namespace skgpu::v2 {
/**
- * Subclass of SkBaseGpuDevice, which directs all drawing to the GrGpu owned by the canvas.
+ * Subclass of BaseDevice, which directs all drawing to the GrGpu owned by the canvas.
*/
-class SkGpuDevice_nga : public SkBaseGpuDevice {
+class Device : public BaseDevice {
public:
- static sk_sp<SkBaseGpuDevice> Make(GrRecordingContext*,
- GrColorType,
- sk_sp<GrSurfaceProxy>,
- sk_sp<SkColorSpace>,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- InitContents) {
+ static sk_sp<BaseDevice> Make(GrRecordingContext*,
+ GrColorType,
+ sk_sp<GrSurfaceProxy>,
+ sk_sp<SkColorSpace>,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ InitContents) {
return nullptr;
}
- static sk_sp<SkBaseGpuDevice> Make(GrRecordingContext*,
- SkBudgeted,
- const SkImageInfo&,
- SkBackingFit,
- int sampleCount,
- GrMipmapped,
- GrProtected,
- GrSurfaceOrigin,
- const SkSurfaceProps&,
- InitContents) {
+ static sk_sp<BaseDevice> Make(GrRecordingContext*,
+ SkBudgeted,
+ const SkImageInfo&,
+ SkBackingFit,
+ int sampleCount,
+ GrMipmapped,
+ GrProtected,
+ GrSurfaceOrigin,
+ const SkSurfaceProps&,
+ InitContents) {
return nullptr;
}
- ~SkGpuDevice_nga() override;
+ ~Device() override;
- GrSurfaceProxyView readSurfaceView() override { return {}; }
+ GrSurfaceProxyView readSurfaceView() override;
bool wait(int numSemaphores,
const GrBackendSemaphore* waitSemaphores,
@@ -140,13 +142,15 @@
/* isNoPixelsDevice */
private:
- SkGpuDevice_nga(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&);
+ Device(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&);
/* replaceBitmapBackendForRasterSurface */
bool forceConservativeRasterClip() const override;
SkImageFilterCache* getImageFilterCache() override;
- using INHERITED = SkBaseGpuDevice;
+ using INHERITED = BaseDevice;
};
-#endif // SkGpuDevice_nga_DEFINED
+} // namespace skgpu::v2
+
+#endif // Device_v2_DEFINED
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
index 391b7ed..d945a6f 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
@@ -46,7 +46,7 @@
imageInfo.refColorSpace(),
kTopLeft_GrSurfaceOrigin,
SkSurfacePropsCopyOrDefault(props),
- SkBaseGpuDevice::kUninit_InitContents);
+ skgpu::BaseDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
@@ -55,7 +55,7 @@
props));
}
-GrVkSecondaryCBDrawContext::GrVkSecondaryCBDrawContext(sk_sp<SkBaseGpuDevice> device,
+GrVkSecondaryCBDrawContext::GrVkSecondaryCBDrawContext(sk_sp<skgpu::BaseDevice> device,
const SkSurfaceProps* props)
: fDevice(device)
, fProps(SkSurfacePropsCopyOrDefault(props)) {}
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.h b/src/gpu/vk/GrVkSecondaryCBDrawContext.h
index 54fcee0..48b8b38 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.h
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.h
@@ -15,7 +15,7 @@
class GrBackendSemaphore;
class GrRecordingContext;
struct GrVkDrawableInfo;
-class SkBaseGpuDevice;
+namespace skgpu { class BaseDevice; }
class SkCanvas;
class SkDeferredDisplayList;
struct SkImageInfo;
@@ -57,7 +57,8 @@
*/
class SK_SPI GrVkSecondaryCBDrawContext : public SkRefCnt {
public:
- static sk_sp<GrVkSecondaryCBDrawContext> Make(GrRecordingContext*, const SkImageInfo&,
+ static sk_sp<GrVkSecondaryCBDrawContext> Make(GrRecordingContext*,
+ const SkImageInfo&,
const GrVkDrawableInfo&,
const SkSurfaceProps* props);
@@ -113,9 +114,9 @@
bool isCompatible(const SkSurfaceCharacterization& characterization) const;
private:
- explicit GrVkSecondaryCBDrawContext(sk_sp<SkBaseGpuDevice>, const SkSurfaceProps*);
+ explicit GrVkSecondaryCBDrawContext(sk_sp<skgpu::BaseDevice>, const SkSurfaceProps*);
- sk_sp<SkBaseGpuDevice> fDevice;
+ sk_sp<skgpu::BaseDevice> fDevice;
std::unique_ptr<SkCanvas> fCachedCanvas;
const SkSurfaceProps fProps;
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index e01d9a9..3211ccb 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -15,6 +15,7 @@
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkSurfacePriv.h"
+#include "src/gpu/BaseDevice.h"
#include "src/gpu/GrAHardwareBufferUtils.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextThreadSafeProxyPriv.h"
@@ -23,14 +24,13 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrTexture.h"
-#include "src/gpu/SkBaseGpuDevice.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkImage_Gpu.h"
#include "src/image/SkSurface_Base.h"
#if SK_SUPPORT_GPU
-SkSurface_Gpu::SkSurface_Gpu(sk_sp<SkBaseGpuDevice> device)
+SkSurface_Gpu::SkSurface_Gpu(sk_sp<skgpu::BaseDevice> device)
: INHERITED(device->width(), device->height(), &device->surfaceProps())
, fDevice(std::move(device)) {
SkASSERT(fDevice->targetProxy()->priv().isExact());
@@ -43,7 +43,7 @@
return fDevice->recordingContext();
}
-SkBaseGpuDevice* SkSurface_Gpu::getDevice() {
+skgpu::BaseDevice* SkSurface_Gpu::getDevice() {
return fDevice.get();
}
@@ -407,7 +407,7 @@
auto device = rContext->priv().createDevice(budgeted, c.imageInfo(), SkBackingFit::kExact,
c.sampleCount(), GrMipmapped(c.isMipMapped()),
c.isProtected(), c.origin(), c.surfaceProps(),
- SkBaseGpuDevice::kClear_InitContents);
+ skgpu::BaseDevice::kClear_InitContents);
if (!device) {
return nullptr;
}
@@ -466,7 +466,7 @@
auto device = rContext->priv().createDevice(budgeted, info, SkBackingFit::kExact,
sampleCount, mipMapped, GrProtected::kNo, origin,
SkSurfacePropsCopyOrDefault(props),
- SkBaseGpuDevice::kClear_InitContents);
+ skgpu::BaseDevice::kClear_InitContents);
if (!device) {
return nullptr;
}
@@ -509,7 +509,7 @@
auto device = rContext->priv().createDevice(grColorType, std::move(proxy),
std::move(colorSpace), origin,
SkSurfacePropsCopyOrDefault(props),
- SkBaseGpuDevice::kUninit_InitContents);
+ skgpu::BaseDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
@@ -626,7 +626,7 @@
auto device = rContext->priv().createDevice(grColorType, std::move(proxy),
std::move(colorSpace), origin,
SkSurfacePropsCopyOrDefault(props),
- SkBaseGpuDevice::kUninit_InitContents);
+ skgpu::BaseDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index 7a70470..5817782 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -14,12 +14,11 @@
#if SK_SUPPORT_GPU
class GrBackendFormat;
-class SkBaseGpuDevice;
-class SkGpuDevice;
+namespace skgpu { class BaseDevice; }
class SkSurface_Gpu : public SkSurface_Base {
public:
- SkSurface_Gpu(sk_sp<SkBaseGpuDevice>);
+ SkSurface_Gpu(sk_sp<skgpu::BaseDevice>);
~SkSurface_Gpu() override;
GrRecordingContext* onGetRecordingContext() override;
@@ -58,10 +57,10 @@
const SkPaint* paint) override;
bool onDraw(sk_sp<const SkDeferredDisplayList>, SkIPoint offset) override;
- SkBaseGpuDevice* getDevice();
+ skgpu::BaseDevice* getDevice();
private:
- sk_sp<SkBaseGpuDevice> fDevice;
+ sk_sp<skgpu::BaseDevice> fDevice;
using INHERITED = SkSurface_Base;
};
diff --git a/src/image/SkSurface_GpuMtl.mm b/src/image/SkSurface_GpuMtl.mm
index 8cc99a0..b38901c 100644
--- a/src/image/SkSurface_GpuMtl.mm
+++ b/src/image/SkSurface_GpuMtl.mm
@@ -88,7 +88,7 @@
std::move(colorSpace),
origin,
SkSurfacePropsCopyOrDefault(surfaceProps),
- SkBaseGpuDevice::kUninit_InitContents);
+ skgpu::BaseDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
@@ -157,7 +157,7 @@
std::move(colorSpace),
origin,
SkSurfacePropsCopyOrDefault(surfaceProps),
- SkBaseGpuDevice::kUninit_InitContents);
+ skgpu::BaseDevice::kUninit_InitContents);
if (!device) {
return nullptr;
}
diff --git a/tests/DeviceTest.cpp b/tests/DeviceTest.cpp
index 0d5997a..8311303 100644
--- a/tests/DeviceTest.cpp
+++ b/tests/DeviceTest.cpp
@@ -87,7 +87,7 @@
auto device = dContext->priv().createDevice(SkBudgeted::kNo, ii, SkBackingFit::kExact,
1, GrMipmapped::kNo, GrProtected::kNo,
kBottomLeft_GrSurfaceOrigin, SkSurfaceProps(),
- SkBaseGpuDevice::kClear_InitContents);
+ skgpu::BaseDevice::kClear_InitContents);
SkBitmap bm;
SkAssertResult(bm.tryAllocN32Pixels(kWidth, kHeight));
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index 3a7f8cf..48124d5 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -15,6 +15,7 @@
#ifdef SK_DIRECT3D
#include "include/gpu/d3d/GrD3DTypes.h"
#endif
+#include "src/gpu/BaseDevice.h"
#include "src/gpu/GrBackendTextureImageGenerator.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrDrawingManager.h"
@@ -26,7 +27,6 @@
#include "src/gpu/GrSurfaceProxyPriv.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/SkBaseGpuDevice.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkSurface_Gpu.h"
#include "tests/Test.h"
@@ -78,7 +78,7 @@
sk_gpu_test::ManagedBackendTexture::ReleaseProc,
mbet->releaseContext());
- SkBaseGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
+ auto device = ((SkSurface_Gpu*)surface.get())->getDevice();
proxy = device->readSurfaceView().asTextureProxyRef();
} else {
image = SkImage::MakeFromTexture(dContext,
@@ -310,7 +310,7 @@
willUseMips);
}
REPORTER_ASSERT(reporter, surface);
- SkBaseGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
+ auto device = ((SkSurface_Gpu*)surface.get())->getDevice();
GrTextureProxy* texProxy = device->readSurfaceView().asTextureProxy();
REPORTER_ASSERT(reporter, mipmapped == texProxy->mipmapped());
diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp
index c5ccc85..0df0193 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -18,6 +18,7 @@
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkSurfacePriv.h"
#include "src/core/SkTypeface_remote.h"
+#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/text/GrSDFTControl.h"
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index 2d90943..6b0d428 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -17,6 +17,7 @@
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkRuntimeEffectPriv.h"
#include "src/core/SkTLazy.h"
+#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColor.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrFragmentProcessor.h"
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index b104ea2..67a1577 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -18,6 +18,7 @@
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkDevice.h"
#include "src/core/SkUtils.h"
+#include "src/gpu/BaseDevice.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrGpuResourcePriv.h"
@@ -25,7 +26,6 @@
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurfaceDrawContext.h"
-#include "src/gpu/SkBaseGpuDevice.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkImage_Gpu.h"
#include "src/image/SkSurface_Gpu.h"