summaryrefslogtreecommitdiff
path: root/cpp/ScriptIntrinsics.cpp
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2015-03-10 15:29:40 -0700
committerMiao Wang <miaowang@google.com>2015-03-30 12:16:28 -0700
commite5428e661ce6f9d24f838cab0a8fb0fa8c76dbca (patch)
tree63202ff218aff023d7b0adb5e34cb28dff992287 /cpp/ScriptIntrinsics.cpp
parentc3851d58e6f0a97a3f5239d78515acd2be47b507 (diff)
Update RenderScript C++ API
- Add Copy3DRangeTo API - Add AutoPadding & unPadding for CopyTo and CopyFrom APIs - Add IntrinsicResize Change-Id: I1138225f8a7b738929a09636bf2669f5d68b0c7d
Diffstat (limited to 'cpp/ScriptIntrinsics.cpp')
-rw-r--r--cpp/ScriptIntrinsics.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/cpp/ScriptIntrinsics.cpp b/cpp/ScriptIntrinsics.cpp
index e40d1a03..54ce4650 100644
--- a/cpp/ScriptIntrinsics.cpp
+++ b/cpp/ScriptIntrinsics.cpp
@@ -24,7 +24,8 @@ using namespace RSC;
ScriptIntrinsic::ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e)
: Script(nullptr, rs) {
- mID = createDispatch(rs, RS::dispatch->ScriptIntrinsicCreate(rs->getContext(), id, e->getID()));
+ mID = createDispatch(rs, RS::dispatch->ScriptIntrinsicCreate(rs->getContext(), id,
+ e != nullptr ? e->getID() : 0));
mElement = e;
}
@@ -569,6 +570,43 @@ ScriptIntrinsicLUT::~ScriptIntrinsicLUT() {
}
+sp<ScriptIntrinsicResize> ScriptIntrinsicResize::create(sp<RS> rs) {
+ return new ScriptIntrinsicResize(rs, nullptr);
+}
+
+ScriptIntrinsicResize::ScriptIntrinsicResize(sp<RS> rs, sp<const Element> e)
+ : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_RESIZE, e) {
+
+}
+void ScriptIntrinsicResize::forEach_bicubic(sp<Allocation> aout) {
+ if (aout == mInput) {
+ mRS->throwError(RS_ERROR_INVALID_PARAMETER, "Resize Input and Ouput cannot be the same");
+ }
+
+ if (!(mInput->getType()->getElement()->isCompatible(aout->getType()->getElement()))) {
+ mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Resize forEach element mismatch");
+ return;
+ }
+ Script::forEach(0, nullptr, aout, nullptr, 0);
+}
+void ScriptIntrinsicResize::setInput(sp<Allocation> ain) {
+ if (!(ain->getType()->getElement()->isCompatible(Element::U8(mRS))) &&
+ !(ain->getType()->getElement()->isCompatible(Element::U8_2(mRS))) &&
+ !(ain->getType()->getElement()->isCompatible(Element::U8_3(mRS))) &&
+ !(ain->getType()->getElement()->isCompatible(Element::U8_4(mRS))) &&
+ !(ain->getType()->getElement()->isCompatible(Element::F32(mRS))) &&
+ !(ain->getType()->getElement()->isCompatible(Element::F32_2(mRS))) &&
+ !(ain->getType()->getElement()->isCompatible(Element::F32_3(mRS))) &&
+ !(ain->getType()->getElement()->isCompatible(Element::F32_4(mRS)))) {
+ mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element for Resize Input");
+ return;
+ }
+
+ mInput = ain;
+ Script::setVar(0, ain);
+}
+
+
sp<ScriptIntrinsicYuvToRGB> ScriptIntrinsicYuvToRGB::create(sp<RS> rs, sp<const Element> e) {
if (!(e->isCompatible(Element::U8_4(rs)))) {
rs->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element for YuvToRGB");