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

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

Issue 1910063005: Store AVDACodecImage list in shared state, cleanup callers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: It lives! Created 4 years, 8 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
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 CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_
6 #define CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ 6 #define CONTENT_COMMON_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 {
17 class SurfaceTexture; 17 class SurfaceTexture;
18 } 18 }
19 19
20 namespace media {
21 class MediaCodecBridge;
22 }
23
20 namespace content { 24 namespace content {
25 class AVDACodecImage;
21 26
22 // Shared state to allow communication between the AVDA and the 27 // Shared state to allow communication between the AVDA and the
23 // GLImages that configure GL for drawing the frames. 28 // GLImages that configure GL for drawing the frames.
24 class AVDASharedState : public base::RefCounted<AVDASharedState> { 29 class AVDASharedState : public base::RefCounted<AVDASharedState> {
25 public: 30 public:
26 AVDASharedState(); 31 AVDASharedState();
27 32
28 GLint surface_texture_service_id() const { 33 GLint surface_texture_service_id() const {
29 return surface_texture_service_id_; 34 return surface_texture_service_id_;
30 } 35 }
(...skipping 12 matching lines...) Expand all
43 // Context that the surface texture is bound to, or nullptr if it is not in 48 // Context that the surface texture is bound to, or nullptr if it is not in
44 // the attached state. 49 // the attached state.
45 gfx::GLContext* context() const { return context_.get(); } 50 gfx::GLContext* context() const { return context_.get(); }
46 51
47 gfx::GLSurface* surface() const { return surface_.get(); } 52 gfx::GLSurface* surface() const { return surface_.get(); }
48 53
49 bool surface_texture_is_attached() const { 54 bool surface_texture_is_attached() const {
50 return surface_texture_is_attached_; 55 return surface_texture_is_attached_;
51 } 56 }
52 57
58 // Iterates over all known codec images and updates the MediaCodec attached to
59 // each one.
60 void CodecChanged(media::MediaCodecBridge* codec);
61
62 // Methods for finding and updating the AVDACodecImage associated with a given
63 // picture buffer id. GetImageForPicture() will return null for unknown ids.
64 void SetImageForPicture(int picture_buffer_id, AVDACodecImage* image);
65 AVDACodecImage* GetImageForPicture(int picture_buffer_id) const;
66 void EraseImage(const AVDACodecImage* image);
67
53 // TODO(liberato): move the surface texture here and make these calls 68 // TODO(liberato): move the surface texture here and make these calls
54 // attach / detach it also. There are several changes going on in avda 69 // attach / detach it also. There are several changes going on in avda
55 // concurrently, so I don't want to change that until the dust settles. 70 // concurrently, so I don't want to change that until the dust settles.
56 // AVDACodecImage would no longer hold the surface texture. 71 // AVDACodecImage would no longer hold the surface texture.
57 72
58 // Call this when the SurfaceTexture is attached to a GL context. This will 73 // Call this when the SurfaceTexture is attached to a GL context. This will
59 // update surface_texture_is_attached(), and set the context() and surface() 74 // update surface_texture_is_attached(), and set the context() and surface()
60 // to match. 75 // to match.
61 void DidAttachSurfaceTexture(); 76 void DidAttachSurfaceTexture();
62 77
63 // Call this when the SurfaceTexture is detached from its GL context. This 78 // Call this when the SurfaceTexture is detached from its GL context. This
64 // will cause us to forget the last binding. 79 // will cause us to forget the last binding.
65 void DidDetachSurfaceTexture(); 80 void DidDetachSurfaceTexture();
66 81
82 protected:
83 virtual ~AVDASharedState();
84
67 private: 85 private:
86 friend class base::RefCounted<AVDASharedState>;
87
68 // Platform gl texture Id for |surface_texture_|. This will be zero if 88 // Platform gl texture Id for |surface_texture_|. This will be zero if
69 // and only if |texture_owner_| is null. 89 // and only if |texture_owner_| is null.
70 // TODO(liberato): This should be GLuint, but we don't seem to have the type. 90 // TODO(liberato): This should be GLuint, but we don't seem to have the type.
71 GLint surface_texture_service_id_; 91 GLint surface_texture_service_id_;
72 92
73 // For signalling OnFrameAvailable(). 93 // For signalling OnFrameAvailable().
74 base::WaitableEvent frame_available_event_; 94 base::WaitableEvent frame_available_event_;
75 95
76 // True if and only if the surface texture is currently attached. 96 // True if and only if the surface texture is currently attached.
77 bool surface_texture_is_attached_; 97 bool surface_texture_is_attached_;
78 98
79 // Context and surface that the surface texture is attached to, if it is 99 // Context and surface that the surface texture is attached to, if it is
80 // currently attached. 100 // currently attached.
81 scoped_refptr<gfx::GLContext> context_; 101 scoped_refptr<gfx::GLContext> context_;
82 scoped_refptr<gfx::GLSurface> surface_; 102 scoped_refptr<gfx::GLSurface> surface_;
83 103
84 protected: 104 // Maps a picture buffer id to a AVDACodecImage.
85 virtual ~AVDASharedState(); 105 std::map<int, AVDACodecImage*> codec_images_;
86 106
87 private: 107 DISALLOW_COPY_AND_ASSIGN(AVDASharedState);
88 friend class base::RefCounted<AVDASharedState>;
89 }; 108 };
90 109
91 } // namespace content 110 } // namespace content
92 111
93 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ 112 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698