diff options
author | Robert Phillips <robertphillips@google.com> | 2018-02-01 15:49:54 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-02 18:21:59 +0000 |
commit | 7a9263906c677c0fa5636521e3cc58ba60837720 (patch) | |
tree | 0eba3834734ec9415fcd703fb40c805003f2989a /src/gpu/SkGr.cpp | |
parent | 68c5632d9216c2318aafadc91035a25cb94ca63a (diff) |
Disable texture strip atlasing for DDL
Ultimately we will want to perform inline and ASAP uploads for the
texture strip atlas. Unfortunately, that functionality relies on the
existance of the flushState (which we don't have for the opList-based
DDL implementation). For now we will punt and try storing the individual
texture strips in their own image-based texture proxy for DDLs.
Change-Id: Ic2ee0deb230172bda4a5d4b69cc802dbe84ad7ac
Reviewed-on: https://skia-review.googlesource.com/102464
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/SkGr.cpp')
-rw-r--r-- | src/gpu/SkGr.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 90fe4f62d6..ad996f82b6 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -23,6 +23,7 @@ #include "SkColorFilter.h" #include "SkConvertPixels.h" #include "SkData.h" +#include "SkImage_Base.h" #include "SkImageInfoPriv.h" #include "SkMaskFilterBase.h" #include "SkMessageBus.h" @@ -239,6 +240,43 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrProxyProvider* proxyProvider, return proxy; } +static void create_unique_key_for_image(const SkImage* image, GrUniqueKey* result) { + if (!image) { + result->reset(); // will be invalid + return; + } + + if (const SkBitmap* bm = as_IB(image)->onPeekBitmap()) { + SkIPoint origin = bm->pixelRefOrigin(); + SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bm->width(), bm->height()); + GrMakeKeyFromImageID(result, bm->getGenerationID(), subset); + return; + } + + GrMakeKeyFromImageID(result, image->uniqueID(), image->bounds()); +} + +sk_sp<GrTextureProxy> GrMakeCachedImageProxy(GrProxyProvider* proxyProvider, + sk_sp<SkImage> srcImage) { + sk_sp<GrTextureProxy> proxy; + GrUniqueKey originalKey; + + create_unique_key_for_image(srcImage.get(), &originalKey); + + if (originalKey.isValid()) { + proxy = proxyProvider->findOrCreateProxyByUniqueKey(originalKey, kTopLeft_GrSurfaceOrigin); + } + if (!proxy) { + proxy = proxyProvider->createTextureProxy(std::move(srcImage), kNone_GrSurfaceFlags, + kTopLeft_GrSurfaceOrigin, 0, SkBudgeted::kYes); + if (proxy && originalKey.isValid()) { + proxyProvider->assignUniqueKeyToProxy(originalKey, proxy.get()); + } + } + + return proxy; +} + /////////////////////////////////////////////////////////////////////////////// GrColor4f SkColorToPremulGrColor4f(SkColor c, const GrColorSpaceInfo& colorSpaceInfo) { |