diff options
author | Brian Salomon <bsalomon@google.com> | 2017-08-24 21:28:04 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-24 21:34:38 +0000 |
commit | 87ae9895692e4a97873a510178003d1ba70ab79a (patch) | |
tree | e7c66b2fc574bf3795a27ca81bf9b3301cd9d0a1 /src/gpu/GrSWMaskHelper.cpp | |
parent | 59c7a6e6e252359dfcd84dc82986354398e2e8c3 (diff) |
Revert "Threaded generation of software paths"
This reverts commit 76323bc0615044a5921afef0e19a350f3d04ffe0.
Reason for revert: Breaking NUC bots in threaded gm comparison:
https://chromium-swarm.appspot.com/task?id=382e589753187f10&refresh=10
Original change's description:
> Threaded generation of software paths
>
> All information needed by the thread is captured by the prepare
> callback object, the lambda captures a pointer to that, and does the
> mask render. Once it's done, it signals the semaphore (also owned by the
> callback). The callback defers the semaphore wait even longer (into the
> ASAP upload), so the odds of waiting for the thread are REALLY low.
>
> Also did a bunch of cleanup along the way, and put in some trace markers
> so we can monitor how well this is working.
>
> Traces of a GM that includes GPU and SW path rendering (path-reverse):
>
> Original:
> https://screenshot.googleplex.com/f5BG3901tQg.png
> Threaded, with wait in the callback (notice pre flush callback blocking):
> https://screenshot.googleplex.com/htOSZFE2s04.png
> Current version, with wait deferred to ASAP upload function:
> https://screenshot.googleplex.com/GHjD0U3C34q.png
>
> Bug: skia:
> Change-Id: I3d5a230bbd68eb35e1f0574b308485c691435790
> Reviewed-on: https://skia-review.googlesource.com/36560
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=egdaniel@google.com,mtklein@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com
Change-Id: Icac0918a3771859f671b69ae07ae0fedd3ebb3db
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/38560
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrSWMaskHelper.cpp')
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index af0d1bdc22..eb3986525e 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -6,12 +6,12 @@ */ #include "GrSWMaskHelper.h" - #include "GrContext.h" #include "GrContextPriv.h" #include "GrShape.h" #include "GrSurfaceContext.h" #include "GrTextureProxy.h" +#include "SkDistanceFieldGen.h" /* * Convert a boolean operation into a transfer mode code @@ -76,13 +76,13 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds, const SkMatrix* matrix) { SkIRect bounds = SkIRect::MakeWH(resultBounds.width(), resultBounds.height()); const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(bounds.width(), bounds.height()); - if (!fPixels->tryAlloc(bmImageInfo)) { + if (!fPixels.tryAlloc(bmImageInfo)) { return false; } - fPixels->erase(0); + fPixels.erase(0); sk_bzero(&fDraw, sizeof(fDraw)); - fDraw.fDst = *fPixels; + fDraw.fDst = fPixels; fRasterClip.setRect(bounds); fDraw.fRC = &fRasterClip; fDraw.fMatrix = &fMatrix; @@ -92,8 +92,8 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds, const SkMatrix* matrix) { sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrContext* context, SkBackingFit fit) { GrSurfaceDesc desc; desc.fOrigin = kTopLeft_GrSurfaceOrigin; - desc.fWidth = fPixels->width(); - desc.fHeight = fPixels->height(); + desc.fWidth = fPixels.width(); + desc.fHeight = fPixels.height(); desc.fConfig = kAlpha_8_GrPixelConfig; sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeDeferredSurfaceContext( @@ -105,9 +105,39 @@ sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrContext* context, SkBacki } SkImageInfo ii = SkImageInfo::MakeA8(desc.fWidth, desc.fHeight); - if (!sContext->writePixels(ii, fPixels->addr(), fPixels->rowBytes(), 0, 0)) { + if (!sContext->writePixels(ii, fPixels.addr(), fPixels.rowBytes(), 0, 0)) { return nullptr; } return sContext->asTextureProxyRef(); } + +/** + * Convert mask generation results to a signed distance field + */ +void GrSWMaskHelper::toSDF(unsigned char* sdf) { + SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fPixels.addr(), + fPixels.width(), fPixels.height(), fPixels.rowBytes()); +} + +//////////////////////////////////////////////////////////////////////////////// +/** + * Software rasterizes shape to A8 mask and uploads the result to a scratch texture. Returns the + * resulting texture on success; nullptr on failure. + */ +sk_sp<GrTextureProxy> GrSWMaskHelper::DrawShapeMaskToTexture(GrContext* context, + const GrShape& shape, + const SkIRect& resultBounds, + GrAA aa, + SkBackingFit fit, + const SkMatrix* matrix) { + GrSWMaskHelper helper; + + if (!helper.init(resultBounds, matrix)) { + return nullptr; + } + + helper.drawShape(shape, SkRegion::kReplace_Op, aa, 0xFF); + + return helper.toTextureProxy(context, fit); +} |