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

Side by Side Diff: media/gpu/avda_picture_buffer_manager.h

Issue 2889603005: Position overlays in AVDACodecImage (Closed)
Patch Set: rebased Created 3 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ 5 #ifndef MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_
6 #define MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ 6 #define MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "media/gpu/avda_state_provider.h" 12 #include "media/gpu/avda_state_provider.h"
13 #include "media/gpu/avda_surface_bundle.h"
13 #include "media/gpu/media_gpu_export.h" 14 #include "media/gpu/media_gpu_export.h"
14 #include "media/gpu/surface_texture_gl_owner.h" 15 #include "media/gpu/surface_texture_gl_owner.h"
15 16
16 namespace gpu { 17 namespace gpu {
17 namespace gles2 { 18 namespace gles2 {
18 class GLStreamTextureImage; 19 class GLStreamTextureImage;
19 } 20 }
20 } 21 }
21 22
22 namespace gl {
23 class ScopedJavaSurface;
24 class SurfaceTexture;
25 }
26
27 namespace media { 23 namespace media {
28 class AVDACodecImage; 24 class AVDACodecImage;
29 class AVDASharedState; 25 class AVDASharedState;
30 class MediaCodecBridge; 26 class MediaCodecBridge;
31 27
32 // AVDAPictureBufferManager is used by AVDA to associate its PictureBuffers with 28 // AVDAPictureBufferManager is used by AVDA to associate its PictureBuffers with
33 // MediaCodec output buffers. It attaches AVDACodecImages to the PictureBuffer 29 // MediaCodec output buffers. It attaches AVDACodecImages to the PictureBuffer
34 // textures so that when they're used to draw the AVDACodecImage can release the 30 // textures so that when they're used to draw the AVDACodecImage can release the
35 // MediaCodec buffer to the backing Surface. If the Surface is a SurfaceTexture, 31 // MediaCodec buffer to the backing Surface. If the Surface is a SurfaceTexture,
36 // the front buffer can then be used to draw without needing to copy the pixels. 32 // the front buffer can then be used to draw without needing to copy the pixels.
37 // If the Surface is a SurfaceView, the release causes the frame to be displayed 33 // If the Surface is a SurfaceView, the release causes the frame to be displayed
38 // immediately. 34 // immediately.
39 class MEDIA_GPU_EXPORT AVDAPictureBufferManager { 35 class MEDIA_GPU_EXPORT AVDAPictureBufferManager {
40 public: 36 public:
41 using PictureBufferMap = std::map<int32_t, PictureBuffer>; 37 using PictureBufferMap = std::map<int32_t, PictureBuffer>;
42 38
43 explicit AVDAPictureBufferManager(AVDAStateProvider* state_provider); 39 explicit AVDAPictureBufferManager(AVDAStateProvider* state_provider);
44 virtual ~AVDAPictureBufferManager(); 40 virtual ~AVDAPictureBufferManager();
45 41
46 // Call either InitializeForOverlay or InitializeForSurfaceTexture before 42 // Call Initialize, providing the surface bundle that holds the surface that
47 // anything else. InitializeForOverlay will set us up to render codec buffers 43 // will back the frames. If an overlay is present in the bundle, then this
48 // at the approrpriate time for display, but will assume that consuming the 44 // will set us up to render codec buffers at the appropriate time for display,
49 // resulting buffers is handled elsewhere (e.g., SurfaceFlinger). 45 // but will assume that consuming the resulting buffers is handled elsewhere
46 // (e.g., SurfaceFlinger). We will ensure that any reference to the bundle
47 // is dropped if the overlay sends OnSurfaceDestroyed.
50 // 48 //
51 // InitializeForSurfaceTexture will create a SurfaceTexture and return the 49 // Without an overlay, we will create a SurfaceTexture and add it (and its
52 // surface for it. We will arrange to consume the buffers at the right time, 50 // surface) to |surface_bundle|. We will arrange to consume the buffers at
53 // in addition to releasing codec buffers for rendering. 51 // the right time, in addition to releasing the codec buffers for rendering.
54 // 52 //
55 // One may call these multiple times to change between overlay and ST. 53 // One may call these multiple times to change between overlay and ST.
56 // 54 //
57 // Picture buffers will be updated to reflect the new surface during the call 55 // Picture buffers will be updated to reflect the new surface during the call
58 // to UseCodecBufferForPicture(). 56 // to UseCodecBufferForPicture().
59 void InitializeForOverlay(); 57 //
60 gl::ScopedJavaSurface InitializeForSurfaceTexture(); 58 // Returns true on success, false otherwise.
watk 2017/05/17 19:45:14 nit: Reminds me of this from the styleguide :P Ho
liberato (no reviews please) 2017/05/17 20:19:32 done, though i'm not sure that i agree with the st
59 bool Initialize(scoped_refptr<AVDASurfaceBundle> surface_bundle);
61 60
62 void Destroy(const PictureBufferMap& buffers); 61 void Destroy(const PictureBufferMap& buffers);
63 62
64 // Sets up |picture_buffer| so that its texture will refer to the image that 63 // Sets up |picture_buffer| so that its texture will refer to the image that
65 // is represented by the decoded output buffer at codec_buffer_index. 64 // is represented by the decoded output buffer at codec_buffer_index.
66 void UseCodecBufferForPictureBuffer(int32_t codec_buffer_index, 65 void UseCodecBufferForPictureBuffer(int32_t codec_buffer_index,
67 const PictureBuffer& picture_buffer); 66 const PictureBuffer& picture_buffer);
68 67
69 // Assigns a picture buffer and attaches an image to its texture. 68 // Assigns a picture buffer and attaches an image to its texture.
70 void AssignOnePictureBuffer(const PictureBuffer& picture_buffer, 69 void AssignOnePictureBuffer(const PictureBuffer& picture_buffer,
(...skipping 12 matching lines...) Expand all
83 // MediaCodec is being destroyed. Previously provided codecs should no longer 82 // MediaCodec is being destroyed. Previously provided codecs should no longer
84 // be referenced. 83 // be referenced.
85 void CodecChanged(MediaCodecBridge* codec); 84 void CodecChanged(MediaCodecBridge* codec);
86 85
87 // Whether the pictures buffers are overlayable. 86 // Whether the pictures buffers are overlayable.
88 bool ArePicturesOverlayable(); 87 bool ArePicturesOverlayable();
89 88
90 // Are there any unrendered picture buffers oustanding? 89 // Are there any unrendered picture buffers oustanding?
91 bool HasUnrenderedPictures() const; 90 bool HasUnrenderedPictures() const;
92 91
93 scoped_refptr<gl::SurfaceTexture> surface_texture() {
94 return surface_texture_;
95 }
96
97 // Returns the GL texture target that the PictureBuffer textures use. 92 // Returns the GL texture target that the PictureBuffer textures use.
98 // Always use OES textures even though this will cause flickering in dev tools 93 // Always use OES textures even though this will cause flickering in dev tools
99 // when inspecting a fullscreen video. See http://crbug.com/592798 94 // when inspecting a fullscreen video. See http://crbug.com/592798
100 static constexpr GLenum kTextureTarget = GL_TEXTURE_EXTERNAL_OES; 95 static constexpr GLenum kTextureTarget = GL_TEXTURE_EXTERNAL_OES;
101 96
102 private: 97 private:
103 // Release any codec buffer that is associated with the given picture buffer 98 // Release any codec buffer that is associated with the given picture buffer
104 // back to the codec. It is okay if there is no such buffer. 99 // back to the codec. It is okay if there is no such buffer.
105 void ReleaseCodecBufferForPicture(const PictureBuffer& picture_buffer); 100 void ReleaseCodecBufferForPicture(const PictureBuffer& picture_buffer);
106 101
(...skipping 21 matching lines...) Expand all
128 123
129 // Maps a picture buffer id to a AVDACodecImage. 124 // Maps a picture buffer id to a AVDACodecImage.
130 std::map<int, scoped_refptr<AVDACodecImage>> codec_images_; 125 std::map<int, scoped_refptr<AVDACodecImage>> codec_images_;
131 126
132 DISALLOW_COPY_AND_ASSIGN(AVDAPictureBufferManager); 127 DISALLOW_COPY_AND_ASSIGN(AVDAPictureBufferManager);
133 }; 128 };
134 129
135 } // namespace media 130 } // namespace media
136 131
137 #endif // MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ 132 #endif // MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698