| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ | 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Asks the StreamTexture to forward its SurfaceTexture to the | 60 // Asks the StreamTexture to forward its SurfaceTexture to the |
| 61 // ScopedSurfaceRequestManager, using the gpu::ScopedSurfaceRequestConduit. | 61 // ScopedSurfaceRequestManager, using the gpu::ScopedSurfaceRequestConduit. |
| 62 void ForwardStreamTextureForSurfaceRequest( | 62 void ForwardStreamTextureForSurfaceRequest( |
| 63 const base::UnguessableToken& request_token); | 63 const base::UnguessableToken& request_token); |
| 64 | 64 |
| 65 struct Deleter { | 65 struct Deleter { |
| 66 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } | 66 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } |
| 67 }; | 67 }; |
| 68 private: | 68 private: |
| 69 friend class StreamTextureFactory; | 69 friend class StreamTextureFactory; |
| 70 explicit StreamTextureProxy(StreamTextureHost* host); | 70 explicit StreamTextureProxy(std::unique_ptr<StreamTextureHost> host); |
| 71 | 71 |
| 72 void BindOnThread(); | 72 void BindOnThread(); |
| 73 void Release(); | 73 void Release(); |
| 74 | 74 |
| 75 const std::unique_ptr<StreamTextureHost> host_; | 75 const std::unique_ptr<StreamTextureHost> host_; |
| 76 | 76 |
| 77 // Protects access to |received_frame_cb_| and |task_runner_|. | 77 // Protects access to |received_frame_cb_| and |task_runner_|. |
| 78 base::Lock lock_; | 78 base::Lock lock_; |
| 79 base::Closure received_frame_cb_; | 79 base::Closure received_frame_cb_; |
| 80 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 80 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 93 scoped_refptr<ContextProviderCommandBuffer> context_provider); | 93 scoped_refptr<ContextProviderCommandBuffer> context_provider); |
| 94 | 94 |
| 95 // Create the StreamTextureProxy object. This internally calls | 95 // Create the StreamTextureProxy object. This internally calls |
| 96 // CreateSteamTexture with the recieved arguments. CreateSteamTexture | 96 // CreateSteamTexture with the recieved arguments. CreateSteamTexture |
| 97 // generates a texture and stores it in *texture_id, the texture is produced | 97 // generates a texture and stores it in *texture_id, the texture is produced |
| 98 // into a mailbox so it can be shipped in a VideoFrame, it creates a | 98 // into a mailbox so it can be shipped in a VideoFrame, it creates a |
| 99 // gpu::StreamTexture and returns its route_id. If this route_id is invalid | 99 // gpu::StreamTexture and returns its route_id. If this route_id is invalid |
| 100 // nullptr is returned and *texture_id will be set to 0. If the route_id is | 100 // nullptr is returned and *texture_id will be set to 0. If the route_id is |
| 101 // valid it returns StreamTextureProxy object. The caller needs to take care | 101 // valid it returns StreamTextureProxy object. The caller needs to take care |
| 102 // of cleaning up the texture_id. | 102 // of cleaning up the texture_id. |
| 103 StreamTextureProxy* CreateProxy(unsigned texture_target, | 103 ScopedStreamTextureProxy CreateProxy(unsigned texture_target, |
| 104 unsigned* texture_id, | 104 unsigned* texture_id, |
| 105 gpu::Mailbox* texture_mailbox); | 105 gpu::Mailbox* texture_mailbox); |
| 106 | 106 |
| 107 gpu::gles2::GLES2Interface* ContextGL(); | 107 gpu::gles2::GLES2Interface* ContextGL(); |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 friend class base::RefCounted<StreamTextureFactory>; | 110 friend class base::RefCounted<StreamTextureFactory>; |
| 111 StreamTextureFactory( | 111 StreamTextureFactory( |
| 112 scoped_refptr<ContextProviderCommandBuffer> context_provider); | 112 scoped_refptr<ContextProviderCommandBuffer> context_provider); |
| 113 ~StreamTextureFactory(); | 113 ~StreamTextureFactory(); |
| 114 // Creates a gpu::StreamTexture and returns its id. Sets |*texture_id| to the | 114 // Creates a gpu::StreamTexture and returns its id. Sets |*texture_id| to the |
| 115 // client-side id of the gpu::StreamTexture. The texture is produced into | 115 // client-side id of the gpu::StreamTexture. The texture is produced into |
| 116 // a mailbox so it can be shipped in a VideoFrame. | 116 // a mailbox so it can be shipped in a VideoFrame. |
| 117 unsigned CreateStreamTexture(unsigned texture_target, | 117 unsigned CreateStreamTexture(unsigned texture_target, |
| 118 unsigned* texture_id, | 118 unsigned* texture_id, |
| 119 gpu::Mailbox* texture_mailbox); | 119 gpu::Mailbox* texture_mailbox); |
| 120 | 120 |
| 121 scoped_refptr<ContextProviderCommandBuffer> context_provider_; | 121 scoped_refptr<ContextProviderCommandBuffer> context_provider_; |
| 122 scoped_refptr<gpu::GpuChannelHost> channel_; | 122 scoped_refptr<gpu::GpuChannelHost> channel_; |
| 123 | 123 |
| 124 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactory); | 124 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactory); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace content | 127 } // namespace content |
| 128 | 128 |
| 129 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ | 129 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ |
| OLD | NEW |