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