Move ReadPixels logic to helper methods.
These routines were pretty much duplicated between D3D9 and D3D11.
Since I was going to have to rewrite them again for Vulkan, I
figured it would be best to move them into a common location and
clean them up a bit.
BUG=angleproject:1319
Change-Id: I15d39b052daf3e1020dbd0880f01ae84f3686a0a
Reviewed-on: https://chromium-review.googlesource.com/349630
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index f987918..9c6b0f2 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -20,14 +20,28 @@
// can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid
// format and type combinations.
-typedef std::pair<GLenum, GLenum> FormatTypePair;
-typedef std::pair<FormatTypePair, GLenum> FormatPair;
-typedef std::map<FormatTypePair, GLenum> FormatMap;
+typedef std::pair<FormatType, GLenum> FormatPair;
+typedef std::map<FormatType, GLenum> FormatMap;
+
+FormatType::FormatType() : format(GL_NONE), type(GL_NONE)
+{
+}
+
+FormatType::FormatType(GLenum format_, GLenum type_) : format(format_), type(type_)
+{
+}
+
+bool FormatType::operator<(const FormatType &other) const
+{
+ if (format != other.format)
+ return format < other.format;
+ return type < other.type;
+}
// A helper function to insert data into the format map with fewer characters.
static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLenum internalFormat)
{
- map->insert(FormatPair(FormatTypePair(format, type), internalFormat));
+ map->insert(FormatPair(FormatType(format, type), internalFormat));
}
FormatMap BuildFormatMap()
@@ -799,7 +813,7 @@
}
static const FormatMap formatMap = BuildFormatMap();
- auto iter = formatMap.find(FormatTypePair(internalFormat, type));
+ auto iter = formatMap.find(FormatType(internalFormat, type));
if (iter != formatMap.end())
{
return iter->second;