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