| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Transport texture is a mechanism to share a texture between renderer process | 5 // Transport texture is a mechanism to share a texture between renderer process |
| 6 // and GPU process. This is useful when a texture is used in the renderer | 6 // and GPU process. This is useful when a texture is used in the renderer |
| 7 // process but updated in the GPU process. | 7 // process but updated in the GPU process. |
| 8 // | 8 // |
| 9 // BACKGROUND INFORMATION | 9 // BACKGROUND INFORMATION |
| 10 // | 10 // |
| 11 // Renderer process uses command buffer to submit GLES2 commands to the GPU | 11 // Renderer process uses command buffer to submit GLES2 commands to the GPU |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // factory->CreateTextures(3, 1024, 768, TransportTexture::RGB, &textures, | 85 // factory->CreateTextures(3, 1024, 768, TransportTexture::RGB, &textures, |
| 86 // base::Bind(&TextureCreateDone), textures); | 86 // base::Bind(&TextureCreateDone), textures); |
| 87 // } | 87 // } |
| 88 | 88 |
| 89 #ifndef CONTENT_RENDERER_GPU_TRANSPORT_TEXTURE_HOST_H_ | 89 #ifndef CONTENT_RENDERER_GPU_TRANSPORT_TEXTURE_HOST_H_ |
| 90 #define CONTENT_RENDERER_GPU_TRANSPORT_TEXTURE_HOST_H_ | 90 #define CONTENT_RENDERER_GPU_TRANSPORT_TEXTURE_HOST_H_ |
| 91 | 91 |
| 92 #include <vector> | 92 #include <vector> |
| 93 | 93 |
| 94 #include "base/basictypes.h" | 94 #include "base/basictypes.h" |
| 95 #include "base/callback_old.h" | |
| 96 #include "base/memory/ref_counted.h" | 95 #include "base/memory/ref_counted.h" |
| 97 #include "base/memory/scoped_ptr.h" | 96 #include "base/memory/scoped_ptr.h" |
| 98 #include "base/task.h" | 97 #include "base/task.h" |
| 99 #include "ipc/ipc_channel.h" | 98 #include "ipc/ipc_channel.h" |
| 100 | 99 |
| 101 class MessageLoop; | 100 class MessageLoop; |
| 102 class RendererGLContext; | 101 class RendererGLContext; |
| 103 class TransportTextureService; | 102 class TransportTextureService; |
| 104 | 103 |
| 105 class TransportTextureHost | 104 class TransportTextureHost |
| 106 : public base::RefCountedThreadSafe<TransportTextureHost>, | 105 : public base::RefCountedThreadSafe<TransportTextureHost>, |
| 107 public IPC::Channel::Listener { | 106 public IPC::Channel::Listener { |
| 108 public: | 107 public: |
| 109 typedef Callback1<int>::Type TextureUpdateCallback; | 108 typedef base::Callback<void(int)> TextureUpdateCallback; |
| 110 | 109 |
| 111 // |io_message_loop| is where the IPC communication should happen. | 110 // |io_message_loop| is where the IPC communication should happen. |
| 112 // |render_message_loop| is where the GLES2 commands should be exeucted. | 111 // |render_message_loop| is where the GLES2 commands should be executed. |
| 113 // |service| contains the route to this object. | 112 // |service| contains the route to this object. |
| 114 // |sender| is used to send IPC messages to GPU process. | 113 // |sender| is used to send IPC messages to GPU process. |
| 115 // |context| is the RendererGLContextt for generating textures. | 114 // |context| is the RendererGLContextt for generating textures. |
| 116 // |context_route_id| is the route ID for the GpuChannelHost. | 115 // |context_route_id| is the route ID for the GpuChannelHost. |
| 117 // |host_id| is the ID of this object in GpuChannelHost. | 116 // |host_id| is the ID of this object in GpuChannelHost. |
| 118 TransportTextureHost(MessageLoop* io_message_loop, | 117 TransportTextureHost(MessageLoop* io_message_loop, |
| 119 MessageLoop* render_message_loop, | 118 MessageLoop* render_message_loop, |
| 120 TransportTextureService* service, | 119 TransportTextureService* service, |
| 121 IPC::Message::Sender* sender, | 120 IPC::Message::Sender* sender, |
| 122 RendererGLContext* context, | 121 RendererGLContext* context, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 136 // Call this method only after textures are not used in both the renderer | 135 // Call this method only after textures are not used in both the renderer |
| 137 // and GPU process. | 136 // and GPU process. |
| 138 void Destroy(); | 137 void Destroy(); |
| 139 | 138 |
| 140 // Get the list of textures generated through this factory. | 139 // Get the list of textures generated through this factory. |
| 141 // A callback must be provided to listen to texture update events. The | 140 // A callback must be provided to listen to texture update events. The |
| 142 // callback will be called on the IO thread. | 141 // callback will be called on the IO thread. |
| 143 // | 142 // |
| 144 // Note that this method doesn't generate any textures, it simply return | 143 // Note that this method doesn't generate any textures, it simply return |
| 145 // the list of textures generated. | 144 // the list of textures generated. |
| 146 void GetTextures(TextureUpdateCallback* callback, | 145 void GetTextures(const TextureUpdateCallback& callback, |
| 147 std::vector<int>* textures); | 146 std::vector<int>* textures); |
| 148 | 147 |
| 149 // Return the peer ID of TransportTexture in the GPU process. | 148 // Return the peer ID of TransportTexture in the GPU process. |
| 150 int GetPeerId(); | 149 int GetPeerId(); |
| 151 | 150 |
| 152 // IPC::Channel::Listener. | 151 // IPC::Channel::Listener. |
| 153 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 152 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 154 virtual void OnChannelError() OVERRIDE; | 153 virtual void OnChannelError() OVERRIDE; |
| 155 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 154 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 156 | 155 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 181 int32 context_route_id_; | 180 int32 context_route_id_; |
| 182 int32 host_id_; | 181 int32 host_id_; |
| 183 int32 peer_id_; | 182 int32 peer_id_; |
| 184 | 183 |
| 185 scoped_ptr<Task> init_task_; | 184 scoped_ptr<Task> init_task_; |
| 186 | 185 |
| 187 // A list of textures generated. | 186 // A list of textures generated. |
| 188 std::vector<int> textures_; | 187 std::vector<int> textures_; |
| 189 | 188 |
| 190 // Callback when a texture is updated. | 189 // Callback when a texture is updated. |
| 191 scoped_ptr<TextureUpdateCallback> update_callback_; | 190 TextureUpdateCallback update_callback_; |
| 192 | 191 |
| 193 DISALLOW_COPY_AND_ASSIGN(TransportTextureHost); | 192 DISALLOW_COPY_AND_ASSIGN(TransportTextureHost); |
| 194 }; | 193 }; |
| 195 | 194 |
| 196 #endif // CONTENT_RENDERER_GPU_TRANSPORT_TEXTURE_HOST_H_ | 195 #endif // CONTENT_RENDERER_GPU_TRANSPORT_TEXTURE_HOST_H_ |
| OLD | NEW |