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

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

Issue 1682343002: AVDACodecImages keep a reference to the SurfaceTexture backing them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/macros.h"
8 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 10 #include "ui/gl/android/surface_texture.h"
10 #include "media/base/android/media_codec_bridge.h" 11 #include "ui/gl/gl_bindings.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"
14 #include "ui/gl/gl_surface.h" 13 #include "ui/gl/gl_surface.h"
15 14
16 namespace gfx {
17 class SurfaceTexture;
18 }
19
20 namespace content { 15 namespace content {
21 16
22 // Shared state to allow communication between the AVDA and the 17 // Shared state to allow communication between
23 // GLImages that configure GL for drawing the frames. 18 // AndroidDeferredRenderingBackingStrategy and the AVDACodecImages it creates.
19 // It's refcounted so that it lives as long as the images that refer to it.
24 class AVDASharedState : public base::RefCounted<AVDASharedState> { 20 class AVDASharedState : public base::RefCounted<AVDASharedState> {
25 public: 21 public:
26 AVDASharedState(); 22 AVDASharedState();
27 23
28 GLint surface_texture_service_id() const { 24 GLint surface_texture_service_id() const {
29 return surface_texture_service_id_; 25 return surface_texture_service_id_;
30 } 26 }
31 27
32 // Set the SurfaceTexture's client texture name, which the SurfaceTexture 28 // Set the SurfaceTexture's client texture name, which the SurfaceTexture
33 // might not know about yet (see surface_texture_is_attached()). 29 // might not know about yet (see surface_texture_is_attached()).
34 void set_surface_texture_service_id(GLint id) { 30 void set_surface_texture_service_id(GLint id) {
35 surface_texture_service_id_ = id; 31 surface_texture_service_id_ = id;
36 } 32 }
37 33
38 // Signal the "frame available" event. This may be called from any thread. 34 scoped_refptr<gfx::SurfaceTexture> surface_texture() const {
39 void SignalFrameAvailable(); 35 return surface_texture_;
36 }
40 37
41 void WaitForFrameAvailable(); 38 void set_surface_texture(
39 const scoped_refptr<gfx::SurfaceTexture> surface_texture) {
40 surface_texture_ = surface_texture;
41 }
42 42
43 // Context that the surface texture is bound to, or nullptr if it is not in 43 // Context that the surface texture is bound to, or nullptr if it is not in
44 // the attached state. 44 // the attached state.
45 gfx::GLContext* context() const { return context_.get(); } 45 gfx::GLContext* context() const { return context_.get(); }
46 46
47 gfx::GLSurface* surface() const { return surface_.get(); } 47 gfx::GLSurface* surface() const { return surface_.get(); }
48 48
49 bool surface_texture_is_attached() const { 49 bool surface_texture_is_attached() const {
50 return surface_texture_is_attached_; 50 return surface_texture_is_attached_;
51 } 51 }
52 52
53 // Signal the "frame available" event. This may be called from any thread.
54 void SignalFrameAvailable();
55
56 void WaitForFrameAvailable();
57
53 // Call this when the SurfaceTexture is attached to a GL context. This will 58 // Call this when the SurfaceTexture is attached to a GL context. This will
54 // update surface_texture_is_attached(), and set the context() and surface() 59 // update surface_texture_is_attached(), and set the context() and surface()
55 // to match. 60 // to match.
56 void did_attach_surface_texture(); 61 void DidAttachSurfaceTexture();
57 62
58 private: 63 private:
59 // Platform gl texture Id for |surface_texture_|. This will be zero if 64 friend class base::RefCounted<AVDASharedState>;
60 // and only if |texture_owner_| is null. 65 virtual ~AVDASharedState();
61 // TODO(liberato): This should be GLuint, but we don't seem to have the type. 66
62 GLint surface_texture_service_id_; 67 // Platform gl texture ID for |surface_texture_|.
68 GLuint surface_texture_service_id_;
69
70 scoped_refptr<gfx::SurfaceTexture> surface_texture_;
63 71
64 // For signalling OnFrameAvailable(). 72 // For signalling OnFrameAvailable().
65 base::WaitableEvent frame_available_event_; 73 base::WaitableEvent frame_available_event_;
66 74
67 // True if and only if the surface texture is currently attached. 75 // True if and only if the surface texture is currently attached.
68 bool surface_texture_is_attached_; 76 bool surface_texture_is_attached_;
69 77
70 // Context and surface that the surface texture is attached to, if it is 78 // Context and surface that the surface texture is attached to, if it is
71 // currently attached. 79 // currently attached.
72 scoped_refptr<gfx::GLContext> context_; 80 scoped_refptr<gfx::GLContext> context_;
73 scoped_refptr<gfx::GLSurface> surface_; 81 scoped_refptr<gfx::GLSurface> surface_;
74 82
75 protected: 83 DISALLOW_COPY_AND_ASSIGN(AVDASharedState);
76 virtual ~AVDASharedState();
77
78 private:
79 friend class base::RefCounted<AVDASharedState>;
80 }; 84 };
81 85
82 } // namespace content 86 } // namespace content
83 87
84 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ 88 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698