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

Side by Side Diff: content/common/gpu/image_transport_surface.h

Issue 9194005: gpu: reference target surfaces through a globally unique surface id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix more tests Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/gpu_messages.h ('k') | content/common/gpu/image_transport_surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ 5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_
6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_
7 #pragma once 7 #pragma once
8 8
9 #if defined(ENABLE_GPU) 9 #if defined(ENABLE_GPU)
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
15 #include "ipc/ipc_channel.h" 16 #include "ipc/ipc_channel.h"
16 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
17 #include "ui/gfx/gl/gl_surface.h" 18 #include "ui/gfx/gl/gl_surface.h"
18 #include "ui/gfx/size.h" 19 #include "ui/gfx/size.h"
19 #include "ui/gfx/native_widget_types.h" 20 #include "ui/gfx/native_widget_types.h"
20 #include "ui/gfx/surface/transport_dib.h" 21 #include "ui/gfx/surface/transport_dib.h"
21 22
22 class GpuChannelManager; 23 class GpuChannelManager;
24 class GpuCommandBufferStub;
23 25
24 struct GpuHostMsg_AcceleratedSurfaceNew_Params; 26 struct GpuHostMsg_AcceleratedSurfaceNew_Params;
25 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; 27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
26 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; 28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
27 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; 29 struct GpuHostMsg_AcceleratedSurfaceRelease_Params;
28 30
29 namespace gfx { 31 namespace gfx {
30 class GLSurface; 32 class GLSurface;
31 } 33 }
32 34
(...skipping 26 matching lines...) Expand all
59 virtual void OnNewSurfaceACK( 61 virtual void OnNewSurfaceACK(
60 uint64 surface_id, TransportDIB::Handle surface_handle) = 0; 62 uint64 surface_id, TransportDIB::Handle surface_handle) = 0;
61 virtual void OnBuffersSwappedACK() = 0; 63 virtual void OnBuffersSwappedACK() = 0;
62 virtual void OnPostSubBufferACK() = 0; 64 virtual void OnPostSubBufferACK() = 0;
63 virtual void OnResizeViewACK() = 0; 65 virtual void OnResizeViewACK() = 0;
64 virtual void OnResize(gfx::Size size) = 0; 66 virtual void OnResize(gfx::Size size) = 0;
65 67
66 // Creates the appropriate surface depending on the GL implementation. 68 // Creates the appropriate surface depending on the GL implementation.
67 static scoped_refptr<gfx::GLSurface> 69 static scoped_refptr<gfx::GLSurface>
68 CreateSurface(GpuChannelManager* manager, 70 CreateSurface(GpuChannelManager* manager,
69 int32 render_view_id, 71 GpuCommandBufferStub* stub,
70 int32 client_id,
71 int32 command_buffer_id,
72 gfx::PluginWindowHandle handle); 72 gfx::PluginWindowHandle handle);
73 private: 73 private:
74 DISALLOW_COPY_AND_ASSIGN(ImageTransportSurface); 74 DISALLOW_COPY_AND_ASSIGN(ImageTransportSurface);
75 }; 75 };
76 76
77 class ImageTransportHelper : public IPC::Channel::Listener { 77 class ImageTransportHelper : public IPC::Channel::Listener {
78 public: 78 public:
79 // Takes weak pointers to objects that outlive the helper. 79 // Takes weak pointers to objects that outlive the helper.
80 ImageTransportHelper(ImageTransportSurface* surface, 80 ImageTransportHelper(ImageTransportSurface* surface,
81 GpuChannelManager* manager, 81 GpuChannelManager* manager,
82 int32 render_view_id, 82 GpuCommandBufferStub* stub,
83 int32 client_id,
84 int32 command_buffer_id,
85 gfx::PluginWindowHandle handle); 83 gfx::PluginWindowHandle handle);
86 virtual ~ImageTransportHelper(); 84 virtual ~ImageTransportHelper();
87 85
88 bool Initialize(); 86 bool Initialize();
89 void Destroy(); 87 void Destroy();
90 88
91 // IPC::Channel::Listener implementation: 89 // IPC::Channel::Listener implementation:
92 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 90 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
93 91
94 // Helper send functions. Caller fills in the surface specific params 92 // Helper send functions. Caller fills in the surface specific params
(...skipping 14 matching lines...) Expand all
109 void DeferToFence(base::Closure task); 107 void DeferToFence(base::Closure task);
110 108
111 // Make the surface's context current. 109 // Make the surface's context current.
112 bool MakeCurrent(); 110 bool MakeCurrent();
113 111
114 private: 112 private:
115 gpu::GpuScheduler* Scheduler(); 113 gpu::GpuScheduler* Scheduler();
116 gpu::gles2::GLES2Decoder* Decoder(); 114 gpu::gles2::GLES2Decoder* Decoder();
117 115
118 // IPC::Message handlers. 116 // IPC::Message handlers.
119 void OnNewSurfaceACK(uint64 surface_id, TransportDIB::Handle surface_handle); 117 void OnNewSurfaceACK(uint64 surface_handle, TransportDIB::Handle shm_handle);
120 void OnBuffersSwappedACK(); 118 void OnBuffersSwappedACK();
121 void OnPostSubBufferACK(); 119 void OnPostSubBufferACK();
122 void OnResizeViewACK(); 120 void OnResizeViewACK();
123 121
124 // Backbuffer resize callback. 122 // Backbuffer resize callback.
125 void Resize(gfx::Size size); 123 void Resize(gfx::Size size);
126 124
127 // Set the default swap interval on the surface. 125 // Set the default swap interval on the surface.
128 void SetSwapInterval(); 126 void SetSwapInterval();
129 127
130 // Weak pointers that point to objects that outlive this helper. 128 // Weak pointers that point to objects that outlive this helper.
131 ImageTransportSurface* surface_; 129 ImageTransportSurface* surface_;
132 GpuChannelManager* manager_; 130 GpuChannelManager* manager_;
133 131
134 int32 render_view_id_; 132 base::WeakPtr<GpuCommandBufferStub> stub_;
135 int32 client_id_;
136 int32 command_buffer_id_;
137 int32 route_id_; 133 int32 route_id_;
138 gfx::PluginWindowHandle handle_; 134 gfx::PluginWindowHandle handle_;
139 135
140 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); 136 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper);
141 }; 137 };
142 138
143 // An implementation of ImageTransportSurface that implements GLSurface through 139 // An implementation of ImageTransportSurface that implements GLSurface through
144 // GLSurfaceAdapter, thereby forwarding GLSurface methods through to it. 140 // GLSurfaceAdapter, thereby forwarding GLSurface methods through to it.
145 class PassThroughImageTransportSurface 141 class PassThroughImageTransportSurface
146 : public gfx::GLSurfaceAdapter, 142 : public gfx::GLSurfaceAdapter,
147 public ImageTransportSurface { 143 public ImageTransportSurface {
148 public: 144 public:
149 PassThroughImageTransportSurface(GpuChannelManager* manager, 145 PassThroughImageTransportSurface(GpuChannelManager* manager,
150 int32 render_view_id, 146 GpuCommandBufferStub* stub,
151 int32 client_id,
152 int32 command_buffer_id,
153 gfx::GLSurface* surface); 147 gfx::GLSurface* surface);
154 virtual ~PassThroughImageTransportSurface(); 148 virtual ~PassThroughImageTransportSurface();
155 149
156 // GLSurface implementation. 150 // GLSurface implementation.
157 virtual bool Initialize() OVERRIDE; 151 virtual bool Initialize() OVERRIDE;
158 virtual void Destroy() OVERRIDE; 152 virtual void Destroy() OVERRIDE;
159 virtual bool SwapBuffers() OVERRIDE; 153 virtual bool SwapBuffers() OVERRIDE;
160 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 154 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
161 155
162 // ImageTransportSurface implementation. 156 // ImageTransportSurface implementation.
163 virtual void OnNewSurfaceACK( 157 virtual void OnNewSurfaceACK(
164 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 158 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE;
165 virtual void OnBuffersSwappedACK() OVERRIDE; 159 virtual void OnBuffersSwappedACK() OVERRIDE;
166 virtual void OnPostSubBufferACK() OVERRIDE; 160 virtual void OnPostSubBufferACK() OVERRIDE;
167 virtual void OnResizeViewACK() OVERRIDE; 161 virtual void OnResizeViewACK() OVERRIDE;
168 virtual void OnResize(gfx::Size size) OVERRIDE; 162 virtual void OnResize(gfx::Size size) OVERRIDE;
169 163
170 private: 164 private:
171 scoped_ptr<ImageTransportHelper> helper_; 165 scoped_ptr<ImageTransportHelper> helper_;
172 166
173 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); 167 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface);
174 }; 168 };
175 169
176 #endif // defined(ENABLE_GPU) 170 #endif // defined(ENABLE_GPU)
177 171
178 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ 172 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_messages.h ('k') | content/common/gpu/image_transport_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698