| OLD | NEW |
| 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 | 7 |
| 8 #if defined(ENABLE_GPU) | 8 #if defined(ENABLE_GPU) |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "ipc/ipc_listener.h" | 17 #include "ipc/ipc_listener.h" |
| 18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 22 #include "ui/gl/gl_surface.h" | 22 #include "ui/gl/gl_surface.h" |
| 23 #include "ui/surface/transport_dib.h" | 23 #include "ui/surface/transport_dib.h" |
| 24 #include "webkit/compositor_bindings/web_latency_info_impl.h" |
| 24 | 25 |
| 25 struct GpuHostMsg_AcceleratedSurfaceNew_Params; | 26 struct GpuHostMsg_AcceleratedSurfaceNew_Params; |
| 26 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
| 27 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; | 28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; |
| 28 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; | 29 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; |
| 29 | 30 |
| 30 namespace gfx { | 31 namespace gfx { |
| 31 class GLSurface; | 32 class GLSurface; |
| 32 } | 33 } |
| 33 | 34 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 56 // making sure outside events reach the ImageTransportSurface and | 57 // making sure outside events reach the ImageTransportSurface and |
| 57 // allowing the ImageTransportSurface to send events to the outside world. | 58 // allowing the ImageTransportSurface to send events to the outside world. |
| 58 | 59 |
| 59 class ImageTransportSurface { | 60 class ImageTransportSurface { |
| 60 public: | 61 public: |
| 61 ImageTransportSurface(); | 62 ImageTransportSurface(); |
| 62 | 63 |
| 63 virtual void OnBufferPresented(uint64 surface_handle, uint32 sync_point) = 0; | 64 virtual void OnBufferPresented(uint64 surface_handle, uint32 sync_point) = 0; |
| 64 virtual void OnResizeViewACK() = 0; | 65 virtual void OnResizeViewACK() = 0; |
| 65 virtual void OnResize(gfx::Size size) = 0; | 66 virtual void OnResize(gfx::Size size) = 0; |
| 67 virtual void SetLatencyInfo( |
| 68 const WebKit::WebLatencyInfoImpl& latency_info) = 0; |
| 66 | 69 |
| 67 // Creates the appropriate surface depending on the GL implementation. | 70 // Creates the appropriate surface depending on the GL implementation. |
| 68 static scoped_refptr<gfx::GLSurface> | 71 static scoped_refptr<gfx::GLSurface> |
| 69 CreateSurface(GpuChannelManager* manager, | 72 CreateSurface(GpuChannelManager* manager, |
| 70 GpuCommandBufferStub* stub, | 73 GpuCommandBufferStub* stub, |
| 71 const gfx::GLSurfaceHandle& handle); | 74 const gfx::GLSurfaceHandle& handle); |
| 72 | 75 |
| 73 virtual gfx::Size GetSize() = 0; | 76 virtual gfx::Size GetSize() = 0; |
| 74 | 77 |
| 75 protected: | 78 protected: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void SendAcceleratedSurfaceBuffersSwapped( | 113 void SendAcceleratedSurfaceBuffersSwapped( |
| 111 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params); | 114 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params); |
| 112 void SendAcceleratedSurfacePostSubBuffer( | 115 void SendAcceleratedSurfacePostSubBuffer( |
| 113 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params); | 116 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params); |
| 114 void SendAcceleratedSurfaceRelease( | 117 void SendAcceleratedSurfaceRelease( |
| 115 GpuHostMsg_AcceleratedSurfaceRelease_Params params); | 118 GpuHostMsg_AcceleratedSurfaceRelease_Params params); |
| 116 void SendResizeView(const gfx::Size& size); | 119 void SendResizeView(const gfx::Size& size); |
| 117 void SendUpdateVSyncParameters( | 120 void SendUpdateVSyncParameters( |
| 118 base::TimeTicks timebase, base::TimeDelta interval); | 121 base::TimeTicks timebase, base::TimeDelta interval); |
| 119 | 122 |
| 123 void SendLatencyInfo(const WebKit::WebLatencyInfoImpl& latency_info); |
| 124 |
| 120 // Whether or not we should execute more commands. | 125 // Whether or not we should execute more commands. |
| 121 void SetScheduled(bool is_scheduled); | 126 void SetScheduled(bool is_scheduled); |
| 122 | 127 |
| 123 void DeferToFence(base::Closure task); | 128 void DeferToFence(base::Closure task); |
| 124 | 129 |
| 125 void SetPreemptByCounter( | 130 void SetPreemptByCounter( |
| 126 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter); | 131 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter); |
| 127 | 132 |
| 128 // Make the surface's context current. | 133 // Make the surface's context current. |
| 129 bool MakeCurrent(); | 134 bool MakeCurrent(); |
| 130 | 135 |
| 131 // Set the default swap interval on the surface. | 136 // Set the default swap interval on the surface. |
| 132 static void SetSwapInterval(gfx::GLContext* context); | 137 static void SetSwapInterval(gfx::GLContext* context); |
| 133 | 138 |
| 134 void Suspend(); | 139 void Suspend(); |
| 135 | 140 |
| 136 GpuChannelManager* manager() const { return manager_; } | 141 GpuChannelManager* manager() const { return manager_; } |
| 137 GpuCommandBufferStub* stub() const { return stub_.get(); } | 142 GpuCommandBufferStub* stub() const { return stub_.get(); } |
| 138 | 143 |
| 139 private: | 144 private: |
| 140 gpu::GpuScheduler* Scheduler(); | 145 gpu::GpuScheduler* Scheduler(); |
| 141 gpu::gles2::GLES2Decoder* Decoder(); | 146 gpu::gles2::GLES2Decoder* Decoder(); |
| 142 | 147 |
| 143 // IPC::Message handlers. | 148 // IPC::Message handlers. |
| 144 void OnBufferPresented(uint64 surface_handle, uint32 sync_point); | 149 void OnBufferPresented(uint64 surface_handle, uint32 sync_point); |
| 145 void OnResizeViewACK(); | 150 void OnResizeViewACK(); |
| 151 void OnFrameDisplayed(const WebKit::WebLatencyInfoImpl& latency_info); |
| 146 | 152 |
| 147 // Backbuffer resize callback. | 153 // Backbuffer resize callback. |
| 148 void Resize(gfx::Size size); | 154 void Resize(gfx::Size size); |
| 149 | 155 |
| 156 void SetLatencyInfo(const WebKit::WebLatencyInfoImpl& latency_info); |
| 157 |
| 150 // Weak pointers that point to objects that outlive this helper. | 158 // Weak pointers that point to objects that outlive this helper. |
| 151 ImageTransportSurface* surface_; | 159 ImageTransportSurface* surface_; |
| 152 GpuChannelManager* manager_; | 160 GpuChannelManager* manager_; |
| 153 | 161 |
| 154 base::WeakPtr<GpuCommandBufferStub> stub_; | 162 base::WeakPtr<GpuCommandBufferStub> stub_; |
| 155 int32 route_id_; | 163 int32 route_id_; |
| 156 gfx::PluginWindowHandle handle_; | 164 gfx::PluginWindowHandle handle_; |
| 157 | 165 |
| 158 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); | 166 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); |
| 159 }; | 167 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 175 virtual bool SwapBuffers() OVERRIDE; | 183 virtual bool SwapBuffers() OVERRIDE; |
| 176 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 184 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
| 177 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 185 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
| 178 | 186 |
| 179 // ImageTransportSurface implementation. | 187 // ImageTransportSurface implementation. |
| 180 virtual void OnBufferPresented(uint64 surface_handle, | 188 virtual void OnBufferPresented(uint64 surface_handle, |
| 181 uint32 sync_point) OVERRIDE; | 189 uint32 sync_point) OVERRIDE; |
| 182 virtual void OnResizeViewACK() OVERRIDE; | 190 virtual void OnResizeViewACK() OVERRIDE; |
| 183 virtual void OnResize(gfx::Size size) OVERRIDE; | 191 virtual void OnResize(gfx::Size size) OVERRIDE; |
| 184 virtual gfx::Size GetSize() OVERRIDE; | 192 virtual gfx::Size GetSize() OVERRIDE; |
| 193 virtual void SetLatencyInfo( |
| 194 const WebKit::WebLatencyInfoImpl& latency_info) OVERRIDE; |
| 185 | 195 |
| 186 protected: | 196 protected: |
| 187 virtual ~PassThroughImageTransportSurface(); | 197 virtual ~PassThroughImageTransportSurface(); |
| 188 | 198 |
| 189 // If updated vsync parameters can be determined, send this information to | 199 // If updated vsync parameters can be determined, send this information to |
| 190 // the browser. | 200 // the browser. |
| 191 virtual void SendVSyncUpdateIfAvailable(); | 201 virtual void SendVSyncUpdateIfAvailable(); |
| 192 | 202 |
| 193 private: | 203 private: |
| 194 scoped_ptr<ImageTransportHelper> helper_; | 204 scoped_ptr<ImageTransportHelper> helper_; |
| 195 gfx::Size new_size_; | 205 gfx::Size new_size_; |
| 196 bool transport_; | 206 bool transport_; |
| 197 bool did_set_swap_interval_; | 207 bool did_set_swap_interval_; |
| 208 WebKit::WebLatencyInfoImpl latency_info_; |
| 198 | 209 |
| 199 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); | 210 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); |
| 200 }; | 211 }; |
| 201 | 212 |
| 202 } // namespace content | 213 } // namespace content |
| 203 | 214 |
| 204 #endif // defined(ENABLE_GPU) | 215 #endif // defined(ENABLE_GPU) |
| 205 | 216 |
| 206 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ | 217 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ |
| OLD | NEW |