gles2_decoder_helper.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2017 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 MEDIA_GPU_GLES2_DECODER_HELPER_H_
  5. #define MEDIA_GPU_GLES2_DECODER_HELPER_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include "base/memory/ref_counted.h"
  9. #include "media/gpu/media_gpu_export.h"
  10. #include "ui/gl/gl_bindings.h"
  11. namespace gpu {
  12. class DecoderContext;
  13. struct Mailbox;
  14. namespace gles2 {
  15. class AbstractTexture;
  16. } // namespace gles2
  17. } // namespace gpu
  18. namespace gl {
  19. class GLContext;
  20. } // namespace gl
  21. namespace media {
  22. // Utility methods to simplify working with a gpu::DecoderContext from
  23. // inside VDAs.
  24. class MEDIA_GPU_EXPORT GLES2DecoderHelper {
  25. public:
  26. static std::unique_ptr<GLES2DecoderHelper> Create(
  27. gpu::DecoderContext* decoder);
  28. virtual ~GLES2DecoderHelper() {}
  29. // TODO(sandersd): Provide scoped version?
  30. virtual bool MakeContextCurrent() = 0;
  31. // Creates a texture and configures it as a video frame (linear filtering,
  32. // clamp to edge). The context must be current. It is up to the caller to
  33. // ensure that the entire texture is initialized before providing it to the
  34. // renderer. For th
  35. //
  36. // See glTexImage2D() for parameter definitions.
  37. //
  38. // Returns nullptr on failure, but there are currently no failure paths.
  39. virtual std::unique_ptr<gpu::gles2::AbstractTexture> CreateTexture(
  40. GLenum target,
  41. GLenum internal_format,
  42. GLsizei width,
  43. GLsizei height,
  44. GLenum format,
  45. GLenum type) = 0;
  46. // Gets the associated GLContext.
  47. virtual gl::GLContext* GetGLContext() = 0;
  48. // Creates a mailbox for a texture.
  49. virtual gpu::Mailbox CreateMailbox(
  50. gpu::gles2::AbstractTexture* texture_ref) = 0;
  51. // Produce a texture into a mailbox.
  52. virtual void ProduceTexture(const gpu::Mailbox& mailbox,
  53. gpu::gles2::AbstractTexture* texture_ref) = 0;
  54. };
  55. } // namespace media
  56. #endif // MEDIA_GPU_GLES2_DECODER_HELPER_H_