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 CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "content/common/gpu/media/avda_shared_state.h" | 13 #include "content/common/gpu/media/avda_shared_state.h" |
14 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 14 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 class ScopedMakeCurrent; | 17 class ScopedMakeCurrent; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 // GLImage that renders MediaCodec buffers to a SurfaceTexture or SurfaceView as | 22 // GLImage that renders MediaCodec buffers to a SurfaceTexture or SurfaceView as |
23 // needed in order to draw them. | 23 // needed in order to draw them. |
24 class AVDACodecImage : public gpu::gles2::GLStreamTextureImage { | 24 class AVDACodecImage : public gpu::gles2::GLStreamTextureImage { |
25 public: | 25 public: |
26 AVDACodecImage(const scoped_refptr<AVDASharedState>&, | 26 AVDACodecImage(int picture_buffer_id, |
| 27 const scoped_refptr<AVDASharedState>& shared_state, |
27 media::VideoCodecBridge* codec, | 28 media::VideoCodecBridge* codec, |
28 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, | 29 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, |
29 const scoped_refptr<gfx::SurfaceTexture>& surface_texture); | 30 const scoped_refptr<gfx::SurfaceTexture>& surface_texture); |
30 | 31 |
31 protected: | |
32 ~AVDACodecImage() override; | |
33 | |
34 public: | |
35 // gl::GLImage implementation | 32 // gl::GLImage implementation |
36 void Destroy(bool have_context) override; | 33 void Destroy(bool have_context) override; |
37 gfx::Size GetSize() override; | 34 gfx::Size GetSize() override; |
38 unsigned GetInternalFormat() override; | 35 unsigned GetInternalFormat() override; |
39 bool BindTexImage(unsigned target) override; | 36 bool BindTexImage(unsigned target) override; |
40 void ReleaseTexImage(unsigned target) override; | 37 void ReleaseTexImage(unsigned target) override; |
41 bool CopyTexImage(unsigned target) override; | 38 bool CopyTexImage(unsigned target) override; |
42 bool CopyTexSubImage(unsigned target, | 39 bool CopyTexSubImage(unsigned target, |
43 const gfx::Point& offset, | 40 const gfx::Point& offset, |
44 const gfx::Rect& rect) override; | 41 const gfx::Rect& rect) override; |
45 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 42 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
46 int z_order, | 43 int z_order, |
47 gfx::OverlayTransform transform, | 44 gfx::OverlayTransform transform, |
48 const gfx::Rect& bounds_rect, | 45 const gfx::Rect& bounds_rect, |
49 const gfx::RectF& crop_rect) override; | 46 const gfx::RectF& crop_rect) override; |
50 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 47 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
51 uint64_t process_tracing_id, | 48 uint64_t process_tracing_id, |
52 const std::string& dump_name) override; | 49 const std::string& dump_name) override; |
53 // gpu::gles2::GLStreamTextureMatrix implementation | 50 // gpu::gles2::GLStreamTextureMatrix implementation |
54 void GetTextureMatrix(float xform[16]) override; | 51 void GetTextureMatrix(float xform[16]) override; |
55 | 52 |
56 public: | |
57 // Decoded buffer index that has the image for us to display. | 53 // Decoded buffer index that has the image for us to display. |
58 void SetMediaCodecBufferIndex(int buffer_index); | 54 void SetMediaCodecBufferIndex(int buffer_index); |
59 | 55 |
60 // Return the codec buffer that we will return to the codec, or | 56 // Return the codec buffer that we will return to the codec, or |
61 // <0 if there is no such buffer. | 57 // <0 if there is no such buffer. |
62 int GetMediaCodecBufferIndex() const; | 58 int GetMediaCodecBufferIndex() const; |
63 | 59 |
64 // Set the size of the current image. | 60 // Set the size of the current image. |
65 void SetSize(const gfx::Size& size); | 61 void SetSize(const gfx::Size& size); |
66 | 62 |
67 void SetMediaCodec(media::MediaCodecBridge* codec); | 63 // Updates the MediaCodec for this image; clears |codec_buffer_index_|. |
| 64 void CodecChanged(media::MediaCodecBridge* codec); |
68 | 65 |
69 void SetTexture(gpu::gles2::Texture* texture); | 66 void SetTexture(gpu::gles2::Texture* texture); |
70 | 67 |
| 68 protected: |
| 69 ~AVDACodecImage() override; |
| 70 |
71 private: | 71 private: |
72 enum { kInvalidCodecBufferIndex = -1 }; | 72 enum { kInvalidCodecBufferIndex = -1 }; |
73 | 73 |
74 // Make sure that the surface texture's front buffer is current. This will | 74 // Make sure that the surface texture's front buffer is current. This will |
75 // save / restore the current context. It will optionally restore the texture | 75 // save / restore the current context. It will optionally restore the texture |
76 // bindings in the surface texture's context, based on |mode|. This is | 76 // bindings in the surface texture's context, based on |mode|. This is |
77 // intended as a hint if we don't need to change contexts. If we do need to | 77 // intended as a hint if we don't need to change contexts. If we do need to |
78 // change contexts, then we'll always preserve the texture bindings in the | 78 // change contexts, then we'll always preserve the texture bindings in the |
79 // both contexts. In other words, the caller is telling us whether it's | 79 // both contexts. In other words, the caller is telling us whether it's |
80 // okay to change the binding in the current context. | 80 // okay to change the binding in the current context. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Should we detach |surface_texture_| from its GL context when we are | 119 // Should we detach |surface_texture_| from its GL context when we are |
120 // deleted? This happens when it's using our Texture's texture handle. | 120 // deleted? This happens when it's using our Texture's texture handle. |
121 bool detach_surface_texture_on_destruction_; | 121 bool detach_surface_texture_on_destruction_; |
122 | 122 |
123 // The texture that we're attached to. | 123 // The texture that we're attached to. |
124 gpu::gles2::Texture* texture_; | 124 gpu::gles2::Texture* texture_; |
125 | 125 |
126 // Texture matrix of the front buffer of the surface texture. | 126 // Texture matrix of the front buffer of the surface texture. |
127 float gl_matrix_[16]; | 127 float gl_matrix_[16]; |
128 | 128 |
| 129 // The picture buffer id attached to this image. |
| 130 int picture_buffer_id_; |
| 131 |
129 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); | 132 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); |
130 }; | 133 }; |
131 | 134 |
132 } // namespace content | 135 } // namespace content |
133 | 136 |
134 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ | 137 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ |
OLD | NEW |