Add blend intrinsic to C++ API.
Change-Id: Id4d27650d27ef50d2a503307adc60946503a5267
diff --git a/cpp/Android.mk b/cpp/Android.mk
index 8756ce7..1fba998 100644
--- a/cpp/Android.mk
+++ b/cpp/Android.mk
@@ -20,7 +20,8 @@
Type.cpp \
Allocation.cpp \
Script.cpp \
- ScriptC.cpp
+ ScriptC.cpp \
+ ScriptIntrinsics.cpp
LOCAL_SHARED_LIBRARIES := \
libRS \
diff --git a/cpp/ScriptIntrinsics.cpp b/cpp/ScriptIntrinsics.cpp
new file mode 100644
index 0000000..2781e5e
--- /dev/null
+++ b/cpp/ScriptIntrinsics.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2008-2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <utils/Log.h>
+#include <malloc.h>
+
+#include "RenderScript.h"
+#include "rsDefines.h"
+
+using namespace android;
+using namespace renderscriptCpp;
+
+ScriptIntrinsic::ScriptIntrinsic(sp<RS> rs, int id, Element *e)
+ : Script(NULL, rs) {
+ mID = rsScriptIntrinsicCreate(rs->getContext(), id, e);
+}
+
+ScriptIntrinsicBlend::ScriptIntrinsicBlend(sp<RS> rs, Element *e)
+ : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLEND, e) {
+
+}
+
+void ScriptIntrinsicBlend::blendClear(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(0, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendSrc(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(1, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendDst(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(2, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendSrcOver(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(3, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendDstOver(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(4, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendSrcIn(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(5, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendDstIn(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(6, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendSrcOut(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(7, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendDstOut(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(8, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendSrcAtop(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(9, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendDstAtop(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(10, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendXor(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(11, in, out, NULL, 0);
+}
+
+// Numbering jumps here
+void ScriptIntrinsicBlend::blendMultiply(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(14, in, out, NULL, 0);
+}
+
+// Numbering jumps here
+void ScriptIntrinsicBlend::blendAdd(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(34, in, out, NULL, 0);
+}
+
+void ScriptIntrinsicBlend::blendSubtract(sp<Allocation> in, sp<Allocation> out) {
+ Script::forEach(35, in, out, NULL, 0);
+}
+
+
+
+
+
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index bee43d8..0b7e613 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -523,8 +523,33 @@
};
+class ScriptIntrinsic : public Script {
+ protected:
+ ScriptIntrinsic(sp<RS> rs, int id, Element *e);
+};
+
+class ScriptIntrinsicBlend : public ScriptIntrinsic {
+ public:
+ ScriptIntrinsicBlend(sp<RS> rs, Element *e);
+ void blendClear(sp<Allocation> in, sp<Allocation> out);
+ void blendSrc(sp<Allocation> in, sp<Allocation> out);
+ void blendDst(sp<Allocation> in, sp<Allocation> out);
+ void blendSrcOver(sp<Allocation> in, sp<Allocation> out);
+ void blendDstOver(sp<Allocation> in, sp<Allocation> out);
+ void blendSrcIn(sp<Allocation> in, sp<Allocation> out);
+ void blendDstIn(sp<Allocation> in, sp<Allocation> out);
+ void blendSrcOut(sp<Allocation> in, sp<Allocation> out);
+ void blendDstOut(sp<Allocation> in, sp<Allocation> out);
+ void blendSrcAtop(sp<Allocation> in, sp<Allocation> out);
+ void blendDstAtop(sp<Allocation> in, sp<Allocation> out);
+ void blendXor(sp<Allocation> in, sp<Allocation> out);
+ void blendMultiply(sp<Allocation> in, sp<Allocation> out);
+ void blendAdd(sp<Allocation> in, sp<Allocation> out);
+ void blendSubtract(sp<Allocation> in, sp<Allocation> out);
+};
}
+
}
#endif