GrContext option to prevent GPU based YUV -> RGB

Rob and I spent a long time debugging why this wasn't working for
Flutter - doing the more complex operations on the loading thread
produces a blank texture when it's used later on the drawing thread.

Limiting ourselves to just creating and uploading RGBA data fixes
that. We need to debug what's going wrong, but in the meantime, this
lets Flutter use Skia APIs to manage GPU uploading and lifetime of
texture-backed images, while still doing those uploads on their IO
thread.

BUG=skia:

Change-Id: Ibf5c37f2439814544beab8c93c2a646f7a9e779d
Reviewed-on: https://skia-review.googlesource.com/8443
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2017-02-14 14:15:48 -05:00 committed by Skia Commit-Bot
parent 431815dcfb
commit 46da1cc9f2
5 changed files with 12 additions and 1 deletions

View File

@ -394,6 +394,7 @@ private:
GrAtlasGlyphCache* fAtlasGlyphCache;
std::unique_ptr<GrTextBlobCache> fTextBlobCache;
bool fDisableGpuYUVConversion;
bool fDidTestPMConversions;
int fPMToUPMConversion;
int fUPMToPMConversion;

View File

@ -85,6 +85,12 @@ struct GrContextOptions {
* sRGB support.
*/
bool fRequireDecodeDisableForSRGB = true;
/**
* If true, the GPU will not be used to perform YUV -> RGB conversion when generating
* textures from codec-backed images.
*/
bool fDisableGpuYUVConversion = false;
};
#endif

View File

@ -17,6 +17,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpuResourcePriv.h"
#include "GrImageTextureMaker.h"
#include "GrResourceKey.h"
@ -569,7 +570,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori
#endif
// 4. Ask the generator to return YUV planes, which the GPU can convert
{
if (!ctx->contextPriv().disableGpuYUVConversion()) {
ScopedGenerator generator(fSharedGenerator);
Generator_GrYUVProvider provider(generator);
sk_sp<GrTexture> tex = provider.refAsTexture(ctx, desc, true);

View File

@ -91,6 +91,7 @@ void GrContext::initCommon(const GrContextOptions& options) {
fResourceCache = new GrResourceCache(fCaps);
fResourceProvider = new GrResourceProvider(fGpu, fResourceCache, &fSingleOwner);
fDisableGpuYUVConversion = options.fDisableGpuYUVConversion;
fDidTestPMConversions = false;
GrRenderTargetOpList::Options rtOpListOptions;

View File

@ -57,6 +57,8 @@ public:
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* = nullptr);
bool disableGpuYUVConversion() const { return fContext->fDisableGpuYUVConversion; }
private:
explicit GrContextPriv(GrContext* context) : fContext(context) {}
GrContextPriv(const GrContextPriv&) {} // unimpl