Chromium Code Reviews| Index: src/gpu/gl/GrGLCaps.h |
| diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h |
| index ccf04fd7ba5a3d668ef5d2671d0defc5af6ea6b6..ef3ff29ee48ebd0fc97a5018fd8525ef421e0606 100644 |
| --- a/src/gpu/gl/GrGLCaps.h |
| +++ b/src/gpu/gl/GrGLCaps.h |
| @@ -13,6 +13,7 @@ |
| #include "GrGLStencilBuffer.h" |
| #include "SkTArray.h" |
| #include "SkTDArray.h" |
| +#include "SkTDynamicHash.h" |
| class GrGLContextInfo; |
| @@ -253,7 +254,8 @@ public: |
| /// Does ReadPixels support the provided format/type combo? |
| bool readPixelsSupported(const GrGLInterface* intf, |
| GrGLenum format, |
| - GrGLenum type) const; |
| + GrGLenum type, |
| + GrGLenum currFboFormat) const; |
| bool isCoreProfile() const { return fIsCoreProfile; } |
| @@ -324,6 +326,10 @@ private: |
| void initConfigRenderableTable(const GrGLContextInfo&); |
| void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*); |
| + bool doReadPixelsSupported(const GrGLInterface* intf, |
| + GrGLenum format, |
| + GrGLenum type) const; |
| + |
| // tracks configs that have been verified to pass the FBO completeness when |
| // used as a color attachment |
| VerifiedColorConfigs fVerifiedColorConfigs; |
| @@ -364,6 +370,87 @@ private: |
| bool fFullClearIsFree : 1; |
| bool fDropsTileOnZeroDivide : 1; |
| + struct ReadPixelsSupportedFormatsKey { |
| + GrGLenum fFormat; |
| + GrGLenum fType; |
| + GrGLenum fFboFormat; |
| + |
| + bool operator==(const ReadPixelsSupportedFormatsKey& rhs) const { |
| + return fFormat == rhs.fFormat |
| + && fType == rhs.fType |
| + && fFboFormat == rhs.fFboFormat; |
| + } |
| + }; |
| + |
| + class ReadPixelsSupportedFormats { |
| + public: |
| + ReadPixelsSupportedFormats(ReadPixelsSupportedFormatsKey key, |
| + bool value) |
| + :fKey(key), fValue(value) { |
| + } |
| + |
| + static const ReadPixelsSupportedFormatsKey& GetKey(const ReadPixelsSupportedFormats& element) { |
| + return element.fKey; |
| + } |
| + static uint32_t Hash(const ReadPixelsSupportedFormatsKey&); |
| + |
| + bool value() const { return fValue; } |
| + private: |
| + ReadPixelsSupportedFormatsKey fKey; |
| + bool fValue; |
| + }; |
| + |
| + template <typename T, |
| + typename Key, |
| + typename Traits = T, |
| + int kGrowPercent = 75> |
| + class DynamicHashCache { |
|
Justin Novosad
2014/07/04 14:42:27
This seems like a generally useful wrapper for SkT
bsalomon
2014/07/07 13:31:10
Adding the other Mike WRT this comment.
mtklein
2014/07/07 13:44:30
Yup, does sound useful to me too. We seem to have
mtklein
2014/07/07 13:44:30
If possible, class DynamicHashCache : SkNoncopyabl
Rémi Piotaix
2014/07/07 18:10:17
Done.
Rémi Piotaix
2014/07/07 18:10:17
Done.
|
| + public: |
| + DynamicHashCache() { |
| + fDict = new SkTDynamicHash<T, Key, Traits, kGrowPercent>(); |
|
mtklein
2014/07/07 13:44:30
fDict = SkNEW(SkTDynamicHash<T, Key, Traits, kGrow
Rémi Piotaix
2014/07/07 18:10:16
Done.
|
| + } |
| + |
| + virtual ~DynamicHashCache() { |
|
mtklein
2014/07/07 13:44:30
Don't make this virtual? Nothing else is virtual.
Rémi Piotaix
2014/07/07 18:10:17
Done.
|
| + delete fDict; |
| + } |
| + |
| + bool has(Key& key) const { |
|
mtklein
2014/07/07 13:44:30
Can any of these parameters be passed as const Key
Rémi Piotaix
2014/07/07 18:10:17
Done.
|
| + return NULL != find(key); |
|
mtklein
2014/07/07 13:44:30
return NULL != this->find(key);
Rémi Piotaix
2014/07/07 18:10:17
Done.
|
| + } |
| + |
| + T* find(Key& key) const { |
| + return fDict->find(key); |
| + } |
| + |
| + // if element already in cache, return immediately the cached value |
| + T& put(T& element) { |
| + Key key = Traits::GetKey(element); |
| + if(has(key)) |
|
mtklein
2014/07/07 13:44:30
if (this->has(key)) {
return *this->find(key);
}
Rémi Piotaix
2014/07/07 18:10:17
Done.
|
| + return *find(key); |
|
mtklein
2014/07/07 13:44:30
Does this all optimize away into one call to find(
Rémi Piotaix
2014/07/07 18:10:17
Done.
|
| + |
| + T& e = fValues.push_back(element); |
| + |
| + fDict->add(&e); |
|
mtklein
2014/07/07 13:44:30
Aren't these pointers invalidated when fValues res
Rémi Piotaix
2014/07/07 18:10:17
Yes, you're right. I've corrected this in the new
|
| + |
| + return e; |
| + } |
| + |
| + int size() { |
| + return fValues.count(); |
| + } |
| + |
| + void clear() { |
| + fValues.reset(); |
| + delete fDict; |
| + fDict = new SkTDynamicHash<T, Key, Traits, kGrowPercent>(); |
|
mtklein
2014/07/07 13:44:30
Seems like we could make fDict a non-pointer membe
|
| + } |
| + private: |
| + SkTDynamicHash<T, Key, Traits, kGrowPercent>* fDict; |
| + SkTArray<T, true> fValues; |
| + }; |
| + |
| + mutable DynamicHashCache<ReadPixelsSupportedFormats, ReadPixelsSupportedFormatsKey> fReadPixelsSupportedCache; |
| + |
| typedef GrDrawTargetCaps INHERITED; |
| }; |