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

Side by Side Diff: content/common/gpu/image_transport_surface_win.cc

Issue 10388010: Decoupling backbuffer allocation suggestion from frontbuffer allocation suggestion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updating all platforms to really decouple the two allocations by not using a shared AdjustBufferAll… Created 8 years, 7 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
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 #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
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 SetBufferAllocation(BufferAllocationState state) OVERRIDE; 43 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE;
44 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
44 45
45 protected: 46 protected:
46 // ImageTransportSurface implementation 47 // ImageTransportSurface implementation
47 virtual void OnNewSurfaceACK(uint64 surface_handle, 48 virtual void OnNewSurfaceACK(uint64 surface_handle,
48 TransportDIB::Handle shm_handle) OVERRIDE; 49 TransportDIB::Handle shm_handle) OVERRIDE;
49 virtual void OnBuffersSwappedACK() OVERRIDE; 50 virtual void OnBuffersSwappedACK() OVERRIDE;
50 virtual void OnPostSubBufferACK() OVERRIDE; 51 virtual void OnPostSubBufferACK() OVERRIDE;
51 virtual void OnResizeViewACK() OVERRIDE; 52 virtual void OnResizeViewACK() OVERRIDE;
52 virtual void OnResize(gfx::Size size) OVERRIDE; 53 virtual void OnResize(gfx::Size size) OVERRIDE;
53 54
54 private: 55 private:
55 virtual ~PbufferImageTransportSurface(); 56 virtual ~PbufferImageTransportSurface();
56 void SendBuffersSwapped(); 57 void SendBuffersSwapped();
57 void DestroySurface(); 58 void DestroySurface();
58 59
59 // Tracks the current buffer allocation state. 60 // Tracks the current buffer allocation state.
60 BufferAllocationState buffer_allocation_state_; 61 bool backbuffer_suggested_allocation_;
62 bool frontbuffer_suggested_allocation_;
61 63
62 // Size to resize to when the surface becomes visible. 64 // Size to resize to when the surface becomes visible.
63 gfx::Size visible_size_; 65 gfx::Size visible_size_;
64 66
65 scoped_ptr<ImageTransportHelper> helper_; 67 scoped_ptr<ImageTransportHelper> helper_;
66 68
67 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface); 69 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface);
68 }; 70 };
69 71
70 PbufferImageTransportSurface::PbufferImageTransportSurface( 72 PbufferImageTransportSurface::PbufferImageTransportSurface(
71 GpuChannelManager* manager, 73 GpuChannelManager* manager,
72 GpuCommandBufferStub* stub) 74 GpuCommandBufferStub* stub)
73 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))), 75 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))),
74 buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK) { 76 backbuffer_suggested_allocation_(true),
77 frontbuffer_suggested_allocation_(true) {
75 helper_.reset(new ImageTransportHelper(this, 78 helper_.reset(new ImageTransportHelper(this,
76 manager, 79 manager,
77 stub, 80 stub,
78 gfx::kNullPluginWindow)); 81 gfx::kNullPluginWindow));
79 } 82 }
80 83
81 PbufferImageTransportSurface::~PbufferImageTransportSurface() { 84 PbufferImageTransportSurface::~PbufferImageTransportSurface() {
82 Destroy(); 85 Destroy();
83 } 86 }
84 87
(...skipping 30 matching lines...) Expand all
115 118
116 return true; 119 return true;
117 } 120 }
118 121
119 bool PbufferImageTransportSurface::PostSubBuffer( 122 bool PbufferImageTransportSurface::PostSubBuffer(
120 int x, int y, int width, int height) { 123 int x, int y, int width, int height) {
121 NOTREACHED(); 124 NOTREACHED();
122 return false; 125 return false;
123 } 126 }
124 127
125 void PbufferImageTransportSurface::SetBufferAllocation( 128 void PbufferImageTransportSurface::SetBackbufferAllocation(bool allocation) {
126 BufferAllocationState state) { 129 if (backbuffer_suggested_allocation_ == allocation)
127 if (buffer_allocation_state_ == state)
128 return; 130 return;
129 buffer_allocation_state_ = state; 131 backbuffer_suggested_allocation_ = allocation;
130 132
131 switch (state) { 133 if (backbuffer_suggested_allocation_)
132 case BUFFER_ALLOCATION_FRONT_AND_BACK: 134 Resize(visible_size_);
133 Resize(visible_size_); 135 else
134 break; 136 Resize(gfx::Size(1, 1));
135
136 case BUFFER_ALLOCATION_FRONT_ONLY:
137 Resize(gfx::Size(1, 1));
138 break;
139
140 case BUFFER_ALLOCATION_NONE:
141 Resize(gfx::Size(1, 1));
142 helper_->Suspend();
143 break;
144
145 default:
146 NOTREACHED();
147 }
148 DestroySurface(); 137 DestroySurface();
149 } 138 }
150 139
140 void PbufferImageTransportSurface::SetFrontbufferAllocation(bool allocation) {
141 if (frontbuffer_suggested_allocation_ == allocation)
142 return;
143 frontbuffer_suggested_allocation_ = allocation;
144
145 // We recreate frontbuffer by recreating backbuffer and swapping.
146 // But we release frontbuffer by telling UI to release its handle on it.
147 if (!frontbuffer_suggested_allocation_)
148 helper_->Suspend();
149 }
150
151 void PbufferImageTransportSurface::DestroySurface() { 151 void PbufferImageTransportSurface::DestroySurface() {
152 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 152 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
153 helper_->SendAcceleratedSurfaceRelease(params); 153 helper_->SendAcceleratedSurfaceRelease(params);
154 } 154 }
155 155
156 std::string PbufferImageTransportSurface::GetExtensions() { 156 std::string PbufferImageTransportSurface::GetExtensions() {
157 std::string extensions = gfx::GLSurface::GetExtensions(); 157 std::string extensions = gfx::GLSurface::GetExtensions();
158 extensions += extensions.empty() ? "" : " "; 158 extensions += extensions.empty() ? "" : " ";
159 extensions += "GL_CHROMIUM_front_buffer_cached"; 159 extensions += "GL_CHROMIUM_front_buffer_cached";
160 return extensions; 160 return extensions;
(...skipping 20 matching lines...) Expand all
181 uint64 surface_handle, 181 uint64 surface_handle,
182 TransportDIB::Handle shm_handle) { 182 TransportDIB::Handle shm_handle) {
183 NOTREACHED(); 183 NOTREACHED();
184 } 184 }
185 185
186 void PbufferImageTransportSurface::OnResizeViewACK() { 186 void PbufferImageTransportSurface::OnResizeViewACK() {
187 NOTREACHED(); 187 NOTREACHED();
188 } 188 }
189 189
190 void PbufferImageTransportSurface::OnResize(gfx::Size size) { 190 void PbufferImageTransportSurface::OnResize(gfx::Size size) {
191 if (buffer_allocation_state_ == BUFFER_ALLOCATION_FRONT_AND_BACK) 191 DCHECK(backbuffer_suggested_allocation_);
192 Resize(size); 192 DCHECK(frontbuffer_suggested_allocation_);
193 Resize(size);
193 194
194 DestroySurface(); 195 DestroySurface();
195 196
196 visible_size_ = size; 197 visible_size_ = size;
197 } 198 }
198 199
199 } // namespace anonymous 200 } // namespace anonymous
200 201
201 // static 202 // static
202 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( 203 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
(...skipping 25 matching lines...) Expand all
228 handle.transport); 229 handle.transport);
229 } 230 }
230 231
231 if (surface->Initialize()) 232 if (surface->Initialize())
232 return surface; 233 return surface;
233 else 234 else
234 return NULL; 235 return NULL;
235 } 236 }
236 237
237 #endif // ENABLE_GPU 238 #endif // ENABLE_GPU
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698