aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ccpr
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-05-31 12:43:27 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-31 17:27:43 +0000
commit774168efac172d096cd7f09841bce51650cb6e84 (patch)
tree1433b93978baaf92439289fe5a0a3e648a73974f /src/gpu/ccpr
parente304a8a21b0bc40c3a7d85a96371a21180750076 (diff)
Allow CCPR in DDL mode (take 2)
A lot of the changes to get this compiling on the win_chromium_compile_dbg_ng bot (i.e., moving a lot of header files to private) should be undone if that bot is ever "fixed". Bug: skia:7988 Change-Id: I704ff793d80b18e7312048538874498824803580 Reviewed-on: https://skia-review.googlesource.com/130920 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/ccpr')
-rw-r--r--src/gpu/ccpr/GrCCClipPath.h79
-rw-r--r--src/gpu/ccpr/GrCCClipProcessor.cpp2
-rw-r--r--src/gpu/ccpr/GrCCDrawPathsOp.h2
-rw-r--r--src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp22
-rw-r--r--src/gpu/ccpr/GrCoverageCountingPathRenderer.h43
5 files changed, 36 insertions, 112 deletions
diff --git a/src/gpu/ccpr/GrCCClipPath.h b/src/gpu/ccpr/GrCCClipPath.h
deleted file mode 100644
index f15cc9c756..0000000000
--- a/src/gpu/ccpr/GrCCClipPath.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrCCClipPath_DEFINED
-#define GrCCClipPath_DEFINED
-
-#include "GrTextureProxy.h"
-#include "SkPath.h"
-
-class GrCCAtlas;
-class GrCCPerFlushResources;
-class GrOnFlushResourceProvider;
-class GrProxyProvider;
-
-/**
- * These are keyed by SkPath generation ID, and store which device-space paths are accessed and
- * where by clip FPs in a given opList. A single GrCCClipPath can be referenced by multiple FPs. At
- * flush time their coverage count masks are packed into atlas(es) alongside normal DrawPathOps.
- */
-class GrCCClipPath {
-public:
- GrCCClipPath() = default;
- GrCCClipPath(const GrCCClipPath&) = delete;
-
- ~GrCCClipPath() {
- // Ensure no clip FPs exist with a dangling pointer back into this class.
- SkASSERT(!fAtlasLazyProxy || fAtlasLazyProxy->isUnique_debugOnly());
- // Ensure no lazy proxy callbacks exist with a dangling pointer back into this class.
- SkASSERT(fHasAtlasTransform);
- }
-
- bool isInitialized() const { return fAtlasLazyProxy != nullptr; }
- void init(GrProxyProvider* proxyProvider,
- const SkPath& deviceSpacePath, const SkIRect& accessRect,
- int rtWidth, int rtHeight);
-
- void addAccess(const SkIRect& accessRect) {
- SkASSERT(this->isInitialized());
- fAccessRect.join(accessRect);
- }
- GrTextureProxy* atlasLazyProxy() const {
- SkASSERT(this->isInitialized());
- return fAtlasLazyProxy.get();
- }
- const SkPath& deviceSpacePath() const {
- SkASSERT(this->isInitialized());
- return fDeviceSpacePath;
- }
- const SkIRect& pathDevIBounds() const {
- SkASSERT(this->isInitialized());
- return fPathDevIBounds;
- }
-
- void renderPathInAtlas(GrCCPerFlushResources*, GrOnFlushResourceProvider*);
-
- const SkVector& atlasScale() const { SkASSERT(fHasAtlasTransform); return fAtlasScale; }
- const SkVector& atlasTranslate() const { SkASSERT(fHasAtlasTransform); return fAtlasTranslate; }
-
-private:
- sk_sp<GrTextureProxy> fAtlasLazyProxy;
- SkPath fDeviceSpacePath;
- SkIRect fPathDevIBounds;
- SkIRect fAccessRect;
-
- const GrCCAtlas* fAtlas = nullptr;
- int16_t fAtlasOffsetX;
- int16_t fAtlasOffsetY;
- SkDEBUGCODE(bool fHasAtlas = false);
-
- SkVector fAtlasScale;
- SkVector fAtlasTranslate;
- SkDEBUGCODE(bool fHasAtlasTransform = false);
-};
-
-#endif
diff --git a/src/gpu/ccpr/GrCCClipProcessor.cpp b/src/gpu/ccpr/GrCCClipProcessor.cpp
index d4da596039..91d689246c 100644
--- a/src/gpu/ccpr/GrCCClipProcessor.cpp
+++ b/src/gpu/ccpr/GrCCClipProcessor.cpp
@@ -7,10 +7,10 @@
#include "GrCCClipProcessor.h"
+#include "GrCCClipPath.h"
#include "GrTexture.h"
#include "GrTextureProxy.h"
#include "SkMakeUnique.h"
-#include "ccpr/GrCCClipPath.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.h b/src/gpu/ccpr/GrCCDrawPathsOp.h
index 92ba3dd4c7..9189e5a757 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.h
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.h
@@ -16,7 +16,7 @@
class GrCCAtlas;
class GrCCPerFlushResources;
-struct GrCCPerOpListPaths;
+class GrCCPerOpListPaths;
/**
* This is the Op that draws paths to the actual canvas, using atlases generated by CCPR.
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index d51c0b525a..c8fafeb566 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -32,6 +32,18 @@ static void crop_path(const SkPath& path, const SkIRect& cropbox, SkPath* out) {
out->setIsVolatile(true);
}
+
+GrCCPerOpListPaths::~GrCCPerOpListPaths() {
+ // Ensure there are no surviving DrawPathsOps with a dangling pointer into this class.
+ if (!fDrawOps.isEmpty()) {
+ SK_ABORT("GrCCDrawPathsOp(s) not deleted during flush");
+ }
+ // Clip lazy proxies also reference this class from their callbacks, but those callbacks
+ // are only invoked at flush time while we are still alive. (Unlike DrawPathsOps, that
+ // unregister themselves upon destruction.) So it shouldn't matter if any clip proxies
+ // are still around.
+}
+
bool GrCoverageCountingPathRenderer::IsSupported(const GrCaps& caps) {
const GrShaderCaps& shaderCaps = *caps.shaderCaps();
return shaderCaps.integerSupport() && shaderCaps.flatInterpolationSupport() &&
@@ -50,7 +62,7 @@ sk_sp<GrCoverageCountingPathRenderer> GrCoverageCountingPathRenderer::CreateIfSu
GrCCPerOpListPaths* GrCoverageCountingPathRenderer::lookupPendingPaths(uint32_t opListID) {
auto it = fPendingPaths.find(opListID);
if (fPendingPaths.end() == it) {
- auto paths = skstd::make_unique<GrCCPerOpListPaths>();
+ sk_sp<GrCCPerOpListPaths> paths = sk_make_sp<GrCCPerOpListPaths>();
it = fPendingPaths.insert(std::make_pair(opListID, std::move(paths))).first;
}
return it->second.get();
@@ -227,6 +239,7 @@ void GrCoverageCountingPathRenderer::preFlush(GrOnFlushResourceProvider* onFlush
// Commit flushing paths to the resources once they are successfully completed.
for (auto& flushingPaths : fFlushingPaths) {
+ SkASSERT(!flushingPaths->fFlushResources);
flushingPaths->fFlushResources = resources;
}
}
@@ -234,6 +247,13 @@ void GrCoverageCountingPathRenderer::preFlush(GrOnFlushResourceProvider* onFlush
void GrCoverageCountingPathRenderer::postFlush(GrDeferredUploadToken, const uint32_t* opListIDs,
int numOpListIDs) {
SkASSERT(fFlushing);
+
+ // In DDL mode these aren't guaranteed to be deleted so we must clear out the perFlush
+ // resources manually.
+ for (auto& flushingPaths : fFlushingPaths) {
+ flushingPaths->fFlushResources = nullptr;
+ }
+
// We wait to erase these until after flush, once Ops and FPs are done accessing their data.
fFlushingPaths.reset();
SkDEBUGCODE(fFlushing = false);
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
index d10186601c..4032bd51d5 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
@@ -8,38 +8,15 @@
#ifndef GrCoverageCountingPathRenderer_DEFINED
#define GrCoverageCountingPathRenderer_DEFINED
+#include "GrCCPerOpListPaths.h"
#include "GrPathRenderer.h"
#include "GrRenderTargetOpList.h"
-#include "SkArenaAlloc.h"
-#include "SkTInternalLList.h"
-#include "ccpr/GrCCClipPath.h"
#include "ccpr/GrCCPerFlushResources.h"
#include <map>
class GrCCDrawPathsOp;
/**
- * Tracks all the paths in a given opList that will be drawn when it flushes.
- */
-struct GrCCPerOpListPaths {
- ~GrCCPerOpListPaths() {
- // Ensure there are no surviving DrawPathsOps with a dangling pointer into this class.
- if (!fDrawOps.isEmpty()) {
- SK_ABORT("GrCCDrawPathsOp(s) not deleted during flush");
- }
- // Clip lazy proxies also reference this class from their callbacks, but those callbacks
- // are only invoked at flush time while we are still alive. (Unlike DrawPathsOps, that
- // unregister themselves upon destruction.) So it shouldn't matter if any clip proxies
- // are still around.
- }
-
- SkTInternalLList<GrCCDrawPathsOp> fDrawOps;
- std::map<uint32_t, GrCCClipPath> fClipPaths;
- SkSTArenaAlloc<10 * 1024> fAllocator{10 * 1024 * 2};
- sk_sp<const GrCCPerFlushResources> fFlushResources;
-};
-
-/**
* This is a path renderer that draws antialiased paths by counting coverage in an offscreen
* buffer. (See GrCCCoverageProcessor, GrCCPathProcessor.)
*
@@ -57,17 +34,23 @@ public:
SkASSERT(!fFlushing);
}
- using PendingPathsMap = std::map<uint32_t, std::unique_ptr<GrCCPerOpListPaths>>;
+ using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
// In DDL mode, Ganesh needs to be able to move the pending GrCCPerOpListPaths to the DDL object
// (detachPendingPaths) and then return them upon replay (mergePendingPaths).
PendingPathsMap detachPendingPaths() { return std::move(fPendingPaths); }
- void mergePendingPaths(PendingPathsMap&& paths) {
+ void mergePendingPaths(const PendingPathsMap& paths) {
+#ifdef SK_DEBUG
// Ensure there are no duplicate opList IDs between the incoming path map and ours.
- SkDEBUGCODE(for (const auto& it : paths) SkASSERT(!fPendingPaths.count(it.first)));
- fPendingPaths.insert(std::make_move_iterator(paths.begin()),
- std::make_move_iterator(paths.end()));
+ // This should always be true since opList IDs are globally unique and these are coming
+ // from different DDL recordings.
+ for (const auto& it : paths) {
+ SkASSERT(!fPendingPaths.count(it.first));
+ }
+#endif
+
+ fPendingPaths.insert(paths.begin(), paths.end());
}
// GrPathRenderer overrides.
@@ -101,7 +84,7 @@ private:
// fFlushingPaths holds the GrCCPerOpListPaths objects that are currently being flushed.
// (It will only contain elements when fFlushing is true.)
- SkSTArray<4, std::unique_ptr<GrCCPerOpListPaths>> fFlushingPaths;
+ SkSTArray<4, sk_sp<GrCCPerOpListPaths>> fFlushingPaths;
SkDEBUGCODE(bool fFlushing = false);
const bool fDrawCachablePaths;