| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.renderscript; |
| 18 |
|
| 19 |
import android.compat.annotation.UnsupportedAppUsage; |
| 20 |
import android.os.Build; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@Deprecated |
| 42 |
public class ProgramStore extends BaseObj { |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public enum DepthFunc { |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
@UnsupportedAppUsage |
| 56 |
ALWAYS (0), |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
@UnsupportedAppUsage |
| 62 |
LESS (1), |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
LESS_OR_EQUAL (2), |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
GREATER (3), |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
GREATER_OR_EQUAL (4), |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
EQUAL (5), |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
NOT_EQUAL (6); |
| 88 |
|
| 89 |
int mID; |
| 90 |
DepthFunc(int id) { |
| 91 |
mID = id; |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
public enum BlendSrcFunc { |
| 104 |
ZERO (0), |
| 105 |
@UnsupportedAppUsage |
| 106 |
ONE (1), |
| 107 |
DST_COLOR (2), |
| 108 |
ONE_MINUS_DST_COLOR (3), |
| 109 |
@UnsupportedAppUsage |
| 110 |
SRC_ALPHA (4), |
| 111 |
ONE_MINUS_SRC_ALPHA (5), |
| 112 |
DST_ALPHA (6), |
| 113 |
ONE_MINUS_DST_ALPHA (7), |
| 114 |
SRC_ALPHA_SATURATE (8); |
| 115 |
|
| 116 |
int mID; |
| 117 |
BlendSrcFunc(int id) { |
| 118 |
mID = id; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
public enum BlendDstFunc { |
| 132 |
@UnsupportedAppUsage |
| 133 |
ZERO (0), |
| 134 |
@UnsupportedAppUsage |
| 135 |
ONE (1), |
| 136 |
SRC_COLOR (2), |
| 137 |
ONE_MINUS_SRC_COLOR (3), |
| 138 |
SRC_ALPHA (4), |
| 139 |
@UnsupportedAppUsage |
| 140 |
ONE_MINUS_SRC_ALPHA (5), |
| 141 |
DST_ALPHA (6), |
| 142 |
ONE_MINUS_DST_ALPHA (7); |
| 143 |
|
| 144 |
int mID; |
| 145 |
BlendDstFunc(int id) { |
| 146 |
mID = id; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
DepthFunc mDepthFunc; |
| 151 |
boolean mDepthMask; |
| 152 |
boolean mColorMaskR; |
| 153 |
boolean mColorMaskG; |
| 154 |
boolean mColorMaskB; |
| 155 |
boolean mColorMaskA; |
| 156 |
BlendSrcFunc mBlendSrc; |
| 157 |
BlendDstFunc mBlendDst; |
| 158 |
boolean mDither; |
| 159 |
|
| 160 |
ProgramStore(long id, RenderScript rs) { |
| 161 |
super(id, rs); |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
public DepthFunc getDepthFunc() { |
| 170 |
return mDepthFunc; |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
public boolean isDepthMaskEnabled() { |
| 178 |
return mDepthMask; |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
public boolean isColorMaskRedEnabled() { |
| 186 |
return mColorMaskR; |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
public boolean isColorMaskGreenEnabled() { |
| 194 |
return mColorMaskG; |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
public boolean isColorMaskBlueEnabled() { |
| 202 |
return mColorMaskB; |
| 203 |
} |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
public boolean isColorMaskAlphaEnabled() { |
| 210 |
return mColorMaskA; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
public BlendSrcFunc getBlendSrcFunc() { |
| 218 |
return mBlendSrc; |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
public BlendDstFunc getBlendDstFunc() { |
| 226 |
return mBlendDst; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
public boolean isDitherEnabled() { |
| 235 |
return mDither; |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
public static ProgramStore BLEND_NONE_DEPTH_TEST(RenderScript rs) { |
| 250 |
if(rs.mProgramStore_BLEND_NONE_DEPTH_TEST == null) { |
| 251 |
ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 252 |
builder.setDepthFunc(ProgramStore.DepthFunc.LESS); |
| 253 |
builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO); |
| 254 |
builder.setDitherEnabled(false); |
| 255 |
builder.setDepthMaskEnabled(true); |
| 256 |
rs.mProgramStore_BLEND_NONE_DEPTH_TEST = builder.create(); |
| 257 |
} |
| 258 |
return rs.mProgramStore_BLEND_NONE_DEPTH_TEST; |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
public static ProgramStore BLEND_NONE_DEPTH_NONE(RenderScript rs) { |
| 271 |
if(rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH == null) { |
| 272 |
ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 273 |
builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
| 274 |
builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO); |
| 275 |
builder.setDitherEnabled(false); |
| 276 |
builder.setDepthMaskEnabled(false); |
| 277 |
rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH = builder.create(); |
| 278 |
} |
| 279 |
return rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH; |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
public static ProgramStore BLEND_ALPHA_DEPTH_TEST(RenderScript rs) { |
| 295 |
if(rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST == null) { |
| 296 |
ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 297 |
builder.setDepthFunc(ProgramStore.DepthFunc.LESS); |
| 298 |
builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 299 |
builder.setDitherEnabled(false); |
| 300 |
builder.setDepthMaskEnabled(true); |
| 301 |
rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST = builder.create(); |
| 302 |
} |
| 303 |
return rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST; |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 317 |
public static ProgramStore BLEND_ALPHA_DEPTH_NONE(RenderScript rs) { |
| 318 |
if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH == null) { |
| 319 |
ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 320 |
builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
| 321 |
builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 322 |
builder.setDitherEnabled(false); |
| 323 |
builder.setDepthMaskEnabled(false); |
| 324 |
rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH = builder.create(); |
| 325 |
} |
| 326 |
return rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH; |
| 327 |
} |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
public static class Builder { |
| 335 |
RenderScript mRS; |
| 336 |
DepthFunc mDepthFunc; |
| 337 |
boolean mDepthMask; |
| 338 |
boolean mColorMaskR; |
| 339 |
boolean mColorMaskG; |
| 340 |
boolean mColorMaskB; |
| 341 |
boolean mColorMaskA; |
| 342 |
BlendSrcFunc mBlendSrc; |
| 343 |
BlendDstFunc mBlendDst; |
| 344 |
boolean mDither; |
| 345 |
|
| 346 |
@UnsupportedAppUsage |
| 347 |
public Builder(RenderScript rs) { |
| 348 |
mRS = rs; |
| 349 |
mDepthFunc = DepthFunc.ALWAYS; |
| 350 |
mDepthMask = false; |
| 351 |
mColorMaskR = true; |
| 352 |
mColorMaskG = true; |
| 353 |
mColorMaskB = true; |
| 354 |
mColorMaskA = true; |
| 355 |
mBlendSrc = BlendSrcFunc.ONE; |
| 356 |
mBlendDst = BlendDstFunc.ZERO; |
| 357 |
} |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
@UnsupportedAppUsage |
| 367 |
public Builder setDepthFunc(DepthFunc func) { |
| 368 |
mDepthFunc = func; |
| 369 |
return this; |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
@UnsupportedAppUsage |
| 381 |
public Builder setDepthMaskEnabled(boolean enable) { |
| 382 |
mDepthMask = enable; |
| 383 |
return this; |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
public Builder setColorMaskEnabled(boolean r, boolean g, boolean b, boolean a) { |
| 397 |
mColorMaskR = r; |
| 398 |
mColorMaskG = g; |
| 399 |
mColorMaskB = b; |
| 400 |
mColorMaskA = a; |
| 401 |
return this; |
| 402 |
} |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
@UnsupportedAppUsage |
| 416 |
public Builder setBlendFunc(BlendSrcFunc src, BlendDstFunc dst) { |
| 417 |
mBlendSrc = src; |
| 418 |
mBlendDst = dst; |
| 419 |
return this; |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
@UnsupportedAppUsage |
| 431 |
public Builder setDitherEnabled(boolean enable) { |
| 432 |
mDither = enable; |
| 433 |
return this; |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
@UnsupportedAppUsage |
| 440 |
public ProgramStore create() { |
| 441 |
mRS.validate(); |
| 442 |
long id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA, |
| 443 |
mDepthMask, mDither, |
| 444 |
mBlendSrc.mID, mBlendDst.mID, mDepthFunc.mID); |
| 445 |
ProgramStore programStore = new ProgramStore(id, mRS); |
| 446 |
programStore.mDepthFunc = mDepthFunc; |
| 447 |
programStore.mDepthMask = mDepthMask; |
| 448 |
programStore.mColorMaskR = mColorMaskR; |
| 449 |
programStore.mColorMaskG = mColorMaskG; |
| 450 |
programStore.mColorMaskB = mColorMaskB; |
| 451 |
programStore.mColorMaskA = mColorMaskA; |
| 452 |
programStore.mBlendSrc = mBlendSrc; |
| 453 |
programStore.mBlendDst = mBlendDst; |
| 454 |
programStore.mDither = mDither; |
| 455 |
return programStore; |
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
} |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|