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_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 class GLShareGroup; |
18 } | 19 } |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
22 // Shared state to allow communication between the AVDA and the | 23 // Shared state to allow communication between the AVDA and the |
23 // GLImages that configure GL for drawing the frames. | 24 // GLImages that configure GL for drawing the frames. |
24 class AVDASharedState : public base::RefCounted<AVDASharedState> { | 25 class AVDASharedState : public base::RefCounted<AVDASharedState> { |
25 public: | 26 public: |
26 AVDASharedState(); | 27 AVDASharedState(); |
27 | 28 |
(...skipping 15 matching lines...) Expand all Loading... |
43 // Context that the surface texture is bound to, or nullptr if it is not in | 44 // Context that the surface texture is bound to, or nullptr if it is not in |
44 // the attached state. | 45 // the attached state. |
45 gfx::GLContext* context() const { return context_.get(); } | 46 gfx::GLContext* context() const { return context_.get(); } |
46 | 47 |
47 gfx::GLSurface* surface() const { return surface_.get(); } | 48 gfx::GLSurface* surface() const { return surface_.get(); } |
48 | 49 |
49 bool surface_texture_is_attached() const { | 50 bool surface_texture_is_attached() const { |
50 return surface_texture_is_attached_; | 51 return surface_texture_is_attached_; |
51 } | 52 } |
52 | 53 |
| 54 // TODO(liberato): move the surface texture here and make these calls |
| 55 // attach / detach it also. There are several changes going on in avda |
| 56 // concurrently, so I don't want to change that until the dust settles. |
| 57 // AVDACodecImage would no longer hold the surface texture. |
| 58 |
53 // Call this when the SurfaceTexture is attached to a GL context. This will | 59 // 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() | 60 // update surface_texture_is_attached(), and set the context() and surface() |
55 // to match. | 61 // to match. |
56 void did_attach_surface_texture(); | 62 void DidAttachSurfaceTexture(); |
| 63 |
| 64 // Call this when the SurfaceTexture is detached from its GL context. This |
| 65 // will cause us to forget the last binding. |
| 66 void DidDetachSurfaceTexture(); |
| 67 |
| 68 // Get and set the share group for our SurfaceTexture. |
| 69 void set_share_group(const scoped_refptr<gfx::GLShareGroup>& share_group) { |
| 70 share_group_ = share_group; |
| 71 } |
| 72 |
| 73 gfx::GLShareGroup* share_group() const { return share_group_.get(); } |
57 | 74 |
58 private: | 75 private: |
59 // Platform gl texture Id for |surface_texture_|. This will be zero if | 76 // Platform gl texture Id for |surface_texture_|. This will be zero if |
60 // and only if |texture_owner_| is null. | 77 // and only if |texture_owner_| is null. |
61 // TODO(liberato): This should be GLuint, but we don't seem to have the type. | 78 // TODO(liberato): This should be GLuint, but we don't seem to have the type. |
62 GLint surface_texture_service_id_; | 79 GLint surface_texture_service_id_; |
63 | 80 |
64 // For signalling OnFrameAvailable(). | 81 // For signalling OnFrameAvailable(). |
65 base::WaitableEvent frame_available_event_; | 82 base::WaitableEvent frame_available_event_; |
66 | 83 |
67 // True if and only if the surface texture is currently attached. | 84 // True if and only if the surface texture is currently attached. |
68 bool surface_texture_is_attached_; | 85 bool surface_texture_is_attached_; |
69 | 86 |
70 // Context and surface that the surface texture is attached to, if it is | 87 // Context and surface that the surface texture is attached to, if it is |
71 // currently attached. | 88 // currently attached. |
72 scoped_refptr<gfx::GLContext> context_; | 89 scoped_refptr<gfx::GLContext> context_; |
73 scoped_refptr<gfx::GLSurface> surface_; | 90 scoped_refptr<gfx::GLSurface> surface_; |
74 | 91 |
| 92 // The GL share group that we must be to reference our surface texture. |
| 93 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 94 |
75 protected: | 95 protected: |
76 virtual ~AVDASharedState(); | 96 virtual ~AVDASharedState(); |
77 | 97 |
78 private: | 98 private: |
79 friend class base::RefCounted<AVDASharedState>; | 99 friend class base::RefCounted<AVDASharedState>; |
80 }; | 100 }; |
81 | 101 |
82 } // namespace content | 102 } // namespace content |
83 | 103 |
84 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ | 104 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ |
OLD | NEW |