Have various software uploaders in gpu backend use views.
Bug: skia:9556
Change-Id: I1ac3744632b6e926f79e182d4cd9d59498699aee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269896
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 3fc381a..250a81a 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -523,7 +523,7 @@
draw_clip_elements_to_mask_helper(helper, reducedClip.maskElements(), reducedClip.scissor(),
reducedClip.initialState());
- proxy = helper.toTextureProxy(context, SkBackingFit::kApprox);
+ proxy = helper.toTextureView(context, SkBackingFit::kApprox).asTextureProxyRef();
}
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
diff --git a/src/gpu/GrLegacyDirectContext.cpp b/src/gpu/GrLegacyDirectContext.cpp
index b951dca..04a40bb 100644
--- a/src/gpu/GrLegacyDirectContext.cpp
+++ b/src/gpu/GrLegacyDirectContext.cpp
@@ -191,7 +191,6 @@
sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext,
const GrContextOptions& options) {
#ifdef SK_VULKAN
- GrContextOptions defaultOptions;
sk_sp<GrContext> context(new GrLegacyDirectContext(GrBackendApi::kVulkan, options));
context->fGpu = GrVkGpu::Make(backendContext, options, context.get());
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 45240df..e7916c6 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -93,8 +93,7 @@
return true;
}
-sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrRecordingContext* context,
- SkBackingFit fit) {
+GrSurfaceProxyView GrSWMaskHelper::toTextureView(GrRecordingContext* context, SkBackingFit fit) {
SkImageInfo ii = SkImageInfo::MakeA8(fPixels->width(), fPixels->height());
size_t rowBytes = fPixels->rowBytes();
@@ -106,5 +105,5 @@
GrBitmapTextureMaker maker(context, bitmap, GrBitmapTextureMaker::Cached::kNo, fit);
auto[textureView, ct] = maker.view(GrMipMapped::kNo);
- return textureView.asTextureProxyRef();
+ return textureView;
}
diff --git a/src/gpu/GrSWMaskHelper.h b/src/gpu/GrSWMaskHelper.h
index 0a042e1..8664f96 100644
--- a/src/gpu/GrSWMaskHelper.h
+++ b/src/gpu/GrSWMaskHelper.h
@@ -29,7 +29,7 @@
*
* draw one or more paths/rects specifying the required boolean ops
*
- * toTextureProxy(); // to get it from the internal bitmap to the GPU
+ * toTextureView(); // to get it from the internal bitmap to the GPU
*
* The result of this process will be the final mask (on the GPU) in the
* upper left hand corner of the texture.
@@ -51,7 +51,7 @@
// Draw a single path into the accumuation bitmap using the specified op
void drawShape(const GrShape&, const SkMatrix& matrix, SkRegion::Op op, GrAA, uint8_t alpha);
- sk_sp<GrTextureProxy> toTextureProxy(GrRecordingContext*, SkBackingFit fit);
+ GrSurfaceProxyView toTextureView(GrRecordingContext*, SkBackingFit fit);
// Reset the internal bitmap
void clear(uint8_t alpha) {
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 7ea30e2..6572ac7 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -142,7 +142,7 @@
}
void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
- sk_sp<GrTextureProxy> proxy,
+ GrSurfaceProxyView view,
GrRenderTargetContext* renderTargetContext,
GrPaint&& paint,
const GrUserStencilSettings& userStencilSettings,
@@ -164,18 +164,15 @@
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
paint.addCoverageFragmentProcessor(GrTextureEffect::Make(
std::move(view), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest));
DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
dstRect, invert);
}
-static sk_sp<GrTextureProxy> make_deferred_mask_texture_proxy(GrRecordingContext* context,
- SkBackingFit fit,
- SkISize dimensions) {
+static GrSurfaceProxyView make_deferred_mask_texture_view(GrRecordingContext* context,
+ SkBackingFit fit,
+ SkISize dimensions) {
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
const GrCaps* caps = context->priv().caps();
@@ -184,9 +181,10 @@
GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kAlpha_8);
- return proxyProvider->createProxy(format, dimensions, swizzle, GrRenderable::kNo, 1,
- kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, fit,
- SkBudgeted::kYes, GrProtected::kNo);
+ auto proxy = proxyProvider->createProxy(format, dimensions, swizzle, GrRenderable::kNo, 1,
+ kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, fit,
+ SkBudgeted::kYes, GrProtected::kNo);
+ return {std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle};
}
namespace {
@@ -323,11 +321,17 @@
}
sk_sp<GrTextureProxy> proxy;
+ GrSurfaceProxyView view;
if (useCache) {
- proxy = fProxyProvider->findOrCreateProxyByUniqueKey(maskKey, GrColorType::kAlpha_8,
- kTopLeft_GrSurfaceOrigin);
+ auto proxy = fProxyProvider->findOrCreateProxyByUniqueKey(maskKey, GrColorType::kAlpha_8,
+ kTopLeft_GrSurfaceOrigin);
+ if (proxy) {
+ GrSwizzle swizzle = args.fRenderTargetContext->caps()->getReadSwizzle(
+ proxy->backendFormat(), GrColorType::kAlpha_8);
+ view = {std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle};
+ }
}
- if (!proxy) {
+ if (!view) {
SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox;
GrAA aa = GrAA(GrAAType::kCoverage == args.fAAType);
@@ -337,8 +341,8 @@
}
if (taskGroup) {
- proxy = make_deferred_mask_texture_proxy(args.fContext, fit, boundsForMask->size());
- if (!proxy) {
+ view = make_deferred_mask_texture_view(args.fContext, fit, boundsForMask->size());
+ if (!view) {
return false;
}
@@ -359,32 +363,33 @@
uploaderRaw->signalAndFreeData();
};
taskGroup->add(std::move(drawAndUploadMask));
- proxy->texPriv().setDeferredUploader(std::move(uploader));
+ view.asTextureProxy()->texPriv().setDeferredUploader(std::move(uploader));
} else {
GrSWMaskHelper helper;
if (!helper.init(*boundsForMask)) {
return false;
}
helper.drawShape(*args.fShape, *args.fViewMatrix, SkRegion::kReplace_Op, aa, 0xFF);
- proxy = helper.toTextureProxy(args.fContext, fit);
+ view = helper.toTextureView(args.fContext, fit);
}
- if (!proxy) {
+ if (!view) {
return false;
}
if (useCache) {
- SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
- fProxyProvider->assignUniqueKeyToProxy(maskKey, proxy.get());
+ SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
+ fProxyProvider->assignUniqueKeyToProxy(maskKey, view.asTextureProxy());
args.fShape->addGenIDChangeListener(
sk_make_sp<PathInvalidator>(maskKey, args.fContext->priv().contextID()));
}
}
+ SkASSERT(view);
if (inverseFilled) {
DrawAroundInvPath(args.fRenderTargetContext, GrPaint::Clone(args.fPaint),
*args.fUserStencilSettings, *args.fClip, *args.fViewMatrix, devClipBounds,
unclippedDevShapeBounds);
}
- DrawToTargetWithShapeMask(std::move(proxy), args.fRenderTargetContext, std::move(args.fPaint),
+ DrawToTargetWithShapeMask(std::move(view), args.fRenderTargetContext, std::move(args.fPaint),
*args.fUserStencilSettings, *args.fClip, *args.fViewMatrix,
SkIPoint{boundsForMask->fLeft, boundsForMask->fTop}, *boundsForMask);
diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/GrSoftwarePathRenderer.h
index a510c7b..9166813 100644
--- a/src/gpu/GrSoftwarePathRenderer.h
+++ b/src/gpu/GrSoftwarePathRenderer.h
@@ -51,7 +51,7 @@
// This utility draws a path mask using a provided paint. The rectangle is drawn in device
// space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
// any fragment processors in the paint.
- static void DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy,
+ static void DrawToTargetWithShapeMask(GrSurfaceProxyView,
GrRenderTargetContext* renderTargetContext,
GrPaint&& paint,
const GrUserStencilSettings& userStencilSettings,
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 496e24c..b1ef4e2 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -638,7 +638,7 @@
namespace GrShadowRRectOp {
-static sk_sp<GrTextureProxy> create_falloff_texture(GrRecordingContext* context) {
+static GrSurfaceProxyView create_falloff_texture(GrRecordingContext* context) {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 0, "Shadow Gaussian Falloff");
@@ -646,36 +646,35 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- sk_sp<GrTextureProxy> falloffTexture = proxyProvider->findOrCreateProxyByUniqueKey(
- key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin);
- if (!falloffTexture) {
- static const int kWidth = 128;
- static const size_t kRowBytes = kWidth*GrColorTypeBytesPerPixel(GrColorType::kAlpha_8);
- SkImageInfo ii = SkImageInfo::MakeA8(kWidth, 1);
-
- SkBitmap bitmap;
- bitmap.allocPixels(ii, kRowBytes);
-
- unsigned char* values = (unsigned char*) bitmap.getPixels();
- for (int i = 0; i < 128; ++i) {
- SkScalar d = SK_Scalar1 - i/SkIntToScalar(127);
- values[i] = SkScalarRoundToInt((SkScalarExp(-4*d*d) - 0.018f)*255);
- }
- bitmap.setImmutable();
-
- GrBitmapTextureMaker maker(context, bitmap);
- auto[view, grCT] = maker.view(GrMipMapped::kNo);
- SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
-
- falloffTexture = view.asTextureProxyRef();
- if (!falloffTexture) {
- return nullptr;
- }
-
- proxyProvider->assignUniqueKeyToProxy(key, falloffTexture.get());
+ if (sk_sp<GrTextureProxy> falloffTexture = proxyProvider->findOrCreateProxyByUniqueKey(
+ key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin)) {
+ GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(falloffTexture->backendFormat(),
+ GrColorType::kAlpha_8);
+ return {std::move(falloffTexture), kTopLeft_GrSurfaceOrigin, swizzle};
}
- return falloffTexture;
+ static const int kWidth = 128;
+ static const size_t kRowBytes = kWidth * GrColorTypeBytesPerPixel(GrColorType::kAlpha_8);
+ SkImageInfo ii = SkImageInfo::MakeA8(kWidth, 1);
+
+ SkBitmap bitmap;
+ bitmap.allocPixels(ii, kRowBytes);
+
+ unsigned char* values = (unsigned char*)bitmap.getPixels();
+ for (int i = 0; i < 128; ++i) {
+ SkScalar d = SK_Scalar1 - i / SkIntToScalar(127);
+ values[i] = SkScalarRoundToInt((SkScalarExp(-4 * d * d) - 0.018f) * 255);
+ }
+ bitmap.setImmutable();
+
+ GrBitmapTextureMaker maker(context, bitmap);
+ auto[view, grCT] = maker.view(GrMipMapped::kNo);
+ SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
+
+ if (view) {
+ proxyProvider->assignUniqueKeyToProxy(key, view.asTextureProxy());
+ }
+ return view;
}
@@ -688,14 +687,10 @@
// Shadow rrect ops only handle simple circular rrects.
SkASSERT(viewMatrix.isSimilarity() && SkRRectPriv::EqualRadii(rrect));
- sk_sp<GrTextureProxy> falloffTexture = create_falloff_texture(context);
- if (!falloffTexture) {
+ GrSurfaceProxyView falloffView = create_falloff_texture(context);
+ if (!falloffView) {
return nullptr;
}
- GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(falloffTexture->backendFormat(),
- GrColorType::kAlpha_8);
-
- GrSurfaceProxyView falloffView(std::move(falloffTexture), kTopLeft_GrSurfaceOrigin, swizzle);
// Do any matrix crunching before we reset the draw state for device coords.
const SkRect& rrectBounds = rrect.getBounds();