Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 class MEDIA_GPU_EXPORT AVDAPictureBufferManager { | 38 class MEDIA_GPU_EXPORT AVDAPictureBufferManager { |
| 39 public: | 39 public: |
| 40 using PictureBufferMap = std::map<int32_t, PictureBuffer>; | 40 using PictureBufferMap = std::map<int32_t, PictureBuffer>; |
| 41 | 41 |
| 42 explicit AVDAPictureBufferManager(AVDAStateProvider* state_provider); | 42 explicit AVDAPictureBufferManager(AVDAStateProvider* state_provider); |
| 43 virtual ~AVDAPictureBufferManager(); | 43 virtual ~AVDAPictureBufferManager(); |
| 44 | 44 |
| 45 // Must be called before anything else. If |surface_id| is |kNoSurfaceID| | 45 // Must be called before anything else. If |surface_id| is |kNoSurfaceID| |
| 46 // then a new SurfaceTexture will be returned. Otherwise, the corresponding | 46 // then a new SurfaceTexture will be returned. Otherwise, the corresponding |
| 47 // SurfaceView will be returned. | 47 // SurfaceView will be returned. |
| 48 // | |
| 49 // May be called multiple times to switch to a new |surface_id|. Picture | |
| 50 // buffers will be updated to use the new surface during the call to | |
| 51 // UseCodecBufferForPictureBuffer(). | |
| 48 gl::ScopedJavaSurface Initialize(int surface_id); | 52 gl::ScopedJavaSurface Initialize(int surface_id); |
| 49 | 53 |
| 50 void Destroy(const PictureBufferMap& buffers); | 54 void Destroy(const PictureBufferMap& buffers); |
| 51 | 55 |
| 52 // Returns the GL texture target that the PictureBuffer textures use. | |
| 53 uint32_t GetTextureTarget() const; | |
| 54 | |
| 55 // Returns the size to use when requesting picture buffers. | 56 // Returns the size to use when requesting picture buffers. |
| 56 gfx::Size GetPictureBufferSize() const; | 57 gfx::Size GetPictureBufferSize() const; |
| 57 | 58 |
| 58 // Sets up |picture_buffer| so that its texture will refer to the image that | 59 // Sets up |picture_buffer| so that its texture will refer to the image that |
| 59 // is represented by the decoded output buffer at codec_buffer_index. | 60 // is represented by the decoded output buffer at codec_buffer_index. |
| 60 void UseCodecBufferForPictureBuffer(int32_t codec_buffer_index, | 61 void UseCodecBufferForPictureBuffer(int32_t codec_buffer_index, |
| 61 const PictureBuffer& picture_buffer); | 62 const PictureBuffer& picture_buffer); |
| 62 | 63 |
| 63 // Assigns a picture buffer and attaches an image to its texture. | 64 // Assigns a picture buffer and attaches an image to its texture. |
| 64 void AssignOnePictureBuffer(const PictureBuffer& picture_buffer, | 65 void AssignOnePictureBuffer(const PictureBuffer& picture_buffer, |
| 65 bool have_context); | 66 bool have_context); |
| 66 | 67 |
| 67 // Reuses a picture buffer to hold a new frame. | 68 // Reuses a picture buffer to hold a new frame. |
| 68 void ReuseOnePictureBuffer(const PictureBuffer& picture_buffer); | 69 void ReuseOnePictureBuffer(const PictureBuffer& picture_buffer); |
| 69 | 70 |
| 70 // Release MediaCodec buffers. | 71 // Release MediaCodec buffers. |
| 71 void ReleaseCodecBuffers(const PictureBufferMap& buffers); | 72 void ReleaseCodecBuffers(const PictureBufferMap& buffers); |
| 72 | 73 |
| 73 // Attempts to free up codec output buffers by rendering early. | 74 // Attempts to free up codec output buffers by rendering early. |
| 74 void MaybeRenderEarly(); | 75 void MaybeRenderEarly(); |
| 75 | 76 |
| 76 // Called when the MediaCodec instance changes. If |codec| is nullptr the | 77 // Called when the MediaCodec instance changes. If |codec| is nullptr the |
| 77 // MediaCodec is being destroyed. Previously provided codecs should no longer | 78 // MediaCodec is being destroyed. Previously provided codecs should no longer |
| 78 // be referenced. | 79 // be referenced. |
| 79 void CodecChanged(VideoCodecBridge* codec); | 80 void CodecChanged(VideoCodecBridge* codec); |
| 80 | 81 |
| 81 // Whether the pictures buffers are overlayable. | 82 // Whether the pictures buffers are overlayable. |
| 82 bool ArePicturesOverlayable(); | 83 bool ArePicturesOverlayable(); |
| 83 | 84 |
| 85 // Are there any unrendered picture buffers oustanding? | |
| 86 bool ArePicturesOutstanding() const; | |
| 87 | |
| 88 // Returns the GL texture target that the PictureBuffer textures use. | |
| 89 // Always use OES textures even though this will cause flickering in dev tools | |
| 90 // when inspecting a fullscreen video. See http://crbug.com/592798 | |
| 91 enum GLenum { kTextureTarget = GL_TEXTURE_EXTERNAL_OES }; | |
|
watk
2016/11/08 22:59:03
constexpr instead of enum? Move to the top? If you
DaleCurtis
2016/11/08 23:50:11
Whoops, that was supposed to be the type. Dropped.
| |
| 92 | |
| 84 private: | 93 private: |
| 85 // Release any codec buffer that is associated with the given picture buffer | 94 // Release any codec buffer that is associated with the given picture buffer |
| 86 // back to the codec. It is okay if there is no such buffer. | 95 // back to the codec. It is okay if there is no such buffer. |
| 87 void ReleaseCodecBufferForPicture(const PictureBuffer& picture_buffer); | 96 void ReleaseCodecBufferForPicture(const PictureBuffer& picture_buffer); |
| 88 | 97 |
| 89 // Sets up the texture references (as found by |picture_buffer|), for the | 98 // Sets up the texture references (as found by |picture_buffer|), for the |
| 90 // specified |image|. If |image| is null, clears any ref on the texture | 99 // specified |image|. If |image| is null, clears any ref on the texture |
| 91 // associated with |picture_buffer|. | 100 // associated with |picture_buffer|. |
| 92 void SetImageForPicture(const PictureBuffer& picture_buffer, | 101 void SetImageForPicture(const PictureBuffer& picture_buffer, |
| 93 gpu::gles2::GLStreamTextureImage* image); | 102 gpu::gles2::GLStreamTextureImage* image); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 110 | 119 |
| 111 // Maps a picture buffer id to a AVDACodecImage. | 120 // Maps a picture buffer id to a AVDACodecImage. |
| 112 std::map<int, scoped_refptr<AVDACodecImage>> codec_images_; | 121 std::map<int, scoped_refptr<AVDACodecImage>> codec_images_; |
| 113 | 122 |
| 114 DISALLOW_COPY_AND_ASSIGN(AVDAPictureBufferManager); | 123 DISALLOW_COPY_AND_ASSIGN(AVDAPictureBufferManager); |
| 115 }; | 124 }; |
| 116 | 125 |
| 117 } // namespace media | 126 } // namespace media |
| 118 | 127 |
| 119 #endif // MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ | 128 #endif // MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ |
| OLD | NEW |