BlendingState.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*global define*/
  2. define([
  3. '../Core/freezeObject',
  4. './BlendEquation',
  5. './BlendFunction'
  6. ], function(
  7. freezeObject,
  8. BlendEquation,
  9. BlendFunction) {
  10. "use strict";
  11. /**
  12. * The blending state combines {@link BlendEquation} and {@link BlendFunction} and the
  13. * <code>enabled</code> flag to define the full blending state for combining source and
  14. * destination fragments when rendering.
  15. * <p>
  16. * This is a helper when using custom render states with {@link Appearance#renderState}.
  17. * </p>
  18. *
  19. * @namespace
  20. * @alias BlendingState
  21. */
  22. var BlendingState = {
  23. /**
  24. * Blending is disabled.
  25. *
  26. * @type {Object}
  27. * @constant
  28. */
  29. DISABLED : freezeObject({
  30. enabled : false
  31. }),
  32. /**
  33. * Blending is enabled using alpha blending, <code>source(source.alpha) + destination(1 - source.alpha)</code>.
  34. *
  35. * @type {Object}
  36. * @constant
  37. */
  38. ALPHA_BLEND : freezeObject({
  39. enabled : true,
  40. equationRgb : BlendEquation.ADD,
  41. equationAlpha : BlendEquation.ADD,
  42. functionSourceRgb : BlendFunction.SOURCE_ALPHA,
  43. functionSourceAlpha : BlendFunction.SOURCE_ALPHA,
  44. functionDestinationRgb : BlendFunction.ONE_MINUS_SOURCE_ALPHA,
  45. functionDestinationAlpha : BlendFunction.ONE_MINUS_SOURCE_ALPHA
  46. }),
  47. /**
  48. * Blending is enabled using alpha blending with premultiplied alpha, <code>source + destination(1 - source.alpha)</code>.
  49. *
  50. * @type {Object}
  51. * @constant
  52. */
  53. PRE_MULTIPLIED_ALPHA_BLEND : freezeObject({
  54. enabled : true,
  55. equationRgb : BlendEquation.ADD,
  56. equationAlpha : BlendEquation.ADD,
  57. functionSourceRgb : BlendFunction.ONE,
  58. functionSourceAlpha : BlendFunction.ONE,
  59. functionDestinationRgb : BlendFunction.ONE_MINUS_SOURCE_ALPHA,
  60. functionDestinationAlpha : BlendFunction.ONE_MINUS_SOURCE_ALPHA
  61. }),
  62. /**
  63. * Blending is enabled using additive blending, <code>source(source.alpha) + destination</code>.
  64. *
  65. * @type {Object}
  66. * @constant
  67. */
  68. ADDITIVE_BLEND : freezeObject({
  69. enabled : true,
  70. equationRgb : BlendEquation.ADD,
  71. equationAlpha : BlendEquation.ADD,
  72. functionSourceRgb : BlendFunction.SOURCE_ALPHA,
  73. functionSourceAlpha : BlendFunction.SOURCE_ALPHA,
  74. functionDestinationRgb : BlendFunction.ONE,
  75. functionDestinationAlpha : BlendFunction.ONE
  76. })
  77. };
  78. return freezeObject(BlendingState);
  79. });