diff options
author | Brian Salomon <bsalomon@google.com> | 2019-01-10 16:33:06 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2019-01-10 16:33:11 +0000 |
commit | 426ba463d54c7fdd6f3b94f88b66c10c0212dafd (patch) | |
tree | 2cab189416a5cd1a3cd1f871e8bad8a0a3307d41 /tools | |
parent | 24c1cf086c48adf6298f726b211de119c0085bb5 (diff) | |
download | skqp-426ba463d54c7fdd6f3b94f88b66c10c0212dafd.tar.gz |
Revert "Reuse GrTexture instances when the same GrBackendTexture is used to"
This reverts commit 559c617137517ece202d0f7cdb6b1cd0a715cf2e.
Reason for revert: breaking things
Original change's description:
> Reuse GrTexture instances when the same GrBackendTexture is used to
> repeatedly fulfill a promise SkImage.
>
> Bug: skia:8613
>
> Change-Id: I35c76435d630d2daa034e0c3efb59666bfd6882a
> Reviewed-on: https://skia-review.googlesource.com/c/175820
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
TBR=bsalomon@google.com,robertphillips@google.com
Change-Id: I7548809945d0a875fdb9387398bbc45e733c0846
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:8613
Reviewed-on: https://skia-review.googlesource.com/c/182960
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/DDLPromiseImageHelper.cpp | 57 | ||||
-rw-r--r-- | tools/DDLPromiseImageHelper.h | 68 |
2 files changed, 24 insertions, 101 deletions
diff --git a/tools/DDLPromiseImageHelper.cpp b/tools/DDLPromiseImageHelper.cpp index 62d76cbaa8..2586835868 100644 --- a/tools/DDLPromiseImageHelper.cpp +++ b/tools/DDLPromiseImageHelper.cpp @@ -17,30 +17,13 @@ #include "SkYUVASizeInfo.h" DDLPromiseImageHelper::PromiseImageCallbackContext::~PromiseImageCallbackContext() { - SkASSERT(fDoneCnt == fNumImages); - SkASSERT(!fUnreleasedFulfills); - SkASSERT(fTotalReleases == fTotalFulfills); - SkASSERT(!fTotalFulfills || fDoneCnt); GrGpu* gpu = fContext->contextPriv().getGpu(); - if (fPromiseImageTexture.isValid()) { - gpu->deleteTestingOnlyBackendTexture(fPromiseImageTexture.backendTexture()); + if (fBackendTexture.isValid()) { + gpu->deleteTestingOnlyBackendTexture(fBackendTexture); } } -void DDLPromiseImageHelper::PromiseImageCallbackContext::setBackendTexture( - const GrBackendTexture& backendTexture) { - SkASSERT(!fUnreleasedFulfills); - if (fPromiseImageTexture.isValid()) { - GrGpu* gpu = fContext->contextPriv().getGpu(); - - if (fPromiseImageTexture.isValid()) { - gpu->deleteTestingOnlyBackendTexture(fPromiseImageTexture.backendTexture()); - } - } - fPromiseImageTexture = SkPromiseImageTexture{backendTexture}; -} - /////////////////////////////////////////////////////////////////////////////////////////////////// DDLPromiseImageHelper::~DDLPromiseImageHelper() {} @@ -113,7 +96,7 @@ void DDLPromiseImageHelper::uploadAllToGPU(GrContext* context) { GrGpu* gpu = context->contextPriv().getGpu(); SkASSERT(gpu); - for (int i = 0; i < fImageInfo.count(); i += 2) { + for (int i = 0; i < fImageInfo.count(); ++i) { const PromiseImageInfo& info = fImageInfo[i]; // DDL TODO: how can we tell if we need mipmapping! @@ -128,7 +111,7 @@ void DDLPromiseImageHelper::uploadAllToGPU(GrContext* context) { callbackContext->setBackendTexture(create_yuva_texture(gpu, yuvPixmap, info.yuvaIndices(), j)); - SkASSERT(callbackContext->promiseImageTexture()->isValid()); + SkAssertResult(callbackContext->backendTexture().isValid()); fImageInfo[i].setCallbackContext(j, std::move(callbackContext)); } @@ -150,34 +133,7 @@ void DDLPromiseImageHelper::uploadAllToGPU(GrContext* context) { fImageInfo[i].setCallbackContext(0, std::move(callbackContext)); } - } -} - -void DDLPromiseImageHelper::replaceEveryOtherPromiseTexture(GrContext* context) { - GrGpu* gpu = context->contextPriv().getGpu(); - SkASSERT(gpu); - for (int i = 0; i < fImageInfo.count(); ++i) { - PromiseImageInfo& info = fImageInfo[i]; - - // DDL TODO: how can we tell if we need mipmapping! - if (info.isYUV()) { - int numPixmaps; - SkAssertResult(SkYUVAIndex::AreValidIndices(info.yuvaIndices(), &numPixmaps)); - for (int j = 0; j < numPixmaps; ++j) { - const SkPixmap& yuvPixmap = info.yuvPixmap(j); - info.callbackContext(j)->setBackendTexture( - create_yuva_texture(gpu, yuvPixmap, info.yuvaIndices(), j)); - SkASSERT(info.callbackContext(j)->promiseImageTexture()->isValid()); - } - } else { - const SkBitmap& bm = info.normalBitmap(); - info.callbackContext(0)->setBackendTexture(gpu->createTestingOnlyBackendTexture( - bm.getPixels(), bm.width(), bm.height(), bm.colorType(), false, - GrMipMapped::kNo, bm.rowBytes())); - // The GMs sometimes request too large an image - // SkAssertResult(callbackContext->backendTexture().isValid()); - } } } @@ -250,9 +206,7 @@ sk_sp<SkImage> DDLPromiseImageHelper::PromiseImageCreator(const void* rawData, DDLPromiseImageHelper::PromiseImageReleaseProc, DDLPromiseImageHelper::PromiseImageDoneProc, contexts); - for (int i = 0; i < textureCount; ++i) { - curImage.callbackContext(i)->wasAddedToImage(); - } + } else { const GrBackendTexture& backendTex = curImage.backendTexture(0); GrBackendFormat backendFormat = backendTex.getBackendFormat(); @@ -273,7 +227,6 @@ sk_sp<SkImage> DDLPromiseImageHelper::PromiseImageCreator(const void* rawData, DDLPromiseImageHelper::PromiseImageReleaseProc, DDLPromiseImageHelper::PromiseImageDoneProc, (void*) curImage.refCallbackContext(0).release()); - curImage.callbackContext(0)->wasAddedToImage(); } perRecorderContext->fPromiseImages->push_back(image); SkASSERT(image); diff --git a/tools/DDLPromiseImageHelper.h b/tools/DDLPromiseImageHelper.h index f8627aab36..7a636ce15b 100644 --- a/tools/DDLPromiseImageHelper.h +++ b/tools/DDLPromiseImageHelper.h @@ -8,17 +8,16 @@ #ifndef PromiseImageHelper_DEFINED #define PromiseImageHelper_DEFINED -#include "GrBackendSurface.h" #include "SkBitmap.h" -#include "SkCachedData.h" -#include "SkDeferredDisplayListRecorder.h" -#include "SkPromiseImageTexture.h" #include "SkTArray.h" -#include "SkTLazy.h" + +#include "GrBackendSurface.h" +#include "SkCachedData.h" #include "SkYUVAIndex.h" #include "SkYUVASizeInfo.h" class GrContext; +class SkDeferredDisplayListRecorder; class SkImage; class SkPicture; struct SkYUVAIndex; @@ -55,10 +54,6 @@ public: void uploadAllToGPU(GrContext* context); - // Change the backing store texture for half the images. (Must ensure all fulfilled images are - // released before calling this.). - void replaceEveryOtherPromiseTexture(GrContext*); - // reinflate a deflated SKP, replacing all the indices with promise images. sk_sp<SkPicture> reinflateSKP(SkDeferredDisplayListRecorder*, SkData* compressedPicture, @@ -81,37 +76,16 @@ private: ~PromiseImageCallbackContext(); - void setBackendTexture(const GrBackendTexture& backendTexture); - - void fulfill() { - SkASSERT(fUnreleasedFulfills >= 0); - ++fUnreleasedFulfills; - ++fTotalFulfills; + void setBackendTexture(const GrBackendTexture& backendTexture) { + SkASSERT(!fBackendTexture.isValid()); + fBackendTexture = backendTexture; } - void release() { - SkASSERT(fUnreleasedFulfills > 0); - --fUnreleasedFulfills; - ++fTotalReleases; - } - - void done() { - ++fDoneCnt; - SkASSERT(fDoneCnt <= fNumImages); - } - - void wasAddedToImage() { fNumImages++; } - - SkPromiseImageTexture* promiseImageTexture() { return &fPromiseImageTexture; } + const GrBackendTexture& backendTexture() const { return fBackendTexture; } private: - GrContext* fContext; - SkPromiseImageTexture fPromiseImageTexture; - int fNumImages = 0; - int fTotalFulfills = 0; - int fTotalReleases = 0; - int fUnreleasedFulfills = 0; - int fDoneCnt = 0; + GrContext* fContext; + GrBackendTexture fBackendTexture; typedef SkRefCnt INHERITED; }; @@ -160,7 +134,7 @@ private: SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVASizeInfo::kMaxCount : 1)); fCallbackContexts[index] = callbackContext; } - PromiseImageCallbackContext* callbackContext(int index) const { + PromiseImageCallbackContext* callbackContext(int index) { SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVASizeInfo::kMaxCount : 1)); return fCallbackContexts[index].get(); } @@ -171,7 +145,7 @@ private: const GrBackendTexture& backendTexture(int index) const { SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVASizeInfo::kMaxCount : 1)); - return fCallbackContexts[index]->promiseImageTexture()->backendTexture(); + return fCallbackContexts[index]->backendTexture(); } void setNormalBitmap(const SkBitmap& bm) { fBitmap = bm; } @@ -216,24 +190,21 @@ private: SkTArray<sk_sp<SkImage>>* fPromiseImages; }; - static SkPromiseImageTexture* PromiseImageFulfillProc(void* textureContext) { + static void PromiseImageFulfillProc(void* textureContext, GrBackendTexture* outTexture) { auto callbackContext = static_cast<PromiseImageCallbackContext*>(textureContext); - SkASSERT(callbackContext->promiseImageTexture()->isValid()); - callbackContext->fulfill(); - return callbackContext->promiseImageTexture(); + SkASSERT(callbackContext->backendTexture().isValid()); + *outTexture = callbackContext->backendTexture(); } - static void PromiseImageReleaseProc(void* textureContext, - const SkPromiseImageTexture* texture) { + static void PromiseImageReleaseProc(void* textureContext) { +#ifdef SK_DEBUG auto callbackContext = static_cast<PromiseImageCallbackContext*>(textureContext); - callbackContext->release(); - SkASSERT(texture == callbackContext->promiseImageTexture()); - SkASSERT(callbackContext->promiseImageTexture()->isValid()); + SkASSERT(callbackContext->backendTexture().isValid()); +#endif } static void PromiseImageDoneProc(void* textureContext) { auto callbackContext = static_cast<PromiseImageCallbackContext*>(textureContext); - callbackContext->done(); callbackContext->unref(); } @@ -241,7 +212,6 @@ private: bool isValidID(int id) const { return id >= 0 && id < fImageInfo.count(); } const PromiseImageInfo& getInfo(int id) const { return fImageInfo[id]; } - void uploadImage(GrContext*, PromiseImageInfo*); // returns -1 if not found int findImage(SkImage* image) const; |