color blindness enhancement
This is an attempt at improving the experience of
users with color vision impairement.
At this time this feature can only be enabled for
debugging:
adb shell service call SurfaceFlinger 1014 i32 PARAM
with PARAM:
0 : disabled
1 : protanomaly/protanopia simulation
2 : deuteranomaly/deuteranopia simulation
3 : tritanopia/tritanomaly simulation
11, 12, 13: same as above w/ attempted correction/enhancement
The enhancement algorithm tries to spread the "error"
such that tones that would otherwise appear similar can be
distinguished.
Bug: 9465644
Change-Id: I860f7eed0cb81f54ef9cf24ad78155b6395ade48
diff --git a/services/surfaceflinger/RenderEngine/Mesh.h b/services/surfaceflinger/RenderEngine/Mesh.h
index 160d765..b6d42b0 100644
--- a/services/surfaceflinger/RenderEngine/Mesh.h
+++ b/services/surfaceflinger/RenderEngine/Mesh.h
@@ -33,32 +33,28 @@
~Mesh();
/*
- * VertexArray handles the stride automatically. It also provides
- * a convenient way to set position and texture coordinates by using
- * the usual x,y,z,w or s,t,r,q names.
+ * VertexArray handles the stride automatically.
*/
+ template <typename TYPE>
class VertexArray {
friend class Mesh;
float* mData;
size_t mStride;
VertexArray(float* data, size_t stride) : mData(data), mStride(stride) { }
public:
- struct vertexData {
- operator float*() { return reinterpret_cast<float*>(this); }
- union {
- struct { float x, y, z, w; };
- struct { float s, t, r, q; };
- };
- };
- vertexData& operator[](size_t index) {
- return *reinterpret_cast<vertexData*>(&mData[index*mStride]); }
-
- vertexData const& operator[](size_t index) const {
- return *reinterpret_cast<vertexData const*>(&mData[index*mStride]); }
+ TYPE& operator[](size_t index) {
+ return *reinterpret_cast<TYPE*>(&mData[index*mStride]);
+ }
+ TYPE const& operator[](size_t index) const {
+ return *reinterpret_cast<TYPE const*>(&mData[index*mStride]);
+ }
};
- VertexArray getPositionArray() { return VertexArray(getPositions(), mStride); }
- VertexArray getTexCoordArray() { return VertexArray(getTexCoords(), mStride); }
+ template <typename TYPE>
+ VertexArray<TYPE> getPositionArray() { return VertexArray<TYPE>(getPositions(), mStride); }
+
+ template <typename TYPE>
+ VertexArray<TYPE> getTexCoordArray() { return VertexArray<TYPE>(getTexCoords(), mStride); }
Primitive getPrimitive() const;