Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: content/common/gpu/media/android_deferred_rendering_backing_strategy.h

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Squash and rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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
5 #ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_DEFERRED_RENDERING_BACKING_STRATEGY_H_
6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_DEFERRED_RENDERING_BACKING_STRATEGY_H_
7
8 #include <stdint.h>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "content/common/content_export.h"
13 #include "content/common/gpu/media/android_video_decode_accelerator.h"
14
15 namespace gl {
16 class GLImage;
17 }
18
19 namespace gpu {
20 namespace gles2 {
21 class GLStreamTextureImage;
22 class TextureRef;
23 }
24 }
25
26 namespace content {
27
28 class AVDACodecImage;
29 class AVDASharedState;
30
31 // A BackingStrategy implementation that defers releasing codec buffers until
32 // a PictureBuffer's texture is used to draw, then draws using the surface
33 // texture's front buffer rather than a copy. To do this, it uses a GLImage
34 // implementation to talk to MediaCodec.
35 class CONTENT_EXPORT AndroidDeferredRenderingBackingStrategy
36 : public AndroidVideoDecodeAccelerator::BackingStrategy {
37 public:
38 explicit AndroidDeferredRenderingBackingStrategy(
39 AVDAStateProvider* state_provider);
40 ~AndroidDeferredRenderingBackingStrategy() override;
41
42 // AndroidVideoDecodeAccelerator::BackingStrategy
43 gfx::ScopedJavaSurface Initialize(int surface_view_id) override;
44 void Cleanup(
45 bool have_context,
46 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) override;
47 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture() const override;
48 uint32_t GetTextureTarget() const override;
49 gfx::Size GetPictureBufferSize() const override;
50 void UseCodecBufferForPictureBuffer(
51 int32_t codec_buffer_index,
52 const media::PictureBuffer& picture_buffer) override;
53 void AssignOnePictureBuffer(const media::PictureBuffer&, bool) override;
54 void ReuseOnePictureBuffer(
55 const media::PictureBuffer& picture_buffer) override;
56 void MaybeRenderEarly() override;
57 void CodecChanged(media::VideoCodecBridge* codec) override;
58 void ReleaseCodecBuffers(
59 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) override;
60 void OnFrameAvailable() override;
61 bool ArePicturesOverlayable() override;
62 void UpdatePictureBufferSize(media::PictureBuffer* picture_buffer,
63 const gfx::Size& new_size) override;
64
65 private:
66 // Release any codec buffer that is associated with the given picture buffer
67 // back to the codec. It is okay if there is no such buffer.
68 void ReleaseCodecBufferForPicture(const media::PictureBuffer& picture_buffer);
69
70 // Sets up the texture references (as found by |picture_buffer|), for the
71 // specified |image|. If |image| is null, clears any ref on the texture
72 // associated with |picture_buffer|.
73 void SetImageForPicture(
74 const media::PictureBuffer& picture_buffer,
75 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image);
76
77 // Make a copy of the SurfaceTexture's front buffer and associate all given
78 // picture buffer textures with it. The picture buffer textures will not
79 // dependend on |this|, the SurfaceTexture, the MediaCodec or the VDA, so it's
80 // used to back the picture buffers when the VDA is being destroyed.
81 void CopySurfaceTextureToPictures(
82 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers);
83
84 // Return true if and only if the surface_texture_cant_detach workaround is
85 // not set.
86 bool DoesSurfaceTextureDetachWork() const;
87
88 // Return true if and only if CopySurfaceTextureToPictures is expected to work
89 // on this device.
90 bool ShouldCopyPictures() const;
91
92 scoped_refptr<AVDASharedState> shared_state_;
93
94 AVDAStateProvider* state_provider_;
95
96 // The SurfaceTexture to render to. Non-null after Initialize() if
97 // we're not rendering to a SurfaceView.
98 scoped_refptr<gfx::SurfaceTexture> surface_texture_;
99
100 media::VideoCodecBridge* media_codec_;
101
102 // Picture buffer IDs that are out for display. Stored in order of frames as
103 // they are returned from the decoder.
104 std::vector<int32_t> pictures_out_for_display_;
105
106 DISALLOW_COPY_AND_ASSIGN(AndroidDeferredRenderingBackingStrategy);
107 };
108
109 } // namespace content
110
111 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_DEFERRED_RENDERING_BACKING_STRATEGY_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698