summaryrefslogtreecommitdiff
path: root/chromium/content/common/gpu/media/android_copying_backing_strategy.h
blob: 8980404dfdb48283fb300311065516ab4f25eed6 (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 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_COPYING_BACKING_STRATEGY_H_
#define CONTENT_COMMON_GPU_MEDIA_ANDROID_COPYING_BACKING_STRATEGY_H_

#include <stdint.h>

#include "base/compiler_specific.h"
#include "content/common/content_export.h"
#include "content/common/gpu/media/android_video_decode_accelerator.h"

namespace gpu {
class CopyTextureCHROMIUMResourceManager;
}

namespace media {
class PictureBuffer;
}

namespace content {

class AVDAStateProvider;

// A BackingStrategy implementation that copies images to PictureBuffer
// textures via gpu texture copy.
class CONTENT_EXPORT AndroidCopyingBackingStrategy
    : public AndroidVideoDecodeAccelerator::BackingStrategy {
 public:
  explicit AndroidCopyingBackingStrategy(AVDAStateProvider* state_provider);
  ~AndroidCopyingBackingStrategy() override;

  // AndroidVideoDecodeAccelerator::BackingStrategy
  gfx::ScopedJavaSurface Initialize(int surface_view_id) override;
  void Cleanup(bool have_context,
               const AndroidVideoDecodeAccelerator::OutputBufferMap&) override;
  scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture() const override;
  uint32_t GetTextureTarget() const override;
  gfx::Size GetPictureBufferSize() const override;
  void UseCodecBufferForPictureBuffer(int32_t codec_buffer_index,
                                      const media::PictureBuffer&) override;
  void CodecChanged(
      media::VideoCodecBridge*,
      const AndroidVideoDecodeAccelerator::OutputBufferMap&) override;
  void OnFrameAvailable() override;
  bool ArePicturesOverlayable() override;
  void UpdatePictureBufferSize(media::PictureBuffer* picture_buffer,
                               const gfx::Size& new_size) override;

 private:
  // Used for copy the texture from surface texture to picture buffers.
  scoped_ptr<gpu::CopyTextureCHROMIUMResourceManager> copier_;

  AVDAStateProvider* state_provider_;

  // A container of texture. Used to set a texture to |media_codec_|.
  scoped_refptr<gfx::SurfaceTexture> surface_texture_;

  // The texture id which is set to |surface_texture_|.
  uint32_t surface_texture_id_;

  media::VideoCodecBridge* media_codec_;
};

}  // namespace content

#endif  // CONTENT_COMMON_GPU_MEDIA_ANDROID_COPYING_BACKING_STRATEGY_H_