Add Sampler support to C++ API.
Change-Id: I9a6ada9cf16b5e9f92bcecc12e87d66585df1d33
diff --git a/cpp/Element.cpp b/cpp/Element.cpp
index 7c58516..1289c6e 100644
--- a/cpp/Element.cpp
+++ b/cpp/Element.cpp
@@ -65,8 +65,12 @@
#define CREATE_USER(N, T) sp<const Element> Element::N(sp<RS> rs) { \
- return createUser(rs, RS_TYPE_##T); \
-}
+ if (rs->mElements.N == NULL) { \
+ rs->mElements.N = (createUser(rs, RS_TYPE_##T)).get(); \
+ } \
+ return rs->mElements.N; \
+ }
+
CREATE_USER(BOOLEAN, BOOLEAN);
CREATE_USER(U8, UNSIGNED_8);
CREATE_USER(I8, SIGNED_8);