aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrDrawOpAtlas.cpp18
-rw-r--r--src/gpu/GrDrawOpAtlas.h3
-rw-r--r--src/gpu/GrOnFlushResourceProvider.cpp6
-rw-r--r--src/gpu/GrOnFlushResourceProvider.h14
-rw-r--r--src/gpu/ops/GrSmallPathRenderer.h8
-rw-r--r--src/gpu/text/GrAtlasGlyphCache.h10
6 files changed, 49 insertions, 10 deletions
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index e564e63b04..b2780e6635 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -9,6 +9,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrOnFlushResourceProvider.h"
#include "GrOpFlushState.h"
#include "GrRectanizer.h"
#include "GrProxyProvider.h"
@@ -16,6 +17,23 @@
#include "GrTexture.h"
#include "GrTracing.h"
+// When proxy allocation is deferred until flush time the proxies acting as atlases require
+// special handling. This is because the usage that can be determined from the ops themselves
+// isn't sufficient. Independent of the ops there will be ASAP and inline uploads to the
+// atlases. Extending the usage interval of any op that uses an atlas to the start of the
+// flush (as is done for proxies that are used for sw-generated masks) also won't work because
+// the atlas persists even beyond the last use in an op - for a given flush. Given this, atlases
+// must explicitly manage the lifetime of their backing proxies via the onFlushCallback system
+// (which calls this method).
+void GrDrawOpAtlas::instantiate(GrOnFlushResourceProvider* onFlushResourceProvider) {
+ for (int i = 0; i < GrDrawOpAtlas::kMaxMultitexturePages; ++i) {
+ if (fProxies[i] && !fProxies[i]->priv().isInstantiated()) {
+ // If instantiation fails we expect the ops that rely on the atlas to be dropped
+ onFlushResourceProvider->instatiateProxy(fProxies[i].get());
+ }
+ }
+}
+
std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrContext* ctx, GrPixelConfig config, int width,
int height, int numPlotsX, int numPlotsY,
AllowMultitexturing allowMultitexturing,
diff --git a/src/gpu/GrDrawOpAtlas.h b/src/gpu/GrDrawOpAtlas.h
index edab2cbd24..98e956a43d 100644
--- a/src/gpu/GrDrawOpAtlas.h
+++ b/src/gpu/GrDrawOpAtlas.h
@@ -14,6 +14,7 @@
#include "ops/GrDrawOp.h"
+class GrOnFlushResourceProvider;
class GrRectanizer;
struct GrDrawOpAtlasConfig {
@@ -222,6 +223,8 @@ public:
return id & 0xff;
}
+ void instantiate(GrOnFlushResourceProvider*);
+
private:
uint32_t maxPages() const {
return AllowMultitexturing::kYes == fAllowMultitexturing ? kMaxMultitexturePages : 1;
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index 8de827c5b5..ba80631ad1 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -82,6 +82,12 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
return renderTargetContext;
}
+bool GrOnFlushResourceProvider::instatiateProxy(GrSurfaceProxy* proxy) {
+ auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider();
+
+ return proxy->instantiate(resourceProvider);
+}
+
sk_sp<GrBuffer> GrOnFlushResourceProvider::makeBuffer(GrBufferType intendedType, size_t size,
const void* data) {
auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider();
diff --git a/src/gpu/GrOnFlushResourceProvider.h b/src/gpu/GrOnFlushResourceProvider.h
index f4e4459738..633abe1411 100644
--- a/src/gpu/GrOnFlushResourceProvider.h
+++ b/src/gpu/GrOnFlushResourceProvider.h
@@ -69,15 +69,17 @@ private:
*/
class GrOnFlushResourceProvider {
public:
- sk_sp<GrRenderTargetContext> makeRenderTargetContext(const GrSurfaceDesc& desc,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props);
+ sk_sp<GrRenderTargetContext> makeRenderTargetContext(const GrSurfaceDesc&,
+ sk_sp<SkColorSpace>,
+ const SkSurfaceProps*);
// TODO: we only need this entry point as long as we have to pre-allocate the atlas.
// Remove it ASAP.
- sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy> proxy,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props);
+ sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
+ sk_sp<SkColorSpace>,
+ const SkSurfaceProps*);
+
+ bool instatiateProxy(GrSurfaceProxy*);
// Creates a GPU buffer with a "dynamic" access pattern.
sk_sp<GrBuffer> makeBuffer(GrBufferType, size_t, const void* data = nullptr);
diff --git a/src/gpu/ops/GrSmallPathRenderer.h b/src/gpu/ops/GrSmallPathRenderer.h
index b4fba10943..ef83c771a6 100644
--- a/src/gpu/ops/GrSmallPathRenderer.h
+++ b/src/gpu/ops/GrSmallPathRenderer.h
@@ -33,8 +33,12 @@ public:
// the list of active OnFlushBackkbackObjects in an freeGpuResources call (i.e., we accept the
// default retainOnFreeGpuResources implementation).
- void preFlush(GrOnFlushResourceProvider*, const uint32_t*, int,
- SkTArray<sk_sp<GrRenderTargetContext>>*) override {}
+ void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int,
+ SkTArray<sk_sp<GrRenderTargetContext>>*) override {
+ if (fAtlas) {
+ fAtlas->instantiate(onFlushResourceProvider);
+ }
+ }
void postFlush(GrDeferredUploadToken startTokenForNextFlush,
const uint32_t* opListIDs, int numOpListIDs) override {
diff --git a/src/gpu/text/GrAtlasGlyphCache.h b/src/gpu/text/GrAtlasGlyphCache.h
index c4e1528e7b..6c5ce767db 100644
--- a/src/gpu/text/GrAtlasGlyphCache.h
+++ b/src/gpu/text/GrAtlasGlyphCache.h
@@ -186,8 +186,14 @@ public:
// GrOnFlushCallbackObject overrides
- void preFlush(GrOnFlushResourceProvider*, const uint32_t*, int,
- SkTArray<sk_sp<GrRenderTargetContext>>*) override {}
+ void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int,
+ SkTArray<sk_sp<GrRenderTargetContext>>*) override {
+ for (int i = 0; i < kMaskFormatCount; ++i) {
+ if (fAtlases[i]) {
+ fAtlases[i]->instantiate(onFlushResourceProvider);
+ }
+ }
+ }
void postFlush(GrDeferredUploadToken startTokenForNextFlush,
const uint32_t* opListIDs, int numOpListIDs) override {