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

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: Caching size in EGL (compiles, not tested), and DCHECKS to win (not tested). 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();
59 void AdjustBufferAllocations();
58 60
59 // Tracks the current buffer allocation state. 61 // Tracks the current buffer allocation state.
60 BufferAllocationState buffer_allocation_state_; 62 bool backbuffer_suggested_allocation_;
63 bool frontbuffer_suggested_allocation_;
61 64
62 // Size to resize to when the surface becomes visible. 65 // Size to resize to when the surface becomes visible.
63 gfx::Size visible_size_; 66 gfx::Size visible_size_;
64 67
65 scoped_ptr<ImageTransportHelper> helper_; 68 scoped_ptr<ImageTransportHelper> helper_;
66 69
67 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface); 70 DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface);
68 }; 71 };
69 72
70 PbufferImageTransportSurface::PbufferImageTransportSurface( 73 PbufferImageTransportSurface::PbufferImageTransportSurface(
71 GpuChannelManager* manager, 74 GpuChannelManager* manager,
72 GpuCommandBufferStub* stub) 75 GpuCommandBufferStub* stub)
73 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))), 76 : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))),
74 buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK) { 77 backbuffer_suggested_allocation_(true),
78 frontbuffer_suggested_allocation_(true) {
75 helper_.reset(new ImageTransportHelper(this, 79 helper_.reset(new ImageTransportHelper(this,
76 manager, 80 manager,
77 stub, 81 stub,
78 gfx::kNullPluginWindow)); 82 gfx::kNullPluginWindow));
79 } 83 }
80 84
81 PbufferImageTransportSurface::~PbufferImageTransportSurface() { 85 PbufferImageTransportSurface::~PbufferImageTransportSurface() {
82 Destroy(); 86 Destroy();
83 } 87 }
84 88
(...skipping 30 matching lines...) Expand all
115 119
116 return true; 120 return true;
117 } 121 }
118 122
119 bool PbufferImageTransportSurface::PostSubBuffer( 123 bool PbufferImageTransportSurface::PostSubBuffer(
120 int x, int y, int width, int height) { 124 int x, int y, int width, int height) {
121 NOTREACHED(); 125 NOTREACHED();
122 return false; 126 return false;
123 } 127 }
124 128
125 void PbufferImageTransportSurface::SetBufferAllocation( 129 void PbufferImageTransportSurface::SetBackbufferAllocation(bool allocation) {
126 BufferAllocationState state) { 130 if (backbuffer_suggested_allocation_ == allocation)
127 if (buffer_allocation_state_ == state)
128 return; 131 return;
129 buffer_allocation_state_ = state; 132 backbuffer_suggested_allocation_ = allocation;
jonathan.backer 2012/05/10 21:37:48 Resize here accordingly.
133 AdjustBufferAllocations();
134 }
130 135
131 switch (state) { 136 void PbufferImageTransportSurface::SetFrontbufferAllocation(bool allocation) {
132 case BUFFER_ALLOCATION_FRONT_AND_BACK: 137 if (frontbuffer_suggested_allocation_ == allocation)
133 Resize(visible_size_); 138 return;
134 break; 139 frontbuffer_suggested_allocation_ = allocation;
140 AdjustBufferAllocations();
jonathan.backer 2012/05/10 21:37:48 Suspend here accordingly.
141 }
135 142
136 case BUFFER_ALLOCATION_FRONT_ONLY: 143 void PbufferImageTransportSurface::AdjustBufferAllocations() {
jonathan.backer 2012/05/10 21:37:48 nix this.
137 Resize(gfx::Size(1, 1)); 144 if (backbuffer_suggested_allocation_) {
138 break; 145 Resize(visible_size_);
139 146 } else {
140 case BUFFER_ALLOCATION_NONE: 147 Resize(gfx::Size(1, 1));
141 Resize(gfx::Size(1, 1)); 148 if (!frontbuffer_suggested_allocation_)
142 helper_->Suspend(); 149 helper_->Suspend();
143 break;
144
145 default:
146 NOTREACHED();
147 } 150 }
148 DestroySurface(); 151 DestroySurface();
149 } 152 }
150 153
151 void PbufferImageTransportSurface::DestroySurface() { 154 void PbufferImageTransportSurface::DestroySurface() {
152 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 155 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
153 helper_->SendAcceleratedSurfaceRelease(params); 156 helper_->SendAcceleratedSurfaceRelease(params);
154 } 157 }
155 158
156 std::string PbufferImageTransportSurface::GetExtensions() { 159 std::string PbufferImageTransportSurface::GetExtensions() {
(...skipping 24 matching lines...) Expand all
181 uint64 surface_handle, 184 uint64 surface_handle,
182 TransportDIB::Handle shm_handle) { 185 TransportDIB::Handle shm_handle) {
183 NOTREACHED(); 186 NOTREACHED();
184 } 187 }
185 188
186 void PbufferImageTransportSurface::OnResizeViewACK() { 189 void PbufferImageTransportSurface::OnResizeViewACK() {
187 NOTREACHED(); 190 NOTREACHED();
188 } 191 }
189 192
190 void PbufferImageTransportSurface::OnResize(gfx::Size size) { 193 void PbufferImageTransportSurface::OnResize(gfx::Size size) {
191 if (buffer_allocation_state_ == BUFFER_ALLOCATION_FRONT_AND_BACK) 194 DCHECK(backbuffer_suggested_allocation_);
192 Resize(size); 195 DCHECK(frontbuffer_suggested_allocation_);
196 Resize(size);
193 197
194 DestroySurface(); 198 DestroySurface();
195 199
196 visible_size_ = size; 200 visible_size_ = size;
197 } 201 }
198 202
199 } // namespace anonymous 203 } // namespace anonymous
200 204
201 // static 205 // static
202 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( 206 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
(...skipping 25 matching lines...) Expand all
228 handle.transport); 232 handle.transport);
229 } 233 }
230 234
231 if (surface->Initialize()) 235 if (surface->Initialize())
232 return surface; 236 return surface;
233 else 237 else
234 return NULL; 238 return NULL;
235 } 239 }
236 240
237 #endif // ENABLE_GPU 241 #endif // ENABLE_GPU
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698