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 #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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 PbufferImageTransportSurface(GpuChannelManager* manager, | 33 PbufferImageTransportSurface(GpuChannelManager* manager, |
34 GpuCommandBufferStub* stub); | 34 GpuCommandBufferStub* stub); |
35 | 35 |
36 // gfx::GLSurface implementation | 36 // gfx::GLSurface implementation |
37 virtual bool Initialize() OVERRIDE; | 37 virtual bool Initialize() OVERRIDE; |
38 virtual void Destroy() OVERRIDE; | 38 virtual void Destroy() OVERRIDE; |
39 virtual bool IsOffscreen() OVERRIDE; | 39 virtual bool IsOffscreen() OVERRIDE; |
40 virtual bool SwapBuffers() OVERRIDE; | 40 virtual bool SwapBuffers() OVERRIDE; |
41 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 41 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
42 virtual std::string GetExtensions() OVERRIDE; | 42 virtual std::string GetExtensions() OVERRIDE; |
43 virtual void SetVisibility(VisibilityState visibility_state) OVERRIDE; | 43 virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; |
44 | 44 |
45 protected: | 45 protected: |
46 // ImageTransportSurface implementation | 46 // ImageTransportSurface implementation |
47 virtual void OnNewSurfaceACK(uint64 surface_handle, | 47 virtual void OnNewSurfaceACK(uint64 surface_handle, |
48 TransportDIB::Handle shm_handle) OVERRIDE; | 48 TransportDIB::Handle shm_handle) OVERRIDE; |
49 virtual void OnBuffersSwappedACK() OVERRIDE; | 49 virtual void OnBuffersSwappedACK() OVERRIDE; |
50 virtual void OnPostSubBufferACK() OVERRIDE; | 50 virtual void OnPostSubBufferACK() OVERRIDE; |
51 virtual void OnResizeViewACK() OVERRIDE; | 51 virtual void OnResizeViewACK() OVERRIDE; |
52 virtual void OnResize(gfx::Size size) OVERRIDE; | 52 virtual void OnResize(gfx::Size size) OVERRIDE; |
53 | 53 |
54 private: | 54 private: |
55 virtual ~PbufferImageTransportSurface(); | 55 virtual ~PbufferImageTransportSurface(); |
56 void SendBuffersSwapped(); | 56 void SendBuffersSwapped(); |
57 | 57 |
58 // Tracks the current surface visibility state. | 58 // Tracks the current buffer allocation state. |
59 VisibilityState visibility_state_; | 59 BufferAllocationState buffer_allocation_state_; |
60 | 60 |
61 // Size to resize to when the surface becomes visible. | 61 // Size to resize to when the surface becomes visible. |
62 gfx::Size visible_size_; | 62 gfx::Size visible_size_; |
63 | 63 |
64 scoped_ptr<ImageTransportHelper> helper_; | 64 scoped_ptr<ImageTransportHelper> helper_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface); | 66 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface); |
67 }; | 67 }; |
68 | 68 |
69 PbufferImageTransportSurface::PbufferImageTransportSurface( | 69 PbufferImageTransportSurface::PbufferImageTransportSurface( |
70 GpuChannelManager* manager, | 70 GpuChannelManager* manager, |
71 GpuCommandBufferStub* stub) | 71 GpuCommandBufferStub* stub) |
72 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))), | 72 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))), |
73 visibility_state_(VISIBILITY_STATE_FOREGROUND) { | 73 buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK) { |
74 helper_.reset(new ImageTransportHelper(this, | 74 helper_.reset(new ImageTransportHelper(this, |
75 manager, | 75 manager, |
76 stub, | 76 stub, |
77 gfx::kNullPluginWindow)); | 77 gfx::kNullPluginWindow)); |
78 } | 78 } |
79 | 79 |
80 PbufferImageTransportSurface::~PbufferImageTransportSurface() { | 80 PbufferImageTransportSurface::~PbufferImageTransportSurface() { |
81 Destroy(); | 81 Destroy(); |
82 } | 82 } |
83 | 83 |
(...skipping 30 matching lines...) Expand all Loading... |
114 | 114 |
115 return true; | 115 return true; |
116 } | 116 } |
117 | 117 |
118 bool PbufferImageTransportSurface::PostSubBuffer( | 118 bool PbufferImageTransportSurface::PostSubBuffer( |
119 int x, int y, int width, int height) { | 119 int x, int y, int width, int height) { |
120 NOTREACHED(); | 120 NOTREACHED(); |
121 return false; | 121 return false; |
122 } | 122 } |
123 | 123 |
124 void PbufferImageTransportSurface::SetVisibility( | 124 void PbufferImageTransportSurface::SetBufferAllocation( |
125 VisibilityState visibility_state) { | 125 BufferAllocationState state) { |
126 if (visibility_state_ == visibility_state) | 126 if (buffer_allocation_state_ == state) |
127 return; | 127 return; |
128 visibility_state_ = visibility_state; | 128 buffer_allocation_state_ = state; |
129 | 129 |
130 switch (visibility_state) { | 130 switch (state) { |
131 case VISIBILITY_STATE_FOREGROUND: | 131 case BUFFER_ALLOCATION_FRONT_AND_BACK: |
132 Resize(visible_size_); | 132 Resize(visible_size_); |
133 break; | 133 break; |
134 | 134 |
135 case VISIBILITY_STATE_BACKGROUND: | 135 case BUFFER_ALLOCATION_FRONT_ONLY: |
136 Resize(gfx::Size(1, 1)); | 136 Resize(gfx::Size(1, 1)); |
137 break; | 137 break; |
138 | 138 |
139 case VISIBILITY_STATE_HIBERNATED: | 139 case BUFFER_ALLOCATION_NONE: |
140 Resize(gfx::Size(1, 1)); | 140 Resize(gfx::Size(1, 1)); |
141 helper_->Suspend(); | 141 helper_->Suspend(); |
142 break; | 142 break; |
143 | 143 |
144 default: | 144 default: |
145 NOTREACHED(); | 145 NOTREACHED(); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 std::string PbufferImageTransportSurface::GetExtensions() { | 149 std::string PbufferImageTransportSurface::GetExtensions() { |
(...skipping 24 matching lines...) Expand all Loading... |
174 uint64 surface_handle, | 174 uint64 surface_handle, |
175 TransportDIB::Handle shm_handle) { | 175 TransportDIB::Handle shm_handle) { |
176 NOTREACHED(); | 176 NOTREACHED(); |
177 } | 177 } |
178 | 178 |
179 void PbufferImageTransportSurface::OnResizeViewACK() { | 179 void PbufferImageTransportSurface::OnResizeViewACK() { |
180 NOTREACHED(); | 180 NOTREACHED(); |
181 } | 181 } |
182 | 182 |
183 void PbufferImageTransportSurface::OnResize(gfx::Size size) { | 183 void PbufferImageTransportSurface::OnResize(gfx::Size size) { |
184 if (visibility_state_ == VISIBILITY_STATE_FOREGROUND) | 184 if (buffer_allocation_state_ == BUFFER_ALLOCATION_FRONT_AND_BACK) |
185 Resize(size); | 185 Resize(size); |
186 | 186 |
187 visible_size_ = size; | 187 visible_size_ = size; |
188 } | 188 } |
189 | 189 |
190 } // namespace anonymous | 190 } // namespace anonymous |
191 | 191 |
192 // static | 192 // static |
193 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 193 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
194 GpuChannelManager* manager, | 194 GpuChannelManager* manager, |
(...skipping 24 matching lines...) Expand all Loading... |
219 handle.transport); | 219 handle.transport); |
220 } | 220 } |
221 | 221 |
222 if (surface->Initialize()) | 222 if (surface->Initialize()) |
223 return surface; | 223 return surface; |
224 else | 224 else |
225 return NULL; | 225 return NULL; |
226 } | 226 } |
227 | 227 |
228 #endif // ENABLE_GPU | 228 #endif // ENABLE_GPU |
OLD | NEW |