aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrXferProcessor.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-01-09 11:46:10 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-09 17:21:03 +0000
commita16339297859f37df69230e64f05624cef511ad3 (patch)
tree07dbb20733defb86e05bc8cc924b4ced8ca78374 /include/gpu/GrXferProcessor.h
parenta7080264d11235d6f469d355b14a7647cba8eb75 (diff)
Revert "Revert "Removing ref counting from GrXPFactory.""
This reverts commit 003312a211e65f35e402d6fe80a32e23d4c94ac4. Change-Id: Ib41065e5c356d1dd99e70fa10611ac6756c2b79d Reviewed-on: https://skia-review.googlesource.com/6803 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/gpu/GrXferProcessor.h')
-rw-r--r--include/gpu/GrXferProcessor.h64
1 files changed, 20 insertions, 44 deletions
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index e97c0b92c7..17cd2c7bf3 100644
--- a/include/gpu/GrXferProcessor.h
+++ b/include/gpu/GrXferProcessor.h
@@ -289,8 +289,22 @@ GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags);
* Before the XP is created, the XPF is able to answer queries about what functionality the XPs it
* creates will have. For example, can it create an XP that supports RGB coverage or will the XP
* blend with the destination color.
+ *
+ * GrXPFactories are intended to be static immutable objects. We pass them around as raw pointers
+ * and expect the pointers to always be valid and for the factories to be reusable and thread safe.
+ * Equality is tested for using pointer comparison. GrXPFactory destructors must be no-ops.
*/
-class GrXPFactory : public SkRefCnt {
+
+// In order to construct GrXPFactory subclass instances as constexpr the subclass, and therefore
+// GrXPFactory, must be a literal type. One requirement is having a trivial destructor. This is ok
+// since these objects have no need for destructors. However, GCC and clang throw a warning when a
+// class has virtual functions and a non-virtual destructor. We suppress that warning here and
+// for the subclasses.
+#if defined(__GNUC__) || defined(__clang)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+#endif
+class GrXPFactory {
public:
typedef GrXferProcessor::DstTexture DstTexture;
GrXferProcessor* createXferProcessor(const GrPipelineAnalysis&,
@@ -317,29 +331,8 @@ public:
bool willNeedDstTexture(const GrCaps& caps, const GrPipelineAnalysis&) const;
- bool isEqual(const GrXPFactory& that) const {
- if (this->classID() != that.classID()) {
- return false;
- }
- return this->onIsEqual(that);
- }
-
- /**
- * Helper for down-casting to a GrXPFactory subclass
- */
- template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
-
- uint32_t classID() const { SkASSERT(kIllegalXPFClassID != fClassID); return fClassID; }
-
protected:
- GrXPFactory() : fClassID(kIllegalXPFClassID) {}
-
- template <typename XPF_SUBCLASS> void initClassID() {
- static uint32_t kClassID = GenClassID();
- fClassID = kClassID;
- }
-
- uint32_t fClassID;
+ constexpr GrXPFactory() {}
private:
virtual GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
@@ -347,34 +340,17 @@ private:
bool hasMixedSamples,
const DstTexture*) const = 0;
- virtual bool onIsEqual(const GrXPFactory&) const = 0;
-
bool willReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const;
+
/**
* Returns true if the XP generated by this factory will explicitly read dst in the fragment
* shader.
*/
virtual bool onWillReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const = 0;
-
- static uint32_t GenClassID() {
- // fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The
- // atomic inc returns the old value not the incremented value. So we add
- // 1 to the returned value.
- uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrXPFClassID)) + 1;
- if (!id) {
- SkFAIL("This should never wrap as it should only be called once for each GrXPFactory "
- "subclass.");
- }
- return id;
- }
-
- enum {
- kIllegalXPFClassID = 0,
- };
- static int32_t gCurrXPFClassID;
-
- typedef GrProgramElement INHERITED;
};
+#if defined(__GNUC__) || defined(__clang)
+#pragma GCC diagnostic pop
+#endif
#endif