Switch MDB GrContextOptions over to Enable style

Change-Id: Id6541c346a13649c89ca3b9ccb13972976f9b973
Reviewed-on: https://skia-review.googlesource.com/105603
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2018-02-08 10:59:38 -05:00 committed by Skia Commit-Bot
parent f8cac79227
commit a3f70261cc
8 changed files with 71 additions and 26 deletions

View File

@ -69,6 +69,9 @@ protected:
}
fContext = SkAtlasTextContext::Make(fRenderer);
auto targetHandle = fRenderer->makeTargetHandle(kSize, kSize);
if (!targetHandle) {
return;
}
fTarget = SkAtlasTextTarget::Make(fContext, kSize, kSize, targetHandle);
fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic());
@ -82,7 +85,7 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
if (!fRenderer) {
if (!fRenderer || !fTarget || !fTarget->handle()) {
canvas->clear(SK_ColorRED);
return;
}

View File

@ -4,5 +4,7 @@
# found in the LICENSE file.
flutter_defines = [
"SK_SUPPORT_LEGACY_IMAGE_ENCODE_API",
"SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION",
"SK_DISABLE_RENDER_TARGET_SORTING",
"SK_SUPPORT_LEGACY_RECTMAKELARGEST",
]

View File

@ -144,14 +144,14 @@ struct GrContextOptions {
* Allow Ganesh to explicitly allocate resources at flush time rather than incrementally while
* drawing. This will eventually just be the way it is but, for now, it is optional.
*/
bool fExplicitlyAllocateGPUResources = false;
Enable fExplicitlyAllocateGPUResources = Enable::kDefault;
/**
* Allow Ganesh to sort the opLists prior to allocating resources. This is an optional
* behavior that is only relevant when 'fExplicitlyAllocateGPUResources' is enabled.
* Eventually this will just be what is done and will not be optional.
*/
bool fSortRenderTargets = false;
Enable fSortRenderTargets = Enable::kDefault;
/**
* Disables correctness workarounds that are enabled for particular GPUs, OSes, or drivers.

View File

@ -31,6 +31,41 @@
#include "GrTracing.h"
#include "text/GrAtlasTextContext.h"
// Turn on/off the sorting of opLists at flush time
#ifndef SK_DISABLE_RENDER_TARGET_SORTING
#define SK_DISABLE_RENDER_TARGET_SORTING
#endif
#ifdef SK_DISABLE_RENDER_TARGET_SORTING
static const bool kDefaultSortRenderTargets = false;
#else
static const bool kDefaultSortRenderTargets = true;
#endif
GrDrawingManager::GrDrawingManager(GrContext* context,
const GrPathRendererChain::Options& optionsForPathRendererChain,
const GrAtlasTextContext::Options& optionsForAtlasTextContext,
GrSingleOwner* singleOwner,
GrContextOptions::Enable sortRenderTargets)
: fContext(context)
, fOptionsForPathRendererChain(optionsForPathRendererChain)
, fOptionsForAtlasTextContext(optionsForAtlasTextContext)
, fSingleOwner(singleOwner)
, fAbandoned(false)
, fAtlasTextContext(nullptr)
, fPathRendererChain(nullptr)
, fSoftwarePathRenderer(nullptr)
, fFlushing(false) {
if (GrContextOptions::Enable::kNo == sortRenderTargets) {
fSortRenderTargets = false;
} else if (GrContextOptions::Enable::kYes == sortRenderTargets) {
fSortRenderTargets = true;
} else {
fSortRenderTargets = kDefaultSortRenderTargets;
}
}
void GrDrawingManager::cleanup() {
for (int i = 0; i < fOpLists.count(); ++i) {
// no opList should receive a new command after this

View File

@ -83,22 +83,9 @@ public:
void copyOpListsFromDDL(const SkDeferredDisplayList*, GrRenderTargetProxy* newDest);
private:
GrDrawingManager(GrContext* context,
const GrPathRendererChain::Options& optionsForPathRendererChain,
const GrAtlasTextContext::Options& optionsForAtlasTextContext,
GrSingleOwner* singleOwner,
bool sortRenderTargets)
: fContext(context)
, fOptionsForPathRendererChain(optionsForPathRendererChain)
, fOptionsForAtlasTextContext(optionsForAtlasTextContext)
, fSingleOwner(singleOwner)
, fAbandoned(false)
, fAtlasTextContext(nullptr)
, fPathRendererChain(nullptr)
, fSoftwarePathRenderer(nullptr)
, fFlushing(false)
, fSortRenderTargets(sortRenderTargets) {
}
GrDrawingManager(GrContext*, const GrPathRendererChain::Options&,
const GrAtlasTextContext::Options&, GrSingleOwner*,
GrContextOptions::Enable sortRenderTargets);
void abandon();
void cleanup();

View File

@ -30,18 +30,36 @@ GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);
const uint32_t GrResourceProvider::kMinScratchTextureSize = 16;
// Turn on/off the explicit distribution of GPU resources at flush time
#ifndef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
#define SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
#endif
#ifdef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
static const bool kDefaultExplicitlyAllocateGPUResources = false;
#else
static const bool kDefaultExplicitlyAllocateGPUResources = true;
#endif
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* owner,
bool explicitlyAllocateGPUResources)
GrContextOptions::Enable explicitlyAllocateGPUResources)
: fCache(cache)
, fGpu(gpu)
, fExplicitlyAllocateGPUResources(explicitlyAllocateGPUResources)
#ifdef SK_DEBUG
, fSingleOwner(owner)
#endif
{
if (GrContextOptions::Enable::kNo == explicitlyAllocateGPUResources) {
fExplicitlyAllocateGPUResources = false;
} else if (GrContextOptions::Enable::kYes == explicitlyAllocateGPUResources) {
fExplicitlyAllocateGPUResources = true;
} else {
fExplicitlyAllocateGPUResources = kDefaultExplicitlyAllocateGPUResources;
}
fCaps = sk_ref_sp(fGpu->caps());
GR_DEFINE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);

View File

@ -9,6 +9,7 @@
#define GrResourceProvider_DEFINED
#include "GrBuffer.h"
#include "GrContextOptions.h"
#include "GrPathRange.h"
#include "GrResourceCache.h"
#include "SkImageInfo.h"
@ -39,7 +40,8 @@ class SkTypeface;
*/
class GrResourceProvider {
public:
GrResourceProvider(GrGpu*, GrResourceCache*, GrSingleOwner*, bool explicitlyAllocate);
GrResourceProvider(GrGpu*, GrResourceCache*, GrSingleOwner*,
GrContextOptions::Enable explicitlyAllocateGPUResources);
/**
* Finds a resource in the cache, based on the specified key. Prior to calling this, the caller

View File

@ -95,10 +95,8 @@ void GrTextureProxyPriv::setDeferredUploader(std::unique_ptr<GrDeferredProxyUplo
}
void GrTextureProxyPriv::scheduleUpload(GrOpFlushState* flushState) {
SkASSERT(fTextureProxy->fDeferredUploader);
// Instantiate might have failed
if (fTextureProxy->fTarget) {
// The texture proxy's contents may already have been uploaded or instantiation may have failed
if (fTextureProxy->fDeferredUploader && fTextureProxy->fTarget) {
fTextureProxy->fDeferredUploader->scheduleUpload(flushState, fTextureProxy);
}
}