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

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

Issue 1924973004: Avoid waiting on the SurfaceTexture until we need to. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment cleanup! Created 4 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
« no previous file with comments | « media/gpu/avda_codec_image.cc ('k') | media/gpu/avda_shared_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ 5 #ifndef MEDIA_GPU_AVDA_SHARED_STATE_H_
6 #define CONTENT_COMMON_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"
11 #include "media/base/android/sdk_media_codec_bridge.h" 11 #include "media/base/android/sdk_media_codec_bridge.h"
12 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
13 #include "ui/gl/gl_image.h" 13 #include "ui/gl/gl_image.h"
14 #include "ui/gl/gl_surface.h" 14 #include "ui/gl/gl_surface.h"
15 15
16 namespace gfx { 16 namespace gfx {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // Call this when the SurfaceTexture is attached to a GL context. This will 71 // Call this when the SurfaceTexture is attached to a GL context. This will
72 // update surface_texture_is_attached(), and set the context() and surface() 72 // update surface_texture_is_attached(), and set the context() and surface()
73 // to match. 73 // to match.
74 void DidAttachSurfaceTexture(); 74 void DidAttachSurfaceTexture();
75 75
76 // Call this when the SurfaceTexture is detached from its GL context. This 76 // Call this when the SurfaceTexture is detached from its GL context. This
77 // will cause us to forget the last binding. 77 // will cause us to forget the last binding.
78 void DidDetachSurfaceTexture(); 78 void DidDetachSurfaceTexture();
79 79
80 // Helper method for coordinating the interactions between
81 // MediaCodec::ReleaseOutputBuffer() and WaitForFrameAvailable() when
82 // rendering to a SurfaceTexture; this method should never be called when
83 // rendering to a SurfaceView.
84 //
85 // The release of the codec buffer to the surface texture is asynchronous, by
86 // using this helper we can attempt to let this process complete in a non
87 // blocking fashion before the SurfaceTexture is used.
88 //
89 // Clients should call this method to release the codec buffer for rendering
90 // and then call WaitForFrameAvailable() before using the SurfaceTexture. In
91 // the ideal case the SurfaceTexture has already been updated, otherwise the
92 // method will wait for a pro-rated amount of time based on elapsed time up
93 // to a short deadline.
94 //
95 // Some devices do not reliably notify frame availability, so we use a very
96 // short deadline of only a few milliseconds to avoid indefinite stalls.
97 void RenderCodecBufferToSurfaceTexture(media::MediaCodecBridge* codec,
98 int codec_buffer_index);
99
80 protected: 100 protected:
81 virtual ~AVDASharedState(); 101 virtual ~AVDASharedState();
82 102
83 private: 103 private:
84 friend class base::RefCounted<AVDASharedState>; 104 friend class base::RefCounted<AVDASharedState>;
85 105
86 // Platform gl texture Id for |surface_texture_|. This will be zero if 106 // Platform gl texture Id for |surface_texture_|. This will be zero if
87 // and only if |texture_owner_| is null. 107 // and only if |texture_owner_| is null.
88 // TODO(liberato): This should be GLuint, but we don't seem to have the type. 108 // TODO(liberato): This should be GLuint, but we don't seem to have the type.
89 GLint surface_texture_service_id_; 109 GLint surface_texture_service_id_;
90 110
91 // For signalling OnFrameAvailable(). 111 // For signalling OnFrameAvailable().
92 base::WaitableEvent frame_available_event_; 112 base::WaitableEvent frame_available_event_;
93 113
94 // True if and only if the surface texture is currently attached. 114 // True if and only if the surface texture is currently attached.
95 bool surface_texture_is_attached_; 115 bool surface_texture_is_attached_;
96 116
97 // Context and surface that the surface texture is attached to, if it is 117 // Context and surface that the surface texture is attached to, if it is
98 // currently attached. 118 // currently attached.
99 scoped_refptr<gfx::GLContext> context_; 119 scoped_refptr<gfx::GLContext> context_;
100 scoped_refptr<gfx::GLSurface> surface_; 120 scoped_refptr<gfx::GLSurface> surface_;
101 121
102 // Maps a picture buffer id to a AVDACodecImage. 122 // Maps a picture buffer id to a AVDACodecImage.
103 std::map<int, AVDACodecImage*> codec_images_; 123 std::map<int, AVDACodecImage*> codec_images_;
104 124
125 // The time of the last call to RenderCodecBufferToSurfaceTexture(), null if
126 // there has been no last call.
liberato (no reviews please) 2016/05/03 05:49:30 not quite accurate -- null if and only if a frame
DaleCurtis 2016/05/04 00:25:29 Actually, I think your suggestion isn't accurate :
127 base::TimeTicks release_time_;
128
105 DISALLOW_COPY_AND_ASSIGN(AVDASharedState); 129 DISALLOW_COPY_AND_ASSIGN(AVDASharedState);
106 }; 130 };
107 131
108 } // namespace media 132 } // namespace media
109 133
110 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ 134 #endif // MEDIA_GPU_AVDA_SHARED_STATE_H_
OLDNEW
« no previous file with comments | « media/gpu/avda_codec_image.cc ('k') | media/gpu/avda_shared_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698