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> |
(...skipping 10 matching lines...) Expand all Loading... |
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(const scoped_refptr<AVDASharedState>&, |
27 media::VideoCodecBridge* codec, | 27 media::VideoCodecBridge* codec, |
28 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, | 28 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, |
29 const scoped_refptr<gfx::SurfaceTexture>& surface_texture); | 29 const scoped_refptr<gfx::SurfaceTexture>& surface_texture); |
30 | 30 |
31 protected: | |
32 ~AVDACodecImage() override; | |
33 | |
34 public: | |
35 // gl::GLImage implementation | 31 // gl::GLImage implementation |
36 void Destroy(bool have_context) override; | 32 void Destroy(bool have_context) override; |
37 gfx::Size GetSize() override; | 33 gfx::Size GetSize() override; |
38 unsigned GetInternalFormat() override; | 34 unsigned GetInternalFormat() override; |
39 bool BindTexImage(unsigned target) override; | 35 bool BindTexImage(unsigned target) override; |
40 void ReleaseTexImage(unsigned target) override; | 36 void ReleaseTexImage(unsigned target) override; |
41 bool CopyTexImage(unsigned target) override; | 37 bool CopyTexImage(unsigned target) override; |
42 bool CopyTexSubImage(unsigned target, | 38 bool CopyTexSubImage(unsigned target, |
43 const gfx::Point& offset, | 39 const gfx::Point& offset, |
44 const gfx::Rect& rect) override; | 40 const gfx::Rect& rect) override; |
45 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 41 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
46 int z_order, | 42 int z_order, |
47 gfx::OverlayTransform transform, | 43 gfx::OverlayTransform transform, |
48 const gfx::Rect& bounds_rect, | 44 const gfx::Rect& bounds_rect, |
49 const gfx::RectF& crop_rect) override; | 45 const gfx::RectF& crop_rect) override; |
50 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 46 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
51 uint64_t process_tracing_id, | 47 uint64_t process_tracing_id, |
52 const std::string& dump_name) override; | 48 const std::string& dump_name) override; |
53 // gpu::gles2::GLStreamTextureMatrix implementation | 49 // gpu::gles2::GLStreamTextureMatrix implementation |
54 void GetTextureMatrix(float xform[16]) override; | 50 void GetTextureMatrix(float xform[16]) override; |
55 | 51 |
56 public: | |
57 // Decoded buffer index that has the image for us to display. | 52 // Decoded buffer index that has the image for us to display. |
58 void SetMediaCodecBufferIndex(int buffer_index); | 53 void SetMediaCodecBufferIndex(int buffer_index); |
59 | 54 |
60 // Return the codec buffer that we will return to the codec, or | 55 // Return the codec buffer that we will return to the codec, or |
61 // <0 if there is no such buffer. | 56 // <0 if there is no such buffer. |
62 int GetMediaCodecBufferIndex() const; | 57 int GetMediaCodecBufferIndex() const; |
63 | 58 |
64 // Set the size of the current image. | 59 // Set the size of the current image. |
65 void SetSize(const gfx::Size& size); | 60 void SetSize(const gfx::Size& size); |
66 | 61 |
| 62 // Updates the MediaCodec for this image; clears |codec_buffer_index_|. |
67 void SetMediaCodec(media::MediaCodecBridge* codec); | 63 void SetMediaCodec(media::MediaCodecBridge* codec); |
68 | 64 |
69 void SetTexture(gpu::gles2::Texture* texture); | 65 void SetTexture(gpu::gles2::Texture* texture); |
70 | 66 |
| 67 protected: |
| 68 ~AVDACodecImage() override; |
| 69 |
71 private: | 70 private: |
72 enum { kInvalidCodecBufferIndex = -1 }; | 71 enum { kInvalidCodecBufferIndex = -1 }; |
73 | 72 |
74 // Make sure that the surface texture's front buffer is current. This will | 73 // 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 | 74 // save / restore the current context. It will optionally restore the texture |
76 // bindings in the surface texture's context, based on |mode|. This is | 75 // 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 | 76 // 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 | 77 // 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 | 78 // both contexts. In other words, the caller is telling us whether it's |
80 // okay to change the binding in the current context. | 79 // okay to change the binding in the current context. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 124 |
126 // Texture matrix of the front buffer of the surface texture. | 125 // Texture matrix of the front buffer of the surface texture. |
127 float gl_matrix_[16]; | 126 float gl_matrix_[16]; |
128 | 127 |
129 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); | 128 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); |
130 }; | 129 }; |
131 | 130 |
132 } // namespace content | 131 } // namespace content |
133 | 132 |
134 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ | 133 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ |
OLD | NEW |