plane.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBCODECS_PLANE_H_
  5. #define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBCODECS_PLANE_H_
  6. #include <stdint.h>
  7. #include "base/memory/scoped_refptr.h"
  8. #include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h"
  9. #include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
  10. #include "third_party/blink/renderer/modules/modules_export.h"
  11. #include "third_party/blink/renderer/modules/webcodecs/video_frame_handle.h"
  12. #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
  13. namespace blink {
  14. class ExceptionState;
  15. class MODULES_EXPORT Plane final : public ScriptWrappable {
  16. DEFINE_WRAPPERTYPEINFO();
  17. public:
  18. // Construct a Plane given a |handle| and a plane index.
  19. // It is legal for |handle| to be invalid, the resulting Plane will also be
  20. // invalid.
  21. Plane(scoped_refptr<VideoFrameHandle> handle, size_t plane);
  22. ~Plane() override = default;
  23. // TODO(sandersd): Review return types. There is some implicit casting going
  24. // on here.
  25. // TODO(sandersd): Consider throwing if |handle_| is invalidated. Currently
  26. // everything returns 0, which is not a bad API either.
  27. uint32_t stride() const;
  28. uint32_t rows() const;
  29. uint32_t length() const;
  30. // Throws InvalidStateError if |handle_| has been invalidated.
  31. void readInto(MaybeShared<DOMArrayBufferView> dst, ExceptionState&);
  32. private:
  33. scoped_refptr<VideoFrameHandle> handle_;
  34. size_t plane_;
  35. };
  36. } // namespace blink
  37. #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBCODECS_PLANE_H_