2017-08-30 16:06:35 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2019-05-17 20:29:34 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkSurfaceCharacterization.h"
|
2019-05-17 20:29:34 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
2017-08-30 16:06:35 +00:00
|
|
|
|
2019-05-17 20:29:34 +00:00
|
|
|
class SkDeferredDisplayListPriv;
|
2018-09-19 14:28:59 +00:00
|
|
|
|
2019-05-17 20:29:34 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "include/private/SkTArray.h"
|
2018-09-19 14:28:59 +00:00
|
|
|
#include <map>
|
2019-12-12 18:59:20 +00:00
|
|
|
class GrOpMemoryPool;
|
2019-08-01 20:14:52 +00:00
|
|
|
class GrRenderTask;
|
2019-05-17 20:29:34 +00:00
|
|
|
class GrRenderTargetProxy;
|
2019-08-22 20:19:24 +00:00
|
|
|
struct GrCCPerOpsTaskPaths;
|
2018-02-01 14:10:04 +00:00
|
|
|
#endif
|
|
|
|
|
2017-08-30 16:06:35 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-05-17 20:29:34 +00:00
|
|
|
class SkDeferredDisplayList {
|
2017-08-30 16:06:35 +00:00
|
|
|
public:
|
2018-02-01 14:10:04 +00:00
|
|
|
|
|
|
|
#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.
|
2019-05-17 20:29:34 +00:00
|
|
|
class SK_API LazyProxyData : public SkRefCnt {
|
2018-02-01 14:10:04 +00:00
|
|
|
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
|
2019-05-17 20:29:34 +00:00
|
|
|
class SK_API LazyProxyData : public SkRefCnt {};
|
2018-02-01 14:10:04 +00:00
|
|
|
#endif
|
|
|
|
|
2019-05-17 20:29:34 +00:00
|
|
|
SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
|
|
|
|
sk_sp<LazyProxyData>);
|
|
|
|
SK_API ~SkDeferredDisplayList();
|
2018-02-01 14:10:04 +00:00
|
|
|
|
2019-05-17 20:29:34 +00:00
|
|
|
SK_API const SkSurfaceCharacterization& characterization() const {
|
2017-08-30 16:06:35 +00:00
|
|
|
return fCharacterization;
|
|
|
|
}
|
|
|
|
|
2018-09-27 18:26:47 +00:00
|
|
|
// Provides access to functions that aren't part of the public API.
|
|
|
|
SkDeferredDisplayListPriv priv();
|
|
|
|
const SkDeferredDisplayListPriv priv() const;
|
|
|
|
|
2017-08-30 16:06:35 +00:00
|
|
|
private:
|
2019-12-06 18:05:49 +00:00
|
|
|
#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
|
|
|
|
|
2019-10-22 15:58:17 +00:00
|
|
|
friend class GrDrawingManager; // for access to 'fRenderTasks', 'fLazyProxyData', 'fOpPOD'
|
2018-02-01 14:10:04 +00:00
|
|
|
friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
|
2018-09-27 18:26:47 +00:00
|
|
|
friend class SkDeferredDisplayListPriv;
|
2018-02-01 14:10:04 +00:00
|
|
|
|
2017-11-30 16:22:14 +00:00
|
|
|
const SkSurfaceCharacterization fCharacterization;
|
2017-08-30 16:06:35 +00:00
|
|
|
|
2018-02-01 14:10:04 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2018-05-31 16:43:27 +00:00
|
|
|
// This needs to match the same type in GrCoverageCountingPathRenderer.h
|
2019-08-22 20:19:24 +00:00
|
|
|
using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpsTaskPaths>>;
|
2018-05-31 16:43:27 +00:00
|
|
|
|
2019-12-12 18:59:20 +00:00
|
|
|
// 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).
|
2019-11-15 22:28:37 +00:00
|
|
|
std::unique_ptr<SkArenaAlloc> fRecordTimeData;
|
2019-12-12 18:59:20 +00:00
|
|
|
std::unique_ptr<GrOpMemoryPool> fOpMemoryPool;
|
|
|
|
PendingPathsMap fPendingPaths; // This is the path data from CCPR.
|
|
|
|
SkTArray<sk_sp<GrRenderTask>> fRenderTasks;
|
2019-12-06 18:05:49 +00:00
|
|
|
|
|
|
|
// 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;
|
2018-02-01 14:10:04 +00:00
|
|
|
#endif
|
2019-08-01 20:14:52 +00:00
|
|
|
sk_sp<LazyProxyData> fLazyProxyData;
|
2017-08-30 16:06:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|