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 | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 20 | |
| 21 | using namespace android; |
Tim Murray | 9eb7f4b | 2012-11-16 14:02:18 -0800 | [diff] [blame] | 22 | using namespace RSC; |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 23 | |
Tim Murray | 3cd44af | 2012-11-14 11:25:27 -0800 | [diff] [blame] | 24 | ScriptIntrinsic::ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e) |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 25 | : Script(NULL, rs) { |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 26 | mID = RS::dispatch->ScriptIntrinsicCreate(rs->getContext(), id, e->getID()); |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 27 | } |
| 28 | |
Tim Murray | 89daad6 | 2013-07-29 14:30:02 -0700 | [diff] [blame^] | 29 | ScriptIntrinsic3DLUT::ScriptIntrinsic3DLUT(sp<RS> rs, sp<const Element> e) |
| 30 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_3DLUT, e) { |
| 31 | |
| 32 | } |
| 33 | void ScriptIntrinsic3DLUT::forEach(sp<Allocation> ain, sp<Allocation> aout) { |
| 34 | Script::forEach(0, ain, aout, NULL, 0); |
| 35 | } |
| 36 | void ScriptIntrinsic3DLUT::setLUT(sp<Allocation> lut) { |
| 37 | Script::setVar(0, lut); |
| 38 | } |
| 39 | |
Tim Murray | 3cd44af | 2012-11-14 11:25:27 -0800 | [diff] [blame] | 40 | ScriptIntrinsicBlend::ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e) |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 41 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLEND, e) { |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void ScriptIntrinsicBlend::blendClear(sp<Allocation> in, sp<Allocation> out) { |
| 45 | Script::forEach(0, in, out, NULL, 0); |
| 46 | } |
| 47 | |
| 48 | void ScriptIntrinsicBlend::blendSrc(sp<Allocation> in, sp<Allocation> out) { |
| 49 | Script::forEach(1, in, out, NULL, 0); |
| 50 | } |
| 51 | |
| 52 | void ScriptIntrinsicBlend::blendDst(sp<Allocation> in, sp<Allocation> out) { |
| 53 | Script::forEach(2, in, out, NULL, 0); |
| 54 | } |
| 55 | |
| 56 | void ScriptIntrinsicBlend::blendSrcOver(sp<Allocation> in, sp<Allocation> out) { |
| 57 | Script::forEach(3, in, out, NULL, 0); |
| 58 | } |
| 59 | |
| 60 | void ScriptIntrinsicBlend::blendDstOver(sp<Allocation> in, sp<Allocation> out) { |
| 61 | Script::forEach(4, in, out, NULL, 0); |
| 62 | } |
| 63 | |
| 64 | void ScriptIntrinsicBlend::blendSrcIn(sp<Allocation> in, sp<Allocation> out) { |
| 65 | Script::forEach(5, in, out, NULL, 0); |
| 66 | } |
| 67 | |
| 68 | void ScriptIntrinsicBlend::blendDstIn(sp<Allocation> in, sp<Allocation> out) { |
| 69 | Script::forEach(6, in, out, NULL, 0); |
| 70 | } |
| 71 | |
| 72 | void ScriptIntrinsicBlend::blendSrcOut(sp<Allocation> in, sp<Allocation> out) { |
| 73 | Script::forEach(7, in, out, NULL, 0); |
| 74 | } |
| 75 | |
| 76 | void ScriptIntrinsicBlend::blendDstOut(sp<Allocation> in, sp<Allocation> out) { |
| 77 | Script::forEach(8, in, out, NULL, 0); |
| 78 | } |
| 79 | |
| 80 | void ScriptIntrinsicBlend::blendSrcAtop(sp<Allocation> in, sp<Allocation> out) { |
| 81 | Script::forEach(9, in, out, NULL, 0); |
| 82 | } |
| 83 | |
| 84 | void ScriptIntrinsicBlend::blendDstAtop(sp<Allocation> in, sp<Allocation> out) { |
| 85 | Script::forEach(10, in, out, NULL, 0); |
| 86 | } |
| 87 | |
| 88 | void ScriptIntrinsicBlend::blendXor(sp<Allocation> in, sp<Allocation> out) { |
| 89 | Script::forEach(11, in, out, NULL, 0); |
| 90 | } |
| 91 | |
| 92 | // Numbering jumps here |
| 93 | void ScriptIntrinsicBlend::blendMultiply(sp<Allocation> in, sp<Allocation> out) { |
| 94 | Script::forEach(14, in, out, NULL, 0); |
| 95 | } |
| 96 | |
| 97 | // Numbering jumps here |
| 98 | void ScriptIntrinsicBlend::blendAdd(sp<Allocation> in, sp<Allocation> out) { |
| 99 | Script::forEach(34, in, out, NULL, 0); |
| 100 | } |
| 101 | |
| 102 | void ScriptIntrinsicBlend::blendSubtract(sp<Allocation> in, sp<Allocation> out) { |
| 103 | Script::forEach(35, in, out, NULL, 0); |
| 104 | } |
| 105 | |
Tim Murray | 89daad6 | 2013-07-29 14:30:02 -0700 | [diff] [blame^] | 106 | |
| 107 | |
| 108 | |
Tim Murray | 3cd44af | 2012-11-14 11:25:27 -0800 | [diff] [blame] | 109 | ScriptIntrinsicBlur::ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e) |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 110 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLUR, e) { |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 111 | |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 112 | } |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 113 | |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 114 | void ScriptIntrinsicBlur::blur(sp<Allocation> in, sp<Allocation> out) { |
| 115 | Script::setVar(1, in); |
| 116 | Script::forEach(0, NULL, out, NULL, 0); |
| 117 | } |
Tim Murray | 7f0d568 | 2012-11-08 16:35:24 -0800 | [diff] [blame] | 118 | |
Tim Murray | 8f1e60c | 2012-11-13 12:25:11 -0800 | [diff] [blame] | 119 | void ScriptIntrinsicBlur::setRadius(float radius) { |
| 120 | Script::setVar(0, &radius, sizeof(float)); |
| 121 | } |
Tim Murray | 89daad6 | 2013-07-29 14:30:02 -0700 | [diff] [blame^] | 122 | |
| 123 | |
| 124 | |
| 125 | ScriptIntrinsicColorMatrix::ScriptIntrinsicColorMatrix(sp<RS> rs, sp<const Element> e) |
| 126 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_COLOR_MATRIX, e) { |
| 127 | |
| 128 | } |
| 129 | |
| 130 | void ScriptIntrinsicColorMatrix::forEach(sp<Allocation> in, sp<Allocation> out) { |
| 131 | Script::forEach(0, in, out, NULL, 0); |
| 132 | } |
| 133 | |
| 134 | |
| 135 | void ScriptIntrinsicColorMatrix::setColorMatrix3(float* m) { |
| 136 | Script::setVar(0, (void*)m, sizeof(float) * 9); |
| 137 | } |
| 138 | |
| 139 | |
| 140 | void ScriptIntrinsicColorMatrix::setColorMatrix4(float* m) { |
| 141 | Script::setVar(0, (void*)m, sizeof(float) * 16); |
| 142 | } |
| 143 | |
| 144 | |
| 145 | void ScriptIntrinsicColorMatrix::setGreyscale() { |
| 146 | float matrix[] = {0.299f, 0.587f, 0.114f, 0.299f, 0.587f, 0.114f, 0.299f, 0.587f, 0.114f}; |
| 147 | setColorMatrix3(matrix); |
| 148 | } |
| 149 | |
| 150 | |
| 151 | void ScriptIntrinsicColorMatrix::setRGBtoYUV() { |
| 152 | float matrix[] = {0.299f,0.587f,0.114f,-0.14713f,-0.28886f,0.436f,0.615f,-0.51499f,-0.10001f}; |
| 153 | setColorMatrix3(matrix); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | void ScriptIntrinsicColorMatrix::setYUVtoRGB() { |
| 158 | float matrix[] = {1.f,0.f,1.13983f,1.f,-0.39465f,-0.5806f,1.f,2.03211f,0.f}; |
| 159 | setColorMatrix3(matrix); |
| 160 | } |
| 161 | |
| 162 | ScriptIntrinsicConvolve3x3::ScriptIntrinsicConvolve3x3(sp<RS> rs, sp<const Element> e) |
| 163 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_CONVOLVE_3x3, e) { |
| 164 | |
| 165 | } |
| 166 | |
| 167 | void ScriptIntrinsicConvolve3x3::setInput(sp<Allocation> in) { |
| 168 | Script::setVar(1, in); |
| 169 | } |
| 170 | |
| 171 | void ScriptIntrinsicConvolve3x3::forEach(sp<Allocation> out) { |
| 172 | Script::forEach(0, NULL, out, NULL, 0); |
| 173 | } |
| 174 | |
| 175 | void ScriptIntrinsicConvolve3x3::setCoefficients(float* v) { |
| 176 | Script::setVar(0, (void*)v, sizeof(float) * 9); |
| 177 | } |
| 178 | |
| 179 | ScriptIntrinsicConvolve5x5::ScriptIntrinsicConvolve5x5(sp<RS> rs, sp<const Element> e) |
| 180 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_CONVOLVE_5x5, e) { |
| 181 | |
| 182 | } |
| 183 | |
| 184 | void ScriptIntrinsicConvolve5x5::setInput(sp<Allocation> in) { |
| 185 | Script::setVar(1, in); |
| 186 | } |
| 187 | |
| 188 | void ScriptIntrinsicConvolve5x5::forEach(sp<Allocation> out) { |
| 189 | Script::forEach(0, NULL, out, NULL, 0); |
| 190 | } |
| 191 | |
| 192 | void ScriptIntrinsicConvolve5x5::setCoefficients(float* v) { |
| 193 | Script::setVar(0, (void*)v, sizeof(float) * 25); |
| 194 | } |
| 195 | |
| 196 | /*ScriptIntrinsicLUT::ScriptIntrinsicLUT(sp<RS> rs, sp<const Element> e) |
| 197 | : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_LUT, e) { |
| 198 | |
| 199 | } |
| 200 | |
| 201 | void ScriptIntrinsicLUT::forEach(sp<Allocation> ain, sp<Allocation> aout) { |
| 202 | |
| 203 | } |
| 204 | |
| 205 | void ScriptIntrinsicLUT::setLUT(sp<Allocation> lut) { |
| 206 | |
| 207 | }*/ |
| 208 | |