OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "content/common/gpu/image_transport_surface.h" | 7 #include "content/common/gpu/image_transport_surface.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 class PbufferImageTransportSurface | 25 class PbufferImageTransportSurface |
26 : public gfx::GLSurfaceAdapter, | 26 : public gfx::GLSurfaceAdapter, |
27 public ImageTransportSurface, | 27 public ImageTransportSurface, |
28 public base::SupportsWeakPtr<PbufferImageTransportSurface> { | 28 public base::SupportsWeakPtr<PbufferImageTransportSurface> { |
29 public: | 29 public: |
30 PbufferImageTransportSurface(GpuChannelManager* manager, | 30 PbufferImageTransportSurface(GpuChannelManager* manager, |
31 int32 render_view_id, | 31 int32 render_view_id, |
32 int32 renderer_id, | 32 int32 renderer_id, |
33 int32 command_buffer_id); | 33 int32 command_buffer_id); |
34 | 34 |
35 // GLSurface implementation | 35 // gfx::GLSurface implementation |
36 virtual bool Initialize(); | 36 virtual bool Initialize() OVERRIDE; |
37 virtual void Destroy(); | 37 virtual void Destroy() OVERRIDE; |
38 virtual bool IsOffscreen(); | 38 virtual bool IsOffscreen() OVERRIDE; |
39 virtual bool SwapBuffers(); | 39 virtual bool SwapBuffers() OVERRIDE; |
| 40 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
| 41 virtual std::string GetExtensions() OVERRIDE; |
40 | 42 |
41 protected: | 43 protected: |
42 // ImageTransportSurface implementation | 44 // ImageTransportSurface implementation |
43 virtual void OnNewSurfaceACK(uint64 surface_id, | 45 virtual void OnNewSurfaceACK(uint64 surface_id, |
44 TransportDIB::Handle shm_handle) OVERRIDE; | 46 TransportDIB::Handle shm_handle) OVERRIDE; |
45 virtual void OnBuffersSwappedACK() OVERRIDE; | 47 virtual void OnBuffersSwappedACK() OVERRIDE; |
46 virtual void OnPostSubBufferACK() OVERRIDE; | 48 virtual void OnPostSubBufferACK() OVERRIDE; |
47 virtual void OnResizeViewACK() OVERRIDE; | 49 virtual void OnResizeViewACK() OVERRIDE; |
48 virtual void OnResize(gfx::Size size) OVERRIDE; | 50 virtual void OnResize(gfx::Size size) OVERRIDE; |
49 | 51 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (!surface_handle) | 104 if (!surface_handle) |
103 return false; | 105 return false; |
104 | 106 |
105 helper_->DeferToFence(base::Bind( | 107 helper_->DeferToFence(base::Bind( |
106 &PbufferImageTransportSurface::SendBuffersSwapped, | 108 &PbufferImageTransportSurface::SendBuffersSwapped, |
107 AsWeakPtr())); | 109 AsWeakPtr())); |
108 | 110 |
109 return true; | 111 return true; |
110 } | 112 } |
111 | 113 |
| 114 bool PbufferImageTransportSurface::PostSubBuffer( |
| 115 int x, int y, int width, int height) { |
| 116 NOTREACHED(); |
| 117 return false; |
| 118 } |
| 119 |
| 120 std::string PbufferImageTransportSurface::GetExtensions() { |
| 121 std::string extensions = gfx::GLSurface::GetExtensions(); |
| 122 extensions += extensions.empty() ? "" : " "; |
| 123 extensions += "GL_CHROMIUM_front_buffer_cached"; |
| 124 return extensions; |
| 125 } |
| 126 |
112 void PbufferImageTransportSurface::SendBuffersSwapped() { | 127 void PbufferImageTransportSurface::SendBuffersSwapped() { |
113 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 128 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
114 params.surface_id = reinterpret_cast<int64>(GetShareHandle()); | 129 params.surface_id = reinterpret_cast<int64>(GetShareHandle()); |
115 params.size = GetSize(); | 130 params.size = GetSize(); |
116 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 131 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
117 | 132 |
118 helper_->SetScheduled(false); | 133 helper_->SetScheduled(false); |
119 } | 134 } |
120 | 135 |
121 void PbufferImageTransportSurface::OnBuffersSwappedACK() { | 136 void PbufferImageTransportSurface::OnBuffersSwappedACK() { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 surface.get()); | 187 surface.get()); |
173 } | 188 } |
174 | 189 |
175 if (surface->Initialize()) | 190 if (surface->Initialize()) |
176 return surface; | 191 return surface; |
177 else | 192 else |
178 return NULL; | 193 return NULL; |
179 } | 194 } |
180 | 195 |
181 #endif // ENABLE_GPU | 196 #endif // ENABLE_GPU |
OLD | NEW |