2016-10-25 18:20:06 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrOpList_DEFINED
|
|
|
|
#define GrOpList_DEFINED
|
|
|
|
|
2017-08-29 11:24:09 +00:00
|
|
|
#include "GrColor.h"
|
2018-08-01 13:55:10 +00:00
|
|
|
#include "GrProxyRef.h"
|
2018-02-01 14:10:04 +00:00
|
|
|
#include "GrTextureProxy.h"
|
2016-10-25 18:20:06 +00:00
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkTDArray.h"
|
|
|
|
|
2016-10-26 16:02:18 +00:00
|
|
|
class GrAuditTrail;
|
2017-04-26 15:53:10 +00:00
|
|
|
class GrCaps;
|
2016-12-07 22:06:19 +00:00
|
|
|
class GrOpFlushState;
|
2018-06-19 17:09:54 +00:00
|
|
|
class GrOpMemoryPool;
|
2016-11-23 14:37:01 +00:00
|
|
|
class GrRenderTargetOpList;
|
2017-09-14 16:45:25 +00:00
|
|
|
class GrResourceAllocator;
|
2017-05-17 13:36:38 +00:00
|
|
|
class GrResourceProvider;
|
2016-10-28 17:25:24 +00:00
|
|
|
class GrSurfaceProxy;
|
2016-11-23 14:37:01 +00:00
|
|
|
class GrTextureOpList;
|
2016-10-25 18:20:06 +00:00
|
|
|
|
2017-06-28 14:33:41 +00:00
|
|
|
struct SkIPoint;
|
|
|
|
struct SkIRect;
|
|
|
|
|
2016-10-25 18:20:06 +00:00
|
|
|
class GrOpList : public SkRefCnt {
|
|
|
|
public:
|
2018-06-19 17:09:54 +00:00
|
|
|
GrOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>, GrSurfaceProxy*, GrAuditTrail*);
|
2016-10-25 18:20:06 +00:00
|
|
|
~GrOpList() override;
|
|
|
|
|
2017-10-02 20:38:32 +00:00
|
|
|
// These four methods are invoked at flush time
|
2017-05-17 13:36:38 +00:00
|
|
|
bool instantiate(GrResourceProvider* resourceProvider);
|
2017-10-02 20:38:32 +00:00
|
|
|
// Instantiates any "threaded" texture proxies that are being prepared elsewhere
|
|
|
|
void instantiateDeferredProxies(GrResourceProvider* resourceProvider);
|
2017-08-22 19:01:32 +00:00
|
|
|
void prepare(GrOpFlushState* flushState);
|
|
|
|
bool execute(GrOpFlushState* flushState) { return this->onExecute(flushState); }
|
2016-10-25 18:20:06 +00:00
|
|
|
|
2018-06-12 14:11:12 +00:00
|
|
|
virtual bool copySurface(GrContext*,
|
2017-06-28 14:33:41 +00:00
|
|
|
GrSurfaceProxy* dst,
|
|
|
|
GrSurfaceProxy* src,
|
|
|
|
const SkIRect& srcRect,
|
|
|
|
const SkIPoint& dstPoint) = 0;
|
|
|
|
|
2017-04-26 15:53:10 +00:00
|
|
|
virtual void makeClosed(const GrCaps&) {
|
2017-06-14 19:16:59 +00:00
|
|
|
if (!this->isClosed()) {
|
|
|
|
this->setFlag(kClosed_Flag);
|
|
|
|
fTarget.removeRef();
|
|
|
|
}
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 16:30:29 +00:00
|
|
|
// Called when this class will survive a flush and needs to truncate its ops and start over.
|
|
|
|
// TODO: ultimately it should be invalid for an op list to survive a flush.
|
|
|
|
// https://bugs.chromium.org/p/skia/issues/detail?id=7111
|
|
|
|
virtual void endFlush();
|
2016-10-25 18:20:06 +00:00
|
|
|
|
|
|
|
bool isClosed() const { return this->isSetFlag(kClosed_Flag); }
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify this GrOpList that it relies on the contents of 'dependedOn'
|
|
|
|
*/
|
2017-04-26 15:53:10 +00:00
|
|
|
void addDependency(GrSurfaceProxy* dependedOn, const GrCaps& caps);
|
2016-10-25 18:20:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Does this opList depend on 'dependedOn'?
|
|
|
|
*/
|
2018-07-18 17:52:40 +00:00
|
|
|
bool dependsOn(const GrOpList* dependedOn) const;
|
2016-10-25 18:20:06 +00:00
|
|
|
|
2016-11-23 14:37:01 +00:00
|
|
|
/*
|
|
|
|
* Safely cast this GrOpList to a GrTextureOpList (if possible).
|
|
|
|
*/
|
|
|
|
virtual GrTextureOpList* asTextureOpList() { return nullptr; }
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Safely case this GrOpList to a GrRenderTargetOpList (if possible).
|
|
|
|
*/
|
|
|
|
virtual GrRenderTargetOpList* asRenderTargetOpList() { return nullptr; }
|
|
|
|
|
2017-12-05 17:05:21 +00:00
|
|
|
uint32_t uniqueID() const { return fUniqueID; }
|
2017-03-08 16:50:55 +00:00
|
|
|
|
2016-10-25 18:20:06 +00:00
|
|
|
/*
|
|
|
|
* Dump out the GrOpList dependency DAG
|
|
|
|
*/
|
2018-04-20 16:43:18 +00:00
|
|
|
SkDEBUGCODE(virtual void dump(bool printDependencies) const;)
|
2016-10-25 18:20:06 +00:00
|
|
|
|
2017-05-08 19:35:11 +00:00
|
|
|
SkDEBUGCODE(virtual int numOps() const = 0;)
|
|
|
|
SkDEBUGCODE(virtual int numClips() const { return 0; })
|
|
|
|
|
2017-08-30 11:41:07 +00:00
|
|
|
// TODO: it would be nice for this to be hidden
|
2017-08-29 11:24:09 +00:00
|
|
|
void setStencilLoadOp(GrLoadOp loadOp) { fStencilLoadOp = loadOp; }
|
|
|
|
|
2017-04-13 16:23:54 +00:00
|
|
|
protected:
|
2018-02-07 22:08:21 +00:00
|
|
|
bool isInstantiated() const;
|
2017-09-13 19:25:47 +00:00
|
|
|
|
2018-07-26 12:03:04 +00:00
|
|
|
// In addition to just the GrSurface being allocated, has the stencil buffer been allocated (if
|
|
|
|
// it is required)?
|
|
|
|
bool isFullyInstantiated() const;
|
|
|
|
|
2018-06-19 17:09:54 +00:00
|
|
|
// This is a backpointer to the GrOpMemoryPool that holds the memory for this opLists' ops.
|
|
|
|
// In the DDL case, these back pointers keep the DDL's GrOpMemoryPool alive as long as its
|
|
|
|
// constituent opLists survive.
|
|
|
|
sk_sp<GrOpMemoryPool> fOpMemoryPool;
|
|
|
|
GrSurfaceProxyRef fTarget;
|
|
|
|
GrAuditTrail* fAuditTrail;
|
2017-04-13 16:23:54 +00:00
|
|
|
|
2018-06-19 17:09:54 +00:00
|
|
|
GrLoadOp fColorLoadOp = GrLoadOp::kLoad;
|
|
|
|
GrColor fLoadClearColor = 0x0;
|
|
|
|
GrLoadOp fStencilLoadOp = GrLoadOp::kLoad;
|
2017-08-29 11:24:09 +00:00
|
|
|
|
2017-10-02 20:38:32 +00:00
|
|
|
// List of texture proxies whose contents are being prepared on a worker thread
|
|
|
|
SkTArray<GrTextureProxy*, true> fDeferredProxies;
|
|
|
|
|
2016-10-25 18:20:06 +00:00
|
|
|
private:
|
2017-09-14 16:45:25 +00:00
|
|
|
friend class GrDrawingManager; // for resetFlag, TopoSortTraits & gatherProxyIntervals
|
|
|
|
|
2018-07-18 17:52:40 +00:00
|
|
|
void addDependency(GrOpList* dependedOn);
|
2018-08-06 20:56:26 +00:00
|
|
|
void addDependent(GrOpList* dependent);
|
|
|
|
SkDEBUGCODE(bool isDependedent(const GrOpList* dependent) const);
|
|
|
|
SkDEBUGCODE(void validate() const);
|
2018-10-09 13:31:40 +00:00
|
|
|
void closeThoseWhoDependOnMe(const GrCaps&);
|
2018-07-18 17:52:40 +00:00
|
|
|
|
2018-01-29 15:34:25 +00:00
|
|
|
// Remove all Ops which reference proxies that have not been instantiated.
|
|
|
|
virtual void purgeOpsWithUninstantiatedProxies() = 0;
|
|
|
|
|
2017-09-14 16:45:25 +00:00
|
|
|
// Feed proxy usage intervals to the GrResourceAllocator class
|
|
|
|
virtual void gatherProxyIntervals(GrResourceAllocator*) const = 0;
|
2016-10-25 18:20:06 +00:00
|
|
|
|
2017-03-08 16:50:55 +00:00
|
|
|
static uint32_t CreateUniqueID();
|
|
|
|
|
2016-10-25 18:20:06 +00:00
|
|
|
enum Flags {
|
2016-12-07 20:05:04 +00:00
|
|
|
kClosed_Flag = 0x01, //!< This GrOpList can't accept any more ops
|
2016-10-25 18:20:06 +00:00
|
|
|
|
|
|
|
kWasOutput_Flag = 0x02, //!< Flag for topological sorting
|
|
|
|
kTempMark_Flag = 0x04, //!< Flag for topological sorting
|
|
|
|
};
|
|
|
|
|
|
|
|
void setFlag(uint32_t flag) {
|
|
|
|
fFlags |= flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetFlag(uint32_t flag) {
|
|
|
|
fFlags &= ~flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSetFlag(uint32_t flag) const {
|
|
|
|
return SkToBool(fFlags & flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TopoSortTraits {
|
2018-02-07 22:08:21 +00:00
|
|
|
static void Output(GrOpList* opList, int /* index */) {
|
|
|
|
opList->setFlag(GrOpList::kWasOutput_Flag);
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
2018-02-07 22:08:21 +00:00
|
|
|
static bool WasOutput(const GrOpList* opList) {
|
|
|
|
return opList->isSetFlag(GrOpList::kWasOutput_Flag);
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
2018-02-07 22:08:21 +00:00
|
|
|
static void SetTempMark(GrOpList* opList) {
|
|
|
|
opList->setFlag(GrOpList::kTempMark_Flag);
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
2018-02-07 22:08:21 +00:00
|
|
|
static void ResetTempMark(GrOpList* opList) {
|
|
|
|
opList->resetFlag(GrOpList::kTempMark_Flag);
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
2018-02-07 22:08:21 +00:00
|
|
|
static bool IsTempMarked(const GrOpList* opList) {
|
|
|
|
return opList->isSetFlag(GrOpList::kTempMark_Flag);
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
2018-02-07 22:08:21 +00:00
|
|
|
static int NumDependencies(const GrOpList* opList) {
|
|
|
|
return opList->fDependencies.count();
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
2018-02-07 22:08:21 +00:00
|
|
|
static GrOpList* Dependency(GrOpList* opList, int index) {
|
|
|
|
return opList->fDependencies[index];
|
2016-10-25 18:20:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-22 19:01:32 +00:00
|
|
|
virtual void onPrepare(GrOpFlushState* flushState) = 0;
|
|
|
|
virtual bool onExecute(GrOpFlushState* flushState) = 0;
|
|
|
|
|
2017-09-15 11:48:08 +00:00
|
|
|
uint32_t fUniqueID;
|
|
|
|
uint32_t fFlags;
|
2016-10-25 18:20:06 +00:00
|
|
|
|
|
|
|
// 'this' GrOpList relies on the output of the GrOpLists in 'fDependencies'
|
2017-09-15 11:48:08 +00:00
|
|
|
SkSTArray<1, GrOpList*, true> fDependencies;
|
2018-08-06 20:56:26 +00:00
|
|
|
// 'this' GrOpList's output is relied on by the GrOpLists in 'fDependents'
|
|
|
|
SkSTArray<1, GrOpList*, true> fDependents;
|
2016-10-25 18:20:06 +00:00
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|