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..b2ec434ba463516c5b82f9db65474709da9217dc 100644 |
| --- a/src/gpu/gl/GrGLCaps.h |
| +++ b/src/gpu/gl/GrGLCaps.h |
| @@ -11,8 +11,8 @@ |
| #include "GrDrawTargetCaps.h" |
| #include "GrGLStencilBuffer.h" |
| +#include "SkTHashCache.h" |
| #include "SkTArray.h" |
| -#include "SkTDArray.h" |
| class GrGLContextInfo; |
| @@ -253,7 +253,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 +325,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 +369,55 @@ private: |
| bool fFullClearIsFree : 1; |
| bool fDropsTileOnZeroDivide : 1; |
| + class ReadPixelsSupportedFormats { |
| + public: |
| + struct Key { |
| + GrGLenum fFormat; |
| + GrGLenum fType; |
| + GrGLenum fFboFormat; |
| + |
| + bool operator==(const Key& rhs) const { |
| + return fFormat == rhs.fFormat |
| + && fType == rhs.fType |
| + && fFboFormat == rhs.fFboFormat; |
| + } |
| + |
| + uint32_t getHash() const { |
| + // fFormat has different values like 0x190X or 0x8XXX: 16 bits are required |
| + uint32_t hash = ((static_cast<uint32_t> (fFormat) & 0xFFFF) << 16); |
| + // fType is 0x14XX: 8 lower bits are enough |
| + hash |= ((static_cast<uint32_t> (fType) & 0xFF) << 8); |
| + // fFboFormat is enum GrPixelConfig which has less than 15 values: 8 bits OK |
| + hash |= (static_cast<uint32_t> (fFboFormat) & 0xFF); |
| + |
| + return hash; |
|
mtklein
2014/07/11 18:11:39
You may have better results if you mix these bits.
Rémi Piotaix
2014/07/14 20:38:59
Done.
|
| + } |
| + }; |
| + |
| + ReadPixelsSupportedFormats(Key key, |
|
mtklein
2014/07/11 18:11:39
Strange formatting?
Rémi Piotaix
2014/07/14 20:38:59
Done.
|
| + bool value) |
| + : fKey(key), fValue(value) { |
| + } |
| + |
| + static const Key& GetKey(const ReadPixelsSupportedFormats& element) { |
| + return element.fKey; |
| + } |
| + |
| + static uint32_t Hash(const Key& key) { |
| + return key.getHash(); |
| + } |
| + |
| + bool value() const { |
| + return fValue; |
| + } |
| + private: |
| + Key fKey; |
| + bool fValue; |
| + }; |
| + |
| + mutable SkTHashCache<ReadPixelsSupportedFormats, |
| + ReadPixelsSupportedFormats::Key> fReadPixelsSupportedCache; |
| + |
| typedef GrDrawTargetCaps INHERITED; |
| }; |