WebGLUniformLocation.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef WEBGL_UNIFORM_LOCATION_H_
  6. #define WEBGL_UNIFORM_LOCATION_H_
  7. #include "GLDefs.h"
  8. #include "mozilla/WeakPtr.h"
  9. #include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS
  10. #include "nsISupportsImpl.h" // NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING
  11. #include "nsWrapperCache.h"
  12. #include "WebGLObjectModel.h"
  13. struct JSContext;
  14. namespace mozilla {
  15. class WebGLActiveInfo;
  16. class WebGLContext;
  17. class WebGLProgram;
  18. namespace webgl {
  19. struct LinkedProgramInfo;
  20. struct UniformInfo;
  21. } // namespace webgl
  22. class WebGLUniformLocation final
  23. : public nsWrapperCache
  24. , public WebGLContextBoundObject
  25. {
  26. public:
  27. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLUniformLocation)
  28. NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLUniformLocation)
  29. virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
  30. WebGLContext* GetParentObject() const {
  31. return mContext;
  32. }
  33. //////
  34. const WeakPtr<const webgl::LinkedProgramInfo> mLinkInfo;
  35. webgl::UniformInfo* const mInfo;
  36. const GLuint mLoc;
  37. const size_t mArrayIndex;
  38. //////
  39. WebGLUniformLocation(WebGLContext* webgl, const webgl::LinkedProgramInfo* linkInfo,
  40. webgl::UniformInfo* info, GLuint loc, size_t arrayIndex);
  41. bool ValidateForProgram(const WebGLProgram* prog, const char* funcName) const;
  42. bool ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType,
  43. const char* funcName) const;
  44. bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize,
  45. const char* funcName) const;
  46. JS::Value GetUniform(JSContext* js) const;
  47. // Needed for certain helper functions like ValidateObject.
  48. // `WebGLUniformLocation`s can't be 'Deleted' in the WebGL sense.
  49. bool IsDeleted() const { return false; }
  50. protected:
  51. ~WebGLUniformLocation();
  52. };
  53. } // namespace mozilla
  54. #endif // WEBGL_UNIFORM_LOCATION_H_