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

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: Fix several more bot-identified build issues Created 4 years, 8 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
10 #include "base/macros.h"
11 #include "content/common/content_export.h"
12 #include "content/common/gpu/media/android_video_decode_accelerator.h"
13
14 namespace gl {
15 class GLImage;
16 }
17
18 namespace gpu {
19 namespace gles2 {
20 class GLStreamTextureImage;
21 class TextureRef;
22 }
23 }
24
25 namespace content {
26
27 class AVDACodecImage;
28 class AVDASharedState;
29
30 // A BackingStrategy implementation that defers releasing codec buffers until
31 // a PictureBuffer's texture is used to draw, then draws using the surface
32 // texture's front buffer rather than a copy. To do this, it uses a GLImage
33 // implementation to talk to MediaCodec.
34 class CONTENT_EXPORT AndroidDeferredRenderingBackingStrategy
35 : public AndroidVideoDecodeAccelerator::BackingStrategy {
36 public:
37 explicit AndroidDeferredRenderingBackingStrategy(
38 AVDAStateProvider* state_provider);
39 ~AndroidDeferredRenderingBackingStrategy() override;
40
41 // AndroidVideoDecodeAccelerator::BackingStrategy
42 gfx::ScopedJavaSurface Initialize(int surface_view_id) override;
43 void Cleanup(bool have_context,
44 const AndroidVideoDecodeAccelerator::OutputBufferMap&) override;
45 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture() const override;
46 uint32_t GetTextureTarget() const override;
47 gfx::Size GetPictureBufferSize() const override;
48 void UseCodecBufferForPictureBuffer(int32_t codec_buffer_index,
49 const media::PictureBuffer&) override;
50 void AssignOnePictureBuffer(const media::PictureBuffer&, bool) override;
51 void ReuseOnePictureBuffer(const media::PictureBuffer&) override;
52 void CodecChanged(
53 media::VideoCodecBridge*,
54 const AndroidVideoDecodeAccelerator::OutputBufferMap&) override;
55 void OnFrameAvailable() override;
56 bool ArePicturesOverlayable() override;
57 void UpdatePictureBufferSize(media::PictureBuffer* picture_buffer,
58 const gfx::Size& new_size) override;
59
60 private:
61 // Release any codec buffer that is associated with the given picture buffer
62 // back to the codec. It is okay if there is no such buffer.
63 void ReleaseCodecBufferForPicture(const media::PictureBuffer& picture_buffer);
64
65 // Return the AVDACodecImage for a given PictureBuffer's texture.
66 AVDACodecImage* GetImageForPicture(const media::PictureBuffer&);
67 void SetImageForPicture(
68 const media::PictureBuffer& picture_buffer,
69 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image);
70
71 // Make a copy of the SurfaceTexture's front buffer and associate all given
72 // picture buffer textures with it. The picture buffer textures will not
73 // dependend on |this|, the SurfaceTexture, the MediaCodec or the VDA, so it's
74 // used to back the picture buffers when the VDA is being destroyed.
75 void CopySurfaceTextureToPictures(
76 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers);
77
78 // Return true if and only if the surface_texture_cant_detach workaround is
79 // not set.
80 bool DoesSurfaceTextureDetachWork() const;
81
82 // Return true if and only if CopySurfaceTextureToPictures is expected to work
83 // on this device.
84 bool ShouldCopyPictures() const;
85
86 scoped_refptr<AVDASharedState> shared_state_;
87
88 AVDAStateProvider* state_provider_;
89
90 // The SurfaceTexture to render to. Non-null after Initialize() if
91 // we're not rendering to a SurfaceView.
92 scoped_refptr<gfx::SurfaceTexture> surface_texture_;
93
94 media::VideoCodecBridge* media_codec_;
95
96 DISALLOW_COPY_AND_ASSIGN(AndroidDeferredRenderingBackingStrategy);
97 };
98
99 } // namespace content
100
101 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_DEFERRED_RENDERING_BACKING_STRATEGY_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698