Revert "Migrate uses of deferred proxies to lazy proxies"
This reverts commit 990a0d8b6563941d69aa24ecae847be150ab1128.
Reason for revert: Keeping it. Deferred proxies are uploaded later than lazy and we want that for this use case.
Original change's description:
> Migrate uses of deferred proxies to lazy proxies
>
> A follow-up CL removes the deferred proxies system entirely.
>
> Bug: skia:11288
> Change-Id: Ic5b3ce820ea946f6ae27bd763c0f389caf8863d1
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366716
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Adlai Holler <adlai@google.com>
TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: skia:11288
Change-Id: I9ced532d013805afae3b20baa53cab31cae2b953
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368797
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
diff --git a/src/gpu/GrClipStack.cpp b/src/gpu/GrClipStack.cpp
index 8664fa8..ec85eaf 100644
--- a/src/gpu/GrClipStack.cpp
+++ b/src/gpu/GrClipStack.cpp
@@ -317,19 +317,62 @@
const GrClipStack::Element** elements, int count) {
SkASSERT(count > 0);
- SkTArray<GrClipStack::Element> data(count);
- for (int i = 0; i < count; ++i) {
- data.push_back(*(elements[i]));
+ SkTaskGroup* taskGroup = nullptr;
+ if (auto direct = context->asDirectContext()) {
+ taskGroup = direct->priv().getTaskGroup();
}
- return GrSWMaskHelper::MakeTexture(bounds,
- context,
- SkBackingFit::kApprox,
- [data{std::move(data)}](GrSWMaskHelper* helper) {
- TRACE_EVENT0("skia.gpu", "SW Clip Mask Render");
- for (int i = 0; i < data.count(); ++i) {
- draw_to_sw_mask(helper, data[i], i == 0);
+
+ if (taskGroup) {
+ const GrCaps* caps = context->priv().caps();
+ GrProxyProvider* proxyProvider = context->priv().proxyProvider();
+
+ // Create our texture proxy
+ GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kAlpha_8,
+ GrRenderable::kNo);
+
+ GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kAlpha_8);
+ auto proxy = proxyProvider->createProxy(format, bounds.size(), GrRenderable::kNo, 1,
+ GrMipMapped::kNo, SkBackingFit::kApprox,
+ SkBudgeted::kYes, GrProtected::kNo);
+
+ // Since this will be rendered on another thread, make a copy of the elements in case
+ // the clip stack is modified on the main thread
+ using Uploader = GrTDeferredProxyUploader<SkTArray<GrClipStack::Element>>;
+ std::unique_ptr<Uploader> uploader = std::make_unique<Uploader>(count);
+ for (int i = 0; i < count; ++i) {
+ uploader->data().push_back(*(elements[i]));
}
- });
+
+ Uploader* uploaderRaw = uploader.get();
+ auto drawAndUploadMask = [uploaderRaw, bounds] {
+ TRACE_EVENT0("skia.gpu", "Threaded SW Clip Mask Render");
+ GrSWMaskHelper helper(uploaderRaw->getPixels());
+ if (helper.init(bounds)) {
+ for (int i = 0; i < uploaderRaw->data().count(); ++i) {
+ draw_to_sw_mask(&helper, uploaderRaw->data()[i], i == 0);
+ }
+ } else {
+ SkDEBUGFAIL("Unable to allocate SW clip mask.");
+ }
+ uploaderRaw->signalAndFreeData();
+ };
+
+ taskGroup->add(std::move(drawAndUploadMask));
+ proxy->texPriv().setDeferredUploader(std::move(uploader));
+
+ return {std::move(proxy), kMaskOrigin, swizzle};
+ } else {
+ GrSWMaskHelper helper;
+ if (!helper.init(bounds)) {
+ return {};
+ }
+
+ for (int i = 0; i < count; ++i) {
+ draw_to_sw_mask(&helper,*(elements[i]), i == 0);
+ }
+
+ return helper.toTextureView(context, SkBackingFit::kApprox);
+ }
}
static void render_stencil_mask(GrRecordingContext* context, GrSurfaceDrawContext* rtc,