aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gn/core.gni4
-rw-r--r--gn/gpu.gni3
-rw-r--r--include/private/GrCCClipPath.h (renamed from src/gpu/ccpr/GrCCClipPath.h)0
-rw-r--r--include/private/GrCCPerOpListPaths.h34
-rw-r--r--include/private/SkArenaAlloc.h (renamed from src/core/SkArenaAlloc.h)0
-rw-r--r--include/private/SkDeferredDisplayList.h9
-rw-r--r--include/private/SkTInternalLList.h (renamed from src/core/SkTInternalLList.h)0
-rw-r--r--src/core/SkDeferredDisplayList.cpp3
-rw-r--r--src/gpu/GrContext.cpp1
-rw-r--r--src/gpu/GrDrawingManager.cpp12
-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
14 files changed, 97 insertions, 38 deletions
diff --git a/gn/core.gni b/gn/core.gni
index 1d89a1c6f7..56b335cf0a 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -135,7 +135,6 @@ skia_core_sources = [
"$_src/core/SkFDot6.h",
"$_src/core/SkFindAndPlaceGlyph.h",
"$_src/core/SkArenaAlloc.cpp",
- "$_src/core/SkArenaAlloc.h",
"$_src/core/SkArenaAllocList.h",
"$_src/core/SkGaussFilter.cpp",
"$_src/core/SkGaussFilter.h",
@@ -310,7 +309,6 @@ skia_core_sources = [
"$_src/core/SkTaskGroup2D.h",
"$_src/core/SkTDPQueue.h",
"$_src/core/SkTDynamicHash.h",
- "$_src/core/SkTInternalLList.h",
"$_src/core/SkTextBlob.cpp",
"$_src/core/SkTextBlobRunIterator.h",
"$_src/core/SkTextFormatParams.h",
@@ -448,6 +446,7 @@ skia_core_sources = [
"$_src/jumper/SkJumper.cpp",
# private
+ "$_include/private/SkArenaAlloc.h",
"$_include/private/SkAtomics.h",
"$_include/private/SkChecksum.h",
"$_include/private/SkDeferredDisplayList.h",
@@ -467,6 +466,7 @@ skia_core_sources = [
"$_include/private/SkTDArray.h",
"$_include/private/SkTFitsIn.h",
"$_include/private/SkTHash.h",
+ "$_include/private/SkTInternalLList.h",
"$_include/private/SkThreadID.h",
"$_include/private/SkTSearch.h",
"$_include/private/SkTLogic.h",
diff --git a/gn/gpu.gni b/gn/gpu.gni
index d0e7f7f150..110667d986 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -33,6 +33,8 @@ skia_gpu_sources = [
# Private includes
"$_include/private/GrAuditTrail.h",
"$_include/private/GrColor.h",
+ "$_include/private/GrCCClipPath.h",
+ "$_include/private/GrCCPerOpListPaths.h",
"$_include/private/GrGLSL.h",
"$_include/private/GrOpList.h",
"$_include/private/GrSingleOwner.h",
@@ -302,7 +304,6 @@ skia_gpu_sources = [
"$_src/gpu/ccpr/GrCCAtlas.cpp",
"$_src/gpu/ccpr/GrCCAtlas.h",
"$_src/gpu/ccpr/GrCCClipPath.cpp",
- "$_src/gpu/ccpr/GrCCClipPath.h",
"$_src/gpu/ccpr/GrCCClipProcessor.cpp",
"$_src/gpu/ccpr/GrCCClipProcessor.h",
"$_src/gpu/ccpr/GrCCConicShader.cpp",
diff --git a/src/gpu/ccpr/GrCCClipPath.h b/include/private/GrCCClipPath.h
index f15cc9c756..f15cc9c756 100644
--- a/src/gpu/ccpr/GrCCClipPath.h
+++ b/include/private/GrCCClipPath.h
diff --git a/include/private/GrCCPerOpListPaths.h b/include/private/GrCCPerOpListPaths.h
new file mode 100644
index 0000000000..b94e82c548
--- /dev/null
+++ b/include/private/GrCCPerOpListPaths.h
@@ -0,0 +1,34 @@
+/*
+ * 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 GrCCPerOpListPaths_DEFINED
+#define GrCCPerOpListPaths_DEFINED
+
+#include "SkArenaAlloc.h"
+#include "SkRefCnt.h"
+#include "SkTInternalLList.h"
+#include "GrCCClipPath.h"
+#include <map>
+
+class GrCCDrawPathsOp;
+class GrCCPerFlushResources;
+
+/**
+ * Tracks all the CCPR paths in a given opList that will be drawn when it flushes.
+ */
+// DDL TODO: given the usage pattern in DDL mode, this could probably be non-atomic refcounting.
+class GrCCPerOpListPaths : public SkRefCnt {
+public:
+ ~GrCCPerOpListPaths();
+
+ SkTInternalLList<GrCCDrawPathsOp> fDrawOps;
+ std::map<uint32_t, GrCCClipPath> fClipPaths;
+ SkSTArenaAlloc<10 * 1024> fAllocator{10 * 1024 * 2};
+ sk_sp<const GrCCPerFlushResources> fFlushResources;
+};
+
+#endif
diff --git a/src/core/SkArenaAlloc.h b/include/private/SkArenaAlloc.h
index c9e7274e63..c9e7274e63 100644
--- a/src/core/SkArenaAlloc.h
+++ b/include/private/SkArenaAlloc.h
diff --git a/include/private/SkDeferredDisplayList.h b/include/private/SkDeferredDisplayList.h
index 4d379636a9..00afd85df1 100644
--- a/include/private/SkDeferredDisplayList.h
+++ b/include/private/SkDeferredDisplayList.h
@@ -11,6 +11,8 @@
#include "SkSurfaceCharacterization.h"
#if SK_SUPPORT_GPU
+#include <map>
+#include "GrCCPerOpListPaths.h"
#include "GrOpList.h"
#endif
@@ -22,7 +24,7 @@ class SkSurface;
*
* TODO: we probably need to expose this class so users can query it for memory usage.
*/
-class SkDeferredDisplayList {
+class SK_API SkDeferredDisplayList {
public:
#if SK_SUPPORT_GPU
@@ -42,6 +44,7 @@ public:
SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
sk_sp<LazyProxyData>);
+ ~SkDeferredDisplayList();
const SkSurfaceCharacterization& characterization() const {
return fCharacterization;
@@ -54,7 +57,11 @@ private:
const SkSurfaceCharacterization fCharacterization;
#if SK_SUPPORT_GPU
+ // This needs to match the same type in GrCoverageCountingPathRenderer.h
+ using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
+
SkTArray<sk_sp<GrOpList>> fOpLists;
+ PendingPathsMap fPendingPaths; // This is the path data from CCPR.
#endif
sk_sp<LazyProxyData> fLazyProxyData;
};
diff --git a/src/core/SkTInternalLList.h b/include/private/SkTInternalLList.h
index 2f43f1c1eb..2f43f1c1eb 100644
--- a/src/core/SkTInternalLList.h
+++ b/include/private/SkTInternalLList.h
diff --git a/src/core/SkDeferredDisplayList.cpp b/src/core/SkDeferredDisplayList.cpp
index 530523a4b6..50c8648776 100644
--- a/src/core/SkDeferredDisplayList.cpp
+++ b/src/core/SkDeferredDisplayList.cpp
@@ -15,3 +15,6 @@ SkDeferredDisplayList::SkDeferredDisplayList(const SkSurfaceCharacterization& ch
: fCharacterization(characterization)
, fLazyProxyData(std::move(lazyProxyData)) {
}
+
+SkDeferredDisplayList::~SkDeferredDisplayList() {
+}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 572f58972b..3d57f9818d 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -113,7 +113,6 @@ bool GrContext::initCommon(const GrContextOptions& options) {
// Disable the small path renderer bc of the proxies in the atlas. They need to be
// unified when the opLists are added back to the destination drawing manager.
prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kSmall;
- prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kCoverageCounting;
}
GrTextContext::Options textContextOptions;
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 158239e460..99eb04b918 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -26,6 +26,7 @@
#include "SkSurface_Gpu.h"
#include "SkTTopoSort.h"
#include "GrTracing.h"
+#include "ccpr/GrCoverageCountingPathRenderer.h"
#include "text/GrTextContext.h"
// Turn on/off the sorting of opLists at flush time
@@ -383,6 +384,11 @@ void GrDrawingManager::moveOpListsToDDL(SkDeferredDisplayList* ddl) {
}
ddl->fOpLists = std::move(fOpLists);
+ if (fPathRendererChain) {
+ if (auto ccpr = fPathRendererChain->getCoverageCountingPathRenderer()) {
+ ddl->fPendingPaths = ccpr->detachPendingPaths();
+ }
+ }
}
void GrDrawingManager::copyOpListsFromDDL(const SkDeferredDisplayList* ddl,
@@ -390,6 +396,12 @@ void GrDrawingManager::copyOpListsFromDDL(const SkDeferredDisplayList* ddl,
// Here we jam the proxy that backs the current replay SkSurface into the LazyProxyData.
// The lazy proxy that references it (in the copied opLists) will steal its GrTexture.
ddl->fLazyProxyData->fReplayDest = newDest;
+
+ if (ddl->fPendingPaths.size()) {
+ GrCoverageCountingPathRenderer* ccpr = this->getCoverageCountingPathRenderer();
+
+ ccpr->mergePendingPaths(ddl->fPendingPaths);
+ }
fOpLists.push_back_n(ddl->fOpLists.count(), ddl->fOpLists.begin());
}
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;