aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/atlastext.cpp5
-rw-r--r--gn/flutter_defines.gni2
-rw-r--r--include/gpu/GrContextOptions.h4
-rw-r--r--src/gpu/GrDrawingManager.cpp35
-rw-r--r--src/gpu/GrDrawingManager.h19
-rw-r--r--src/gpu/GrResourceProvider.cpp22
-rw-r--r--src/gpu/GrResourceProvider.h4
-rw-r--r--src/gpu/GrTextureProxy.cpp6
8 files changed, 71 insertions, 26 deletions
diff --git a/gm/atlastext.cpp b/gm/atlastext.cpp
index ac5b3e4582..226b83fdd7 100644
--- a/gm/atlastext.cpp
+++ b/gm/atlastext.cpp
@@ -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;
}
diff --git a/gn/flutter_defines.gni b/gn/flutter_defines.gni
index 83e0a11318..0907b1036c 100644
--- a/gn/flutter_defines.gni
+++ b/gn/flutter_defines.gni
@@ -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",
]
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index 0cf4553ac9..338c538963 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -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.
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 703bc0a92d..cba23b4539 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -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
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 200d0cafce..050d707ec4 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -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();
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index c9575b26dc..17da9a7e8c 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -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);
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 7b5fb60ea1..caa108747d 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -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
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 13e124021f..3362ec81d4 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -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);
}
}