skia2/include/private/SkDeferredDisplayList.h
Michael Ludwig cb10e4d323 Reland "Detach op memory pool from recording context"
This reverts commit ed58654e39.

Reason for revert: Fix field order in SkDeferredDisplayList to deconstruct
dependent types in the proper order.

Original change's description:
> Revert "Detach op memory pool from recording context"
>
> This reverts commit 6b95516728.
>
> Reason for revert: breaking some Win10 bots
>
> Original change's description:
> > Detach op memory pool from recording context
> >
> > This changes GrOpMemoryPool to no longer extend SkRefCnt, and all usages
> > either are std::unique_ptr for owners, or GrOpMemoryPool* when ownership
> > is held somewhere else. The culmination of this is that DDLs explicitly
> > detach the memory pool from the recording context instead of the GrOpsTask
> > maintaining a strong ref that preserved the memory somewhat sneakily.
> >
> > Change-Id: I33e2caebea70cebe8fd7681207c631feeaf2c703
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259424
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: I942ae1e07fdc63d9311f6ee482bd71beca090502
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259696
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Derek Sollenberger <djsollen@google.com>

Change-Id: Ia82fa6e42fc8d75b8aa57e5172894e8dfc7e83d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259816
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2019-12-12 20:11:40 +00:00

96 lines
3.2 KiB
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDeferredDisplayList_DEFINED
#define SkDeferredDisplayList_DEFINED
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceCharacterization.h"
#include "include/core/SkTypes.h"
class SkDeferredDisplayListPriv;
#if SK_SUPPORT_GPU
#include "include/private/SkTArray.h"
#include <map>
class GrOpMemoryPool;
class GrRenderTask;
class GrRenderTargetProxy;
struct GrCCPerOpsTaskPaths;
#endif
/*
* This class contains pre-processed gpu operations that can be replayed into
* an SkSurface via draw(SkDeferredDisplayList*).
*
* TODO: we probably need to expose this class so users can query it for memory usage.
*/
class SkDeferredDisplayList {
public:
#if SK_SUPPORT_GPU
// This object is the source from which the lazy proxy backing the DDL will pull its backing
// texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
// can outlive the DDL.
class SK_API LazyProxyData : public SkRefCnt {
public:
// Upon being replayed - this field will be filled in (by the DrawingManager) with the proxy
// backing the destination SkSurface. Note that, since there is no good place to clear it
// it can become a dangling pointer.
GrRenderTargetProxy* fReplayDest = nullptr;
};
#else
class SK_API LazyProxyData : public SkRefCnt {};
#endif
SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
sk_sp<LazyProxyData>);
SK_API ~SkDeferredDisplayList();
SK_API const SkSurfaceCharacterization& characterization() const {
return fCharacterization;
}
// Provides access to functions that aren't part of the public API.
SkDeferredDisplayListPriv priv();
const SkDeferredDisplayListPriv priv() const;
private:
#if SK_SUPPORT_GPU
// TODO: we should probably also store the GrProgramDescs - since we already have
// them
SK_API const SkTDArray<const GrProgramInfo*>& programInfos() const {
return fProgramInfos;
}
#endif
friend class GrDrawingManager; // for access to 'fRenderTasks', 'fLazyProxyData', 'fOpPOD'
friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
friend class SkDeferredDisplayListPriv;
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<GrCCPerOpsTaskPaths>>;
// These are ordered such that the destructor cleans op tasks up first (which may refer back
// to the arena and memory pool in their destructors).
std::unique_ptr<SkArenaAlloc> fRecordTimeData;
std::unique_ptr<GrOpMemoryPool> fOpMemoryPool;
PendingPathsMap fPendingPaths; // This is the path data from CCPR.
SkTArray<sk_sp<GrRenderTask>> fRenderTasks;
// The program infos should be stored in 'fRecordTimeData' so do not need to be ref counted
// or deleted in the destructor.
SkTDArray<const GrProgramInfo*> fProgramInfos;
#endif
sk_sp<LazyProxyData> fLazyProxyData;
};
#endif