diff options
author | egdaniel <egdaniel@google.com> | 2014-09-19 12:07:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-19 12:07:43 -0700 |
commit | bc127a3fdaeaa9c3cf18fbe3a1139887aaff9903 (patch) | |
tree | c837036238fbb44523b23b3c58cb129899ea45e1 /src/gpu | |
parent | 45725db1d82615d43408ec488549aec6218f80e4 (diff) |
Add UniqueID to GrDrawTargetCaps.
This is needed for creating the Optimized Draw State and checking that we have the same caps
on subsequent calls to ODS
BUG=skia:
R=bsalomon@google.com
Author: egdaniel@google.com
Review URL: https://codereview.chromium.org/585043002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrDrawTargetCaps.h | 20 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index af00ac8db1..e942d7cf31 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -1147,3 +1147,13 @@ SkString GrDrawTargetCaps::dump() const { return r; } + +uint32_t GrDrawTargetCaps::CreateUniqueID() { + static int32_t gUniqueID = SK_InvalidUniqueID; + uint32_t id; + do { + id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); + } while (id == SK_InvalidUniqueID); + return id; +} + diff --git a/src/gpu/GrDrawTargetCaps.h b/src/gpu/GrDrawTargetCaps.h index 1a3a84cf28..e468bc41ab 100644 --- a/src/gpu/GrDrawTargetCaps.h +++ b/src/gpu/GrDrawTargetCaps.h @@ -19,8 +19,12 @@ class GrDrawTargetCaps : public SkRefCnt { public: SK_DECLARE_INST_COUNT(GrDrawTargetCaps) - GrDrawTargetCaps() { this->reset(); } - GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED() { *this = other; } + GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) { + this->reset(); + } + GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(CreateUniqueID()) { + *this = other; + } GrDrawTargetCaps& operator= (const GrDrawTargetCaps&); virtual void reset(); @@ -77,6 +81,13 @@ public: return fConfigTextureSupport[config]; } + /** + * Gets an id that is unique for this GrDrawTargetCaps object. It is static in that it does + * not change when the content of the GrDrawTargetCaps object changes. This will never return + * 0. + */ + uint32_t getUniqueID() const { return fUniqueID; } + protected: bool fNPOTTextureTileSupport : 1; bool fMipMapSupport : 1; @@ -103,6 +114,11 @@ protected: bool fConfigRenderSupport[kGrPixelConfigCnt][2]; bool fConfigTextureSupport[kGrPixelConfigCnt]; +private: + static uint32_t CreateUniqueID(); + + const uint32_t fUniqueID; + typedef SkRefCnt INHERITED; }; |