Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: src/gpu/gl/GrGLCaps.cpp

Issue 364193004: Reopened: Caching the result of readPixelsSupported (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Correcting code as suggested in the comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLCaps.cpp
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 4a62c5acaab1ce370545f9b11d991153260d0e3f..9f0c121e4591d6001d8335cd9e642c50201fef58 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -48,6 +48,8 @@ void GrGLCaps::reset() {
fIsCoreProfile = false;
fFullClearIsFree = false;
fDropsTileOnZeroDivide = false;
+
+ fReadPixelsSupportedCache.clear();
}
GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
@@ -485,7 +487,7 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
// First check version for support
if (kGL_GrGLStandard == standard) {
hasETC1 = hasCompressTex2D &&
- (version >= GR_GL_VER(4, 3) ||
+ (version >= GR_GL_VER(4, 3) ||
ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
} else {
hasETC1 = hasCompressTex2D &&
@@ -541,9 +543,9 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
}
}
-bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
- GrGLenum format,
- GrGLenum type) const {
+bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
+ GrGLenum format,
+ GrGLenum type) const {
if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
// ES 2 guarantees this format is supported
return true;
@@ -570,6 +572,24 @@ bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
}
+bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
+ GrGLenum format,
+ GrGLenum type,
+ GrGLenum currFboFormat) const {
+
+ ReadPixelsSupportedFormatsKey key = {format, type, currFboFormat};
+
+ ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key);
+
+ if (NULL == cachedValue) {
+ bool value = doReadPixelsSupported(intf, format, type);
+ cachedValue = new ReadPixelsSupportedFormats(key, value);
+ fReadPixelsSupportedCache.put(cachedValue);
+ }
+
+ return cachedValue->value();
+}
+
void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
fMSFBOType = kNone_MSFBOType;
@@ -798,3 +818,17 @@ SkString GrGLCaps::dump() const {
r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
return r;
}
+
+//Computes a hash based on the three values in the key struct
+// bits 31------------15---------7---------------0
+// fFormat(15:0) fType(7:0) fFboFormat(7:0)
+uint32_t GrGLCaps::ReadPixelsSupportedFormats::Hash(const ReadPixelsSupportedFormatsKey& key) {
+ // fFormat has different values like 0x190X or 0x8XXX: 16 bits are required
+ uint32_t hash = ((static_cast<uint32_t>(key.fFormat) & 0xFFFF) << 16);
+ // fType is 0x14XX: 8 lower bits are enough
+ hash |= ((static_cast<uint32_t>(key.fType) & 0xFF) << 8);
+ // fFboFormat is enum GrPixelConfig which has less than 15 values: 8 bits OK
+ hash |= (static_cast<uint32_t>(key.fFboFormat) & 0xFF);
+
+ return hash;
+}
« src/core/SkTHashCache.h ('K') | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698