summaryrefslogtreecommitdiff
path: root/chromium/media/gpu/gles2_decoder_helper.h
blob: c3fe8d45dce087636d4b4e4819dd94c0a7b38fdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_GPU_GLES2_DECODER_HELPER_H_
#define MEDIA_GPU_GLES2_DECODER_HELPER_H_

#include <stdint.h>

#include <memory>

#include "base/memory/ref_counted.h"
#include "media/gpu/media_gpu_export.h"
#include "ui/gl/gl_bindings.h"

namespace gpu {
class DecoderContext;
struct Mailbox;
namespace gles2 {
class AbstractTexture;
}  // namespace gles2
}  // namespace gpu

namespace gl {
class GLContext;
}  // namespace gl

namespace media {

// Utility methods to simplify working with a gpu::DecoderContext from
// inside VDAs.
class MEDIA_GPU_EXPORT GLES2DecoderHelper {
 public:
  static std::unique_ptr<GLES2DecoderHelper> Create(
      gpu::DecoderContext* decoder);

  virtual ~GLES2DecoderHelper() {}

  // TODO(sandersd): Provide scoped version?
  virtual bool MakeContextCurrent() = 0;

  // Creates a texture and configures it as a video frame (linear filtering,
  // clamp to edge). The context must be current.  It is up to the caller to
  // ensure that the entire texture is initialized before providing it to the
  // renderer.  For th
  //
  // See glTexImage2D() for parameter definitions.
  //
  // Returns nullptr on failure, but there are currently no failure paths.
  virtual std::unique_ptr<gpu::gles2::AbstractTexture> CreateTexture(
      GLenum target,
      GLenum internal_format,
      GLsizei width,
      GLsizei height,
      GLenum format,
      GLenum type) = 0;

  // Gets the associated GLContext.
  virtual gl::GLContext* GetGLContext() = 0;

  // Creates a mailbox for a texture.
  virtual gpu::Mailbox CreateMailbox(
      gpu::gles2::AbstractTexture* texture_ref) = 0;
};

}  // namespace media

#endif  // MEDIA_GPU_GLES2_DECODER_HELPER_H_