| 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_SHARED_STATE_H_ | 5 #ifndef MEDIA_GPU_AVDA_SHARED_STATE_H_ |
| 6 #define MEDIA_GPU_AVDA_SHARED_STATE_H_ | 6 #define MEDIA_GPU_AVDA_SHARED_STATE_H_ |
| 7 | 7 |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // and then call WaitForFrameAvailable() before using the SurfaceTexture. In | 68 // and then call WaitForFrameAvailable() before using the SurfaceTexture. In |
| 69 // the ideal case the SurfaceTexture has already been updated, otherwise the | 69 // the ideal case the SurfaceTexture has already been updated, otherwise the |
| 70 // method will wait for a pro-rated amount of time based on elapsed time up | 70 // method will wait for a pro-rated amount of time based on elapsed time up |
| 71 // to a short deadline. | 71 // to a short deadline. |
| 72 // | 72 // |
| 73 // Some devices do not reliably notify frame availability, so we use a very | 73 // Some devices do not reliably notify frame availability, so we use a very |
| 74 // short deadline of only a few milliseconds to avoid indefinite stalls. | 74 // short deadline of only a few milliseconds to avoid indefinite stalls. |
| 75 void RenderCodecBufferToSurfaceTexture(MediaCodecBridge* codec, | 75 void RenderCodecBufferToSurfaceTexture(MediaCodecBridge* codec, |
| 76 int codec_buffer_index); | 76 int codec_buffer_index); |
| 77 | 77 |
| 78 // Helper methods for interacting with |surface_texture_|. See |
| 79 // gfx::SurfaceTexture for method details. |
| 80 void UpdateTexImage(); |
| 81 void GetTransformMatrix(float matrix[16]) const; |
| 82 |
| 78 protected: | 83 protected: |
| 79 virtual ~AVDASharedState(); | 84 virtual ~AVDASharedState(); |
| 80 | 85 |
| 81 private: | 86 private: |
| 82 friend class base::RefCounted<AVDASharedState>; | 87 friend class base::RefCounted<AVDASharedState>; |
| 83 | 88 |
| 84 scoped_refptr<gl::SurfaceTexture> surface_texture_; | 89 scoped_refptr<gl::SurfaceTexture> surface_texture_; |
| 85 | 90 |
| 86 // Platform gl texture id for |surface_texture_|. | 91 // Platform gl texture id for |surface_texture_|. |
| 87 GLuint surface_texture_service_id_; | 92 GLuint surface_texture_service_id_; |
| 88 | 93 |
| 89 // For signalling OnFrameAvailable(). | 94 // For signalling OnFrameAvailable(). |
| 90 base::WaitableEvent frame_available_event_; | 95 base::WaitableEvent frame_available_event_; |
| 91 | 96 |
| 92 // Context and surface that |surface_texture_| is bound to, if | 97 // Context and surface that |surface_texture_| is bound to, if |
| 93 // |surface_texture_| is not null. | 98 // |surface_texture_| is not null. |
| 94 scoped_refptr<gl::GLContext> context_; | 99 scoped_refptr<gl::GLContext> context_; |
| 95 scoped_refptr<gl::GLSurface> surface_; | 100 scoped_refptr<gl::GLSurface> surface_; |
| 96 | 101 |
| 97 // Maps a picture buffer id to a AVDACodecImage. | 102 // Maps a picture buffer id to a AVDACodecImage. |
| 98 std::map<int, AVDACodecImage*> codec_images_; | 103 std::map<int, AVDACodecImage*> codec_images_; |
| 99 | 104 |
| 100 // The time of the last call to RenderCodecBufferToSurfaceTexture(), null if | 105 // The time of the last call to RenderCodecBufferToSurfaceTexture(), null if |
| 101 // if there has been no last call or WaitForFrameAvailable() has been called | 106 // if there has been no last call or WaitForFrameAvailable() has been called |
| 102 // since the last call. | 107 // since the last call. |
| 103 base::TimeTicks release_time_; | 108 base::TimeTicks release_time_; |
| 104 | 109 |
| 110 // Texture matrix of the front buffer of the surface texture. |
| 111 float gl_matrix_[16]; |
| 112 |
| 105 DISALLOW_COPY_AND_ASSIGN(AVDASharedState); | 113 DISALLOW_COPY_AND_ASSIGN(AVDASharedState); |
| 106 }; | 114 }; |
| 107 | 115 |
| 108 } // namespace media | 116 } // namespace media |
| 109 | 117 |
| 110 #endif // MEDIA_GPU_AVDA_SHARED_STATE_H_ | 118 #endif // MEDIA_GPU_AVDA_SHARED_STATE_H_ |
| OLD | NEW |