Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 17 | #include <malloc.h> |
| 18 | |
| 19 | #include "RenderScript.h" |
Tim Murray | b206ace | 2013-02-13 14:52:20 -0800 | [diff] [blame] | 20 | #include <rs.h> |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 21 | #include "rsDefines.h" |
| 22 | |
| 23 | using namespace android; |
Tim Murray | 9eb7f4b | 2012-11-16 14:02:18 -0800 | [diff] [blame] | 24 | using namespace RSC; |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 25 | |
Tim Murray | 3cd44af | 2012-11-14 11:25:27 -0800 | [diff] [blame] | 26 | ScriptIntrinsic::ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e) |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 27 | : Script(NULL, rs) { |
Tim Murray | 3cd44af | 2012-11-14 11:25:27 -0800 | [diff] [blame] | 28 | mID = rsScriptIntrinsicCreate(rs->getContext(), id, e->getID()); |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 29 | } |
| 30 | |
Tim Murray | 3cd44af | 2012-11-14 11:25:27 -0800 | [diff] [blame] | 31 | ScriptIntrinsicBlend::ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e) |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 32 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLEND, e) { |
| 33 | |
| 34 | } |
| 35 | |
| 36 | void ScriptIntrinsicBlend::blendClear(sp<Allocation> in, sp<Allocation> out) { |
| 37 | Script::forEach(0, in, out, NULL, 0); |
| 38 | } |
| 39 | |
| 40 | void ScriptIntrinsicBlend::blendSrc(sp<Allocation> in, sp<Allocation> out) { |
| 41 | Script::forEach(1, in, out, NULL, 0); |
| 42 | } |
| 43 | |
| 44 | void ScriptIntrinsicBlend::blendDst(sp<Allocation> in, sp<Allocation> out) { |
| 45 | Script::forEach(2, in, out, NULL, 0); |
| 46 | } |
| 47 | |
| 48 | void ScriptIntrinsicBlend::blendSrcOver(sp<Allocation> in, sp<Allocation> out) { |
| 49 | Script::forEach(3, in, out, NULL, 0); |
| 50 | } |
| 51 | |
| 52 | void ScriptIntrinsicBlend::blendDstOver(sp<Allocation> in, sp<Allocation> out) { |
| 53 | Script::forEach(4, in, out, NULL, 0); |
| 54 | } |
| 55 | |
| 56 | void ScriptIntrinsicBlend::blendSrcIn(sp<Allocation> in, sp<Allocation> out) { |
| 57 | Script::forEach(5, in, out, NULL, 0); |
| 58 | } |
| 59 | |
| 60 | void ScriptIntrinsicBlend::blendDstIn(sp<Allocation> in, sp<Allocation> out) { |
| 61 | Script::forEach(6, in, out, NULL, 0); |
| 62 | } |
| 63 | |
| 64 | void ScriptIntrinsicBlend::blendSrcOut(sp<Allocation> in, sp<Allocation> out) { |
| 65 | Script::forEach(7, in, out, NULL, 0); |
| 66 | } |
| 67 | |
| 68 | void ScriptIntrinsicBlend::blendDstOut(sp<Allocation> in, sp<Allocation> out) { |
| 69 | Script::forEach(8, in, out, NULL, 0); |
| 70 | } |
| 71 | |
| 72 | void ScriptIntrinsicBlend::blendSrcAtop(sp<Allocation> in, sp<Allocation> out) { |
| 73 | Script::forEach(9, in, out, NULL, 0); |
| 74 | } |
| 75 | |
| 76 | void ScriptIntrinsicBlend::blendDstAtop(sp<Allocation> in, sp<Allocation> out) { |
| 77 | Script::forEach(10, in, out, NULL, 0); |
| 78 | } |
| 79 | |
| 80 | void ScriptIntrinsicBlend::blendXor(sp<Allocation> in, sp<Allocation> out) { |
| 81 | Script::forEach(11, in, out, NULL, 0); |
| 82 | } |
| 83 | |
| 84 | // Numbering jumps here |
| 85 | void ScriptIntrinsicBlend::blendMultiply(sp<Allocation> in, sp<Allocation> out) { |
| 86 | Script::forEach(14, in, out, NULL, 0); |
| 87 | } |
| 88 | |
| 89 | // Numbering jumps here |
| 90 | void ScriptIntrinsicBlend::blendAdd(sp<Allocation> in, sp<Allocation> out) { |
| 91 | Script::forEach(34, in, out, NULL, 0); |
| 92 | } |
| 93 | |
| 94 | void ScriptIntrinsicBlend::blendSubtract(sp<Allocation> in, sp<Allocation> out) { |
| 95 | Script::forEach(35, in, out, NULL, 0); |
| 96 | } |
| 97 | |
Tim Murray | 3cd44af | 2012-11-14 11:25:27 -0800 | [diff] [blame] | 98 | ScriptIntrinsicBlur::ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e) |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 99 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLUR, e) { |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 100 | |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 101 | } |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 102 | |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 103 | void ScriptIntrinsicBlur::blur(sp<Allocation> in, sp<Allocation> out) { |
| 104 | Script::setVar(1, in); |
| 105 | Script::forEach(0, NULL, out, NULL, 0); |
| 106 | } |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 107 | |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 108 | void ScriptIntrinsicBlur::setRadius(float radius) { |
| 109 | Script::setVar(0, &radius, sizeof(float)); |
| 110 | } |