| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 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 |  | 
|  | 17 | package android.renderscript; | 
|  | 18 |  | 
|  | 19 |  | 
|  | 20 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 21 | * Intrinsic kernels for blending two {@link android.renderscript.Allocation} objects. | 
| Xusong Wang | 8b4548c | 2021-01-05 10:09:52 -0800 | [diff] [blame] | 22 | * | 
|  | 23 | * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a | 
|  | 24 | * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration | 
|  | 25 | * guide</a> for the proposed alternatives. | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 26 | **/ | 
| Xusong Wang | 8b4548c | 2021-01-05 10:09:52 -0800 | [diff] [blame] | 27 | @Deprecated | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 28 | public class ScriptIntrinsicBlend extends ScriptIntrinsic { | 
| Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 29 | ScriptIntrinsicBlend(long id, RenderScript rs) { | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 30 | super(id, rs); | 
|  | 31 | } | 
|  | 32 |  | 
|  | 33 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 34 | * Supported elements types are {@link Element#U8_4} | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 35 | * | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 36 | * @param rs The RenderScript context | 
|  | 37 | * @param e Element type for inputs and outputs | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 38 | * | 
|  | 39 | * @return ScriptIntrinsicBlend | 
|  | 40 | */ | 
|  | 41 | public static ScriptIntrinsicBlend create(RenderScript rs, Element e) { | 
| Tim Murray | 74478f7 | 2012-09-26 13:46:46 -0700 | [diff] [blame] | 42 | // 7 comes from RS_SCRIPT_INTRINSIC_ID_BLEND in rsDefines.h | 
| Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 43 | long id = rs.nScriptIntrinsicCreate(7, e.getID(rs)); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 44 | return new ScriptIntrinsicBlend(id, rs); | 
|  | 45 |  | 
|  | 46 | } | 
|  | 47 |  | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 48 | private void blend(int id, Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
| Tim Murray | 74478f7 | 2012-09-26 13:46:46 -0700 | [diff] [blame] | 49 | if (!ain.getElement().isCompatible(Element.U8_4(mRS))) { | 
|  | 50 | throw new RSIllegalArgumentException("Input is not of expected format."); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 51 | } | 
| Tim Murray | 74478f7 | 2012-09-26 13:46:46 -0700 | [diff] [blame] | 52 | if (!aout.getElement().isCompatible(Element.U8_4(mRS))) { | 
|  | 53 | throw new RSIllegalArgumentException("Output is not of expected format."); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 54 | } | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 55 | forEach(id, ain, aout, null, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 56 | } | 
|  | 57 |  | 
|  | 58 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 59 | * Sets dst = {0, 0, 0, 0} | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 60 | * | 
|  | 61 | * @param ain The source buffer | 
|  | 62 | * @param aout The destination buffer | 
|  | 63 | */ | 
|  | 64 | public void forEachClear(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 65 | forEachClear(ain, aout, null); | 
|  | 66 | } | 
|  | 67 |  | 
|  | 68 | /** | 
|  | 69 | * Sets dst = {0, 0, 0, 0} | 
|  | 70 | * | 
|  | 71 | * @param ain The source buffer | 
|  | 72 | * @param aout The destination buffer | 
|  | 73 | * @param opt LaunchOptions for clipping | 
|  | 74 | */ | 
|  | 75 | public void forEachClear(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 76 | blend(0, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 77 | } | 
|  | 78 |  | 
|  | 79 | /** | 
|  | 80 | * Get a KernelID for the Clear kernel. | 
|  | 81 | * | 
|  | 82 | * @return Script.KernelID The KernelID object. | 
|  | 83 | */ | 
|  | 84 | public Script.KernelID getKernelIDClear() { | 
|  | 85 | return createKernelID(0, 3, null, null); | 
|  | 86 | } | 
|  | 87 |  | 
|  | 88 |  | 
|  | 89 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 90 | * Sets dst = src | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 91 | * | 
|  | 92 | * @param ain The source buffer | 
|  | 93 | * @param aout The destination buffer | 
|  | 94 | */ | 
|  | 95 | public void forEachSrc(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 96 | forEachSrc(ain, aout, null); | 
|  | 97 | } | 
|  | 98 |  | 
|  | 99 | /** | 
|  | 100 | * Sets dst = src | 
|  | 101 | * | 
|  | 102 | * @param ain The source buffer | 
|  | 103 | * @param aout The destination buffer | 
|  | 104 | * @param opt LaunchOptions for clipping | 
|  | 105 | */ | 
|  | 106 | public void forEachSrc(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
| Jean-Luc Brouillet | a2c6eb2 | 2021-02-12 22:39:33 -0800 | [diff] [blame] | 107 | blend(1, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 108 | } | 
|  | 109 |  | 
|  | 110 | /** | 
|  | 111 | * Get a KernelID for the Src kernel. | 
|  | 112 | * | 
|  | 113 | * @return Script.KernelID The KernelID object. | 
|  | 114 | */ | 
|  | 115 | public Script.KernelID getKernelIDSrc() { | 
|  | 116 | return createKernelID(1, 3, null, null); | 
|  | 117 | } | 
|  | 118 |  | 
|  | 119 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 120 | * Sets dst = dst | 
|  | 121 | * | 
|  | 122 | * This is a NOP. | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 123 | * | 
|  | 124 | * @param ain The source buffer | 
|  | 125 | * @param aout The destination buffer | 
|  | 126 | */ | 
|  | 127 | public void forEachDst(Allocation ain, Allocation aout) { | 
|  | 128 | // NOP | 
|  | 129 | } | 
|  | 130 |  | 
|  | 131 | /** | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 132 | * Sets dst = dst | 
|  | 133 | * | 
|  | 134 | * This is a NOP. | 
|  | 135 | * | 
|  | 136 | * @param ain The source buffer | 
|  | 137 | * @param aout The destination buffer | 
|  | 138 | * @param opt LaunchOptions for clipping | 
|  | 139 | */ | 
|  | 140 | public void forEachDst(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 141 | // N, optOP | 
|  | 142 | } | 
|  | 143 |  | 
|  | 144 | /** | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 145 | * Get a KernelID for the Dst kernel. | 
|  | 146 | * | 
|  | 147 | * @return Script.KernelID The KernelID object. | 
|  | 148 | */ | 
|  | 149 | public Script.KernelID getKernelIDDst() { | 
|  | 150 | return createKernelID(2, 3, null, null); | 
|  | 151 | } | 
|  | 152 |  | 
|  | 153 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 154 | * Sets dst = src + dst * (1.0 - src.a) | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 155 | * | 
|  | 156 | * @param ain The source buffer | 
|  | 157 | * @param aout The destination buffer | 
|  | 158 | */ | 
|  | 159 | public void forEachSrcOver(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 160 | forEachSrcOver(ain, aout, null); | 
|  | 161 | } | 
|  | 162 |  | 
|  | 163 | /** | 
|  | 164 | * Sets dst = src + dst * (1.0 - src.a) | 
|  | 165 | * | 
|  | 166 | * @param ain The source buffer | 
|  | 167 | * @param aout The destination buffer | 
|  | 168 | * @param opt LaunchOptions for clipping | 
|  | 169 | */ | 
|  | 170 | public void forEachSrcOver(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 171 | blend(3, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 172 | } | 
|  | 173 |  | 
|  | 174 | /** | 
|  | 175 | * Get a KernelID for the SrcOver kernel. | 
|  | 176 | * | 
|  | 177 | * @return Script.KernelID The KernelID object. | 
|  | 178 | */ | 
|  | 179 | public Script.KernelID getKernelIDSrcOver() { | 
|  | 180 | return createKernelID(3, 3, null, null); | 
|  | 181 | } | 
|  | 182 |  | 
|  | 183 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 184 | * Sets dst = dst + src * (1.0 - dst.a) | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 185 | * | 
|  | 186 | * @param ain The source buffer | 
|  | 187 | * @param aout The destination buffer | 
|  | 188 | */ | 
|  | 189 | public void forEachDstOver(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 190 | forEachDstOver(ain, aout, null); | 
|  | 191 | } | 
|  | 192 |  | 
|  | 193 | /** | 
|  | 194 | * Sets dst = dst + src * (1.0 - dst.a) | 
|  | 195 | * | 
|  | 196 | * @param ain The source buffer | 
|  | 197 | * @param aout The destination buffer | 
|  | 198 | * @param opt LaunchOptions for clipping | 
|  | 199 | */ | 
|  | 200 | public void forEachDstOver(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 201 | blend(4, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 202 | } | 
|  | 203 |  | 
|  | 204 | /** | 
|  | 205 | * Get a KernelID for the DstOver kernel. | 
|  | 206 | * | 
|  | 207 | * @return Script.KernelID The KernelID object. | 
|  | 208 | */ | 
|  | 209 | public Script.KernelID getKernelIDDstOver() { | 
|  | 210 | return createKernelID(4, 3, null, null); | 
|  | 211 | } | 
|  | 212 |  | 
|  | 213 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 214 | * Sets dst = src * dst.a | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 215 | * | 
|  | 216 | * @param ain The source buffer | 
|  | 217 | * @param aout The destination buffer | 
|  | 218 | */ | 
|  | 219 | public void forEachSrcIn(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 220 | forEachSrcIn(ain, aout, null); | 
|  | 221 | } | 
|  | 222 |  | 
|  | 223 | /** | 
|  | 224 | * Sets dst = src * dst.a | 
|  | 225 | * | 
|  | 226 | * @param ain The source buffer | 
|  | 227 | * @param aout The destination buffer | 
|  | 228 | * @param opt LaunchOptions for clipping | 
|  | 229 | */ | 
|  | 230 | public void forEachSrcIn(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 231 | blend(5, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 232 | } | 
|  | 233 |  | 
|  | 234 | /** | 
|  | 235 | * Get a KernelID for the SrcIn kernel. | 
|  | 236 | * | 
|  | 237 | * @return Script.KernelID The KernelID object. | 
|  | 238 | */ | 
|  | 239 | public Script.KernelID getKernelIDSrcIn() { | 
|  | 240 | return createKernelID(5, 3, null, null); | 
|  | 241 | } | 
|  | 242 |  | 
|  | 243 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 244 | * Sets dst = dst * src.a | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 245 | * | 
|  | 246 | * @param ain The source buffer | 
|  | 247 | * @param aout The destination buffer | 
|  | 248 | */ | 
|  | 249 | public void forEachDstIn(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 250 | forEachDstIn(ain, aout, null); | 
|  | 251 | } | 
|  | 252 |  | 
|  | 253 | /** | 
|  | 254 | * Sets dst = dst * src.a | 
|  | 255 | * | 
|  | 256 | * @param ain The source buffer | 
|  | 257 | * @param aout The destination buffer | 
|  | 258 | * @param opt LaunchOptions for clipping | 
|  | 259 | */ | 
|  | 260 | public void forEachDstIn(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 261 | blend(6, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 262 | } | 
|  | 263 |  | 
|  | 264 | /** | 
|  | 265 | * Get a KernelID for the DstIn kernel. | 
|  | 266 | * | 
|  | 267 | * @return Script.KernelID The KernelID object. | 
|  | 268 | */ | 
|  | 269 | public Script.KernelID getKernelIDDstIn() { | 
|  | 270 | return createKernelID(6, 3, null, null); | 
|  | 271 | } | 
|  | 272 |  | 
|  | 273 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 274 | * Sets dst = src * (1.0 - dst.a) | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 275 | * | 
|  | 276 | * @param ain The source buffer | 
|  | 277 | * @param aout The destination buffer | 
|  | 278 | */ | 
|  | 279 | public void forEachSrcOut(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 280 | forEachSrcOut(ain, aout, null); | 
|  | 281 | } | 
|  | 282 |  | 
|  | 283 | /** | 
|  | 284 | * Sets dst = src * (1.0 - dst.a) | 
|  | 285 | * | 
|  | 286 | * @param ain The source buffer | 
|  | 287 | * @param aout The destination buffer | 
|  | 288 | * @param opt LaunchOptions for clipping | 
|  | 289 | */ | 
|  | 290 | public void forEachSrcOut(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 291 | blend(7, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 292 | } | 
|  | 293 |  | 
|  | 294 | /** | 
|  | 295 | * Get a KernelID for the SrcOut kernel. | 
|  | 296 | * | 
|  | 297 | * @return Script.KernelID The KernelID object. | 
|  | 298 | */ | 
|  | 299 | public Script.KernelID getKernelIDSrcOut() { | 
|  | 300 | return createKernelID(7, 3, null, null); | 
|  | 301 | } | 
|  | 302 |  | 
|  | 303 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 304 | * Sets dst = dst * (1.0 - src.a) | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 305 | * | 
|  | 306 | * @param ain The source buffer | 
|  | 307 | * @param aout The destination buffer | 
|  | 308 | */ | 
|  | 309 | public void forEachDstOut(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 310 | forEachDstOut(ain, aout, null); | 
|  | 311 | } | 
|  | 312 |  | 
|  | 313 | /** | 
|  | 314 | * Sets dst = dst * (1.0 - src.a) | 
|  | 315 | * | 
|  | 316 | * @param ain The source buffer | 
|  | 317 | * @param aout The destination buffer | 
|  | 318 | * @param opt LaunchOptions for clipping | 
|  | 319 | */ | 
|  | 320 | public void forEachDstOut(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 321 | blend(8, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 322 | } | 
|  | 323 |  | 
|  | 324 | /** | 
|  | 325 | * Get a KernelID for the DstOut kernel. | 
|  | 326 | * | 
|  | 327 | * @return Script.KernelID The KernelID object. | 
|  | 328 | */ | 
|  | 329 | public Script.KernelID getKernelIDDstOut() { | 
|  | 330 | return createKernelID(8, 3, null, null); | 
|  | 331 | } | 
|  | 332 |  | 
|  | 333 | /** | 
|  | 334 | * dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb | 
|  | 335 | * dst.a = dst.a | 
|  | 336 | * | 
|  | 337 | * @param ain The source buffer | 
|  | 338 | * @param aout The destination buffer | 
|  | 339 | */ | 
|  | 340 | public void forEachSrcAtop(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 341 | forEachSrcAtop(ain, aout, null); | 
|  | 342 | } | 
|  | 343 |  | 
|  | 344 | /** | 
|  | 345 | * dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb | 
|  | 346 | * dst.a = dst.a | 
|  | 347 | * | 
|  | 348 | * @param ain The source buffer | 
|  | 349 | * @param aout The destination buffer | 
|  | 350 | * @param opt LaunchOptions for clipping | 
|  | 351 | */ | 
|  | 352 | public void forEachSrcAtop(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 353 | blend(9, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 354 | } | 
|  | 355 |  | 
|  | 356 | /** | 
|  | 357 | * Get a KernelID for the SrcAtop kernel. | 
|  | 358 | * | 
|  | 359 | * @return Script.KernelID The KernelID object. | 
|  | 360 | */ | 
|  | 361 | public Script.KernelID getKernelIDSrcAtop() { | 
|  | 362 | return createKernelID(9, 3, null, null); | 
|  | 363 | } | 
|  | 364 |  | 
|  | 365 | /** | 
|  | 366 | * dst = dst.rgb * src.a + (1.0 - dst.a) * src.rgb | 
|  | 367 | * dst.a = src.a | 
| Miao Wang | ffb1a9b | 2015-07-20 15:05:31 -0700 | [diff] [blame] | 368 | * Note: Before API 23, the alpha channel was not correctly set. | 
|  | 369 | *       Please use with caution when targeting older APIs. | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 370 | * | 
|  | 371 | * @param ain The source buffer | 
|  | 372 | * @param aout The destination buffer | 
|  | 373 | */ | 
|  | 374 | public void forEachDstAtop(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 375 | forEachDstAtop(ain, aout, null); | 
|  | 376 | } | 
|  | 377 |  | 
|  | 378 | /** | 
|  | 379 | * dst = dst.rgb * src.a + (1.0 - dst.a) * src.rgb | 
|  | 380 | * dst.a = src.a | 
| Miao Wang | ffb1a9b | 2015-07-20 15:05:31 -0700 | [diff] [blame] | 381 | * Note: Before API 23, the alpha channel was not correctly set. | 
|  | 382 | *       Please use with caution when targeting older APIs. | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 383 | * | 
|  | 384 | * @param ain The source buffer | 
|  | 385 | * @param aout The destination buffer | 
|  | 386 | * @param opt LaunchOptions for clipping | 
|  | 387 | */ | 
|  | 388 | public void forEachDstAtop(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 389 | blend(10, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 390 | } | 
|  | 391 |  | 
|  | 392 | /** | 
|  | 393 | * Get a KernelID for the DstAtop kernel. | 
|  | 394 | * | 
|  | 395 | * @return Script.KernelID The KernelID object. | 
|  | 396 | */ | 
|  | 397 | public Script.KernelID getKernelIDDstAtop() { | 
|  | 398 | return createKernelID(10, 3, null, null); | 
|  | 399 | } | 
|  | 400 |  | 
|  | 401 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 402 | * Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a} | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 403 | * | 
|  | 404 | * @param ain The source buffer | 
|  | 405 | * @param aout The destination buffer | 
|  | 406 | */ | 
|  | 407 | public void forEachXor(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 408 | forEachXor(ain, aout, null); | 
|  | 409 | } | 
|  | 410 |  | 
|  | 411 | /** | 
|  | 412 | * Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a} | 
|  | 413 | * | 
| John Hoford | 6ba4cb7 | 2015-06-29 18:15:22 -0700 | [diff] [blame] | 414 | * <b>Note:</b> this is NOT the Porter/Duff XOR mode; this is a bitwise xor. | 
|  | 415 | * | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 416 | * @param ain The source buffer | 
|  | 417 | * @param aout The destination buffer | 
|  | 418 | * @param opt LaunchOptions for clipping | 
|  | 419 | */ | 
|  | 420 | public void forEachXor(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 421 | blend(11, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 422 | } | 
|  | 423 |  | 
|  | 424 | /** | 
|  | 425 | * Get a KernelID for the Xor kernel. | 
|  | 426 | * | 
|  | 427 | * @return Script.KernelID The KernelID object. | 
|  | 428 | */ | 
|  | 429 | public Script.KernelID getKernelIDXor() { | 
|  | 430 | return createKernelID(11, 3, null, null); | 
|  | 431 | } | 
|  | 432 |  | 
|  | 433 | //////// | 
|  | 434 | /* | 
|  | 435 | public void forEachNormal(Allocation ain, Allocation aout) { | 
|  | 436 | blend(12, ain, aout); | 
|  | 437 | } | 
|  | 438 |  | 
|  | 439 | public void forEachAverage(Allocation ain, Allocation aout) { | 
|  | 440 | blend(13, ain, aout); | 
|  | 441 | } | 
|  | 442 | */ | 
|  | 443 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 444 | * Sets dst = src * dst | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 445 | * | 
|  | 446 | * @param ain The source buffer | 
|  | 447 | * @param aout The destination buffer | 
|  | 448 | */ | 
|  | 449 | public void forEachMultiply(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 450 | forEachMultiply(ain, aout, null); | 
|  | 451 | } | 
|  | 452 |  | 
|  | 453 | /** | 
|  | 454 | * Sets dst = src * dst | 
|  | 455 | * | 
|  | 456 | * @param ain The source buffer | 
|  | 457 | * @param aout The destination buffer | 
|  | 458 | * @param opt LaunchOptions for clipping | 
|  | 459 | */ | 
|  | 460 | public void forEachMultiply(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 461 | blend(14, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 462 | } | 
|  | 463 |  | 
|  | 464 | /** | 
|  | 465 | * Get a KernelID for the Multiply kernel. | 
|  | 466 | * | 
|  | 467 | * @return Script.KernelID The KernelID object. | 
|  | 468 | */ | 
|  | 469 | public Script.KernelID getKernelIDMultiply() { | 
|  | 470 | return createKernelID(14, 3, null, null); | 
|  | 471 | } | 
|  | 472 |  | 
|  | 473 | /* | 
|  | 474 | public void forEachScreen(Allocation ain, Allocation aout) { | 
|  | 475 | blend(15, ain, aout); | 
|  | 476 | } | 
|  | 477 |  | 
|  | 478 | public void forEachDarken(Allocation ain, Allocation aout) { | 
|  | 479 | blend(16, ain, aout); | 
|  | 480 | } | 
|  | 481 |  | 
|  | 482 | public void forEachLighten(Allocation ain, Allocation aout) { | 
|  | 483 | blend(17, ain, aout); | 
|  | 484 | } | 
|  | 485 |  | 
|  | 486 | public void forEachOverlay(Allocation ain, Allocation aout) { | 
|  | 487 | blend(18, ain, aout); | 
|  | 488 | } | 
|  | 489 |  | 
|  | 490 | public void forEachHardlight(Allocation ain, Allocation aout) { | 
|  | 491 | blend(19, ain, aout); | 
|  | 492 | } | 
|  | 493 |  | 
|  | 494 | public void forEachSoftlight(Allocation ain, Allocation aout) { | 
|  | 495 | blend(20, ain, aout); | 
|  | 496 | } | 
|  | 497 |  | 
|  | 498 | public void forEachDifference(Allocation ain, Allocation aout) { | 
|  | 499 | blend(21, ain, aout); | 
|  | 500 | } | 
|  | 501 |  | 
|  | 502 | public void forEachNegation(Allocation ain, Allocation aout) { | 
|  | 503 | blend(22, ain, aout); | 
|  | 504 | } | 
|  | 505 |  | 
|  | 506 | public void forEachExclusion(Allocation ain, Allocation aout) { | 
|  | 507 | blend(23, ain, aout); | 
|  | 508 | } | 
|  | 509 |  | 
|  | 510 | public void forEachColorDodge(Allocation ain, Allocation aout) { | 
|  | 511 | blend(24, ain, aout); | 
|  | 512 | } | 
|  | 513 |  | 
|  | 514 | public void forEachInverseColorDodge(Allocation ain, Allocation aout) { | 
|  | 515 | blend(25, ain, aout); | 
|  | 516 | } | 
|  | 517 |  | 
|  | 518 | public void forEachSoftDodge(Allocation ain, Allocation aout) { | 
|  | 519 | blend(26, ain, aout); | 
|  | 520 | } | 
|  | 521 |  | 
|  | 522 | public void forEachColorBurn(Allocation ain, Allocation aout) { | 
|  | 523 | blend(27, ain, aout); | 
|  | 524 | } | 
|  | 525 |  | 
|  | 526 | public void forEachInverseColorBurn(Allocation ain, Allocation aout) { | 
|  | 527 | blend(28, ain, aout); | 
|  | 528 | } | 
|  | 529 |  | 
|  | 530 | public void forEachSoftBurn(Allocation ain, Allocation aout) { | 
|  | 531 | blend(29, ain, aout); | 
|  | 532 | } | 
|  | 533 |  | 
|  | 534 | public void forEachReflect(Allocation ain, Allocation aout) { | 
|  | 535 | blend(30, ain, aout); | 
|  | 536 | } | 
|  | 537 |  | 
|  | 538 | public void forEachGlow(Allocation ain, Allocation aout) { | 
|  | 539 | blend(31, ain, aout); | 
|  | 540 | } | 
|  | 541 |  | 
|  | 542 | public void forEachFreeze(Allocation ain, Allocation aout) { | 
|  | 543 | blend(32, ain, aout); | 
|  | 544 | } | 
|  | 545 |  | 
|  | 546 | public void forEachHeat(Allocation ain, Allocation aout) { | 
|  | 547 | blend(33, ain, aout); | 
|  | 548 | } | 
|  | 549 | */ | 
|  | 550 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 551 | * Sets dst = min(src + dst, 1.0) | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 552 | * | 
|  | 553 | * @param ain The source buffer | 
|  | 554 | * @param aout The destination buffer | 
|  | 555 | */ | 
|  | 556 | public void forEachAdd(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 557 | forEachAdd(ain, aout, null); | 
|  | 558 | } | 
|  | 559 |  | 
|  | 560 | /** | 
|  | 561 | * Sets dst = min(src + dst, 1.0) | 
|  | 562 | * | 
|  | 563 | * @param ain The source buffer | 
|  | 564 | * @param aout The destination buffer | 
|  | 565 | * @param opt LaunchOptions for clipping | 
|  | 566 | */ | 
|  | 567 | public void forEachAdd(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 568 | blend(34, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 569 | } | 
|  | 570 |  | 
|  | 571 | /** | 
|  | 572 | * Get a KernelID for the Add kernel. | 
|  | 573 | * | 
|  | 574 | * @return Script.KernelID The KernelID object. | 
|  | 575 | */ | 
|  | 576 | public Script.KernelID getKernelIDAdd() { | 
|  | 577 | return createKernelID(34, 3, null, null); | 
|  | 578 | } | 
|  | 579 |  | 
|  | 580 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 581 | * Sets dst = max(dst - src, 0.0) | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 582 | * | 
|  | 583 | * @param ain The source buffer | 
|  | 584 | * @param aout The destination buffer | 
|  | 585 | */ | 
|  | 586 | public void forEachSubtract(Allocation ain, Allocation aout) { | 
| Tim Murray | 6f842ac | 2014-01-13 11:47:53 -0800 | [diff] [blame] | 587 | forEachSubtract(ain, aout, null); | 
|  | 588 | } | 
|  | 589 |  | 
|  | 590 | /** | 
|  | 591 | * Sets dst = max(dst - src, 0.0) | 
|  | 592 | * | 
|  | 593 | * @param ain The source buffer | 
|  | 594 | * @param aout The destination buffer | 
|  | 595 | * @param opt LaunchOptions for clipping | 
|  | 596 | */ | 
|  | 597 | public void forEachSubtract(Allocation ain, Allocation aout, Script.LaunchOptions opt) { | 
|  | 598 | blend(35, ain, aout, opt); | 
| Jason Sams | f70bb04 | 2012-09-21 16:10:49 -0700 | [diff] [blame] | 599 | } | 
|  | 600 |  | 
|  | 601 | /** | 
|  | 602 | * Get a KernelID for the Subtract kernel. | 
|  | 603 | * | 
|  | 604 | * @return Script.KernelID The KernelID object. | 
|  | 605 | */ | 
|  | 606 | public Script.KernelID getKernelIDSubtract() { | 
|  | 607 | return createKernelID(35, 3, null, null); | 
|  | 608 | } | 
|  | 609 |  | 
|  | 610 | /* | 
|  | 611 | public void forEachStamp(Allocation ain, Allocation aout) { | 
|  | 612 | blend(36, ain, aout); | 
|  | 613 | } | 
|  | 614 |  | 
|  | 615 | public void forEachRed(Allocation ain, Allocation aout) { | 
|  | 616 | blend(37, ain, aout); | 
|  | 617 | } | 
|  | 618 |  | 
|  | 619 | public void forEachGreen(Allocation ain, Allocation aout) { | 
|  | 620 | blend(38, ain, aout); | 
|  | 621 | } | 
|  | 622 |  | 
|  | 623 | public void forEachBlue(Allocation ain, Allocation aout) { | 
|  | 624 | blend(39, ain, aout); | 
|  | 625 | } | 
|  | 626 |  | 
|  | 627 | public void forEachHue(Allocation ain, Allocation aout) { | 
|  | 628 | blend(40, ain, aout); | 
|  | 629 | } | 
|  | 630 |  | 
|  | 631 | public void forEachSaturation(Allocation ain, Allocation aout) { | 
|  | 632 | blend(41, ain, aout); | 
|  | 633 | } | 
|  | 634 |  | 
|  | 635 | public void forEachColor(Allocation ain, Allocation aout) { | 
|  | 636 | blend(42, ain, aout); | 
|  | 637 | } | 
|  | 638 |  | 
|  | 639 | public void forEachLuminosity(Allocation ain, Allocation aout) { | 
|  | 640 | blend(43, ain, aout); | 
|  | 641 | } | 
|  | 642 | */ | 
|  | 643 | } |