webgl.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const {Arg, Option, RetVal, generateActorSpec} = require("devtools/shared/protocol");
  6. const shaderSpec = generateActorSpec({
  7. typeName: "gl-shader",
  8. methods: {
  9. getText: {
  10. response: { text: RetVal("string") }
  11. },
  12. compile: {
  13. request: { text: Arg(0, "string") },
  14. response: { error: RetVal("nullable:json") }
  15. },
  16. },
  17. });
  18. exports.shaderSpec = shaderSpec;
  19. const programSpec = generateActorSpec({
  20. typeName: "gl-program",
  21. methods: {
  22. getVertexShader: {
  23. response: { shader: RetVal("gl-shader") }
  24. },
  25. getFragmentShader: {
  26. response: { shader: RetVal("gl-shader") }
  27. },
  28. highlight: {
  29. request: { tint: Arg(0, "array:number") },
  30. oneway: true
  31. },
  32. unhighlight: {
  33. oneway: true
  34. },
  35. blackbox: {
  36. oneway: true
  37. },
  38. unblackbox: {
  39. oneway: true
  40. },
  41. }
  42. });
  43. exports.programSpec = programSpec;
  44. const webGLSpec = generateActorSpec({
  45. typeName: "webgl",
  46. /**
  47. * Events emitted by this actor. The "program-linked" event is fired every
  48. * time a WebGL program was linked with its respective two shaders.
  49. */
  50. events: {
  51. "program-linked": {
  52. type: "programLinked",
  53. program: Arg(0, "gl-program")
  54. },
  55. "global-destroyed": {
  56. type: "globalDestroyed",
  57. program: Arg(0, "number")
  58. },
  59. "global-created": {
  60. type: "globalCreated",
  61. program: Arg(0, "number")
  62. }
  63. },
  64. methods: {
  65. setup: {
  66. request: { reload: Option(0, "boolean") },
  67. oneway: true
  68. },
  69. finalize: {
  70. oneway: true
  71. },
  72. getPrograms: {
  73. response: { programs: RetVal("array:gl-program") }
  74. },
  75. waitForFrame: {
  76. response: { success: RetVal("nullable:json") }
  77. },
  78. getPixel: {
  79. request: {
  80. selector: Option(0, "string"),
  81. position: Option(0, "json")
  82. },
  83. response: { pixels: RetVal("json") }
  84. },
  85. _getAllPrograms: {
  86. response: { programs: RetVal("array:gl-program") }
  87. }
  88. }
  89. });
  90. exports.webGLSpec = webGLSpec;