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

Side by Side Diff: content/common/gpu/image_transport_surface_mac.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/mac/scoped_cftyperef.h" 9 #include "base/mac/scoped_cftyperef.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 19 matching lines...) Expand all
30 // GLSurface implementation 30 // GLSurface implementation
31 virtual bool Initialize() OVERRIDE; 31 virtual bool Initialize() OVERRIDE;
32 virtual void Destroy() OVERRIDE; 32 virtual void Destroy() OVERRIDE;
33 virtual bool IsOffscreen() OVERRIDE; 33 virtual bool IsOffscreen() OVERRIDE;
34 virtual bool SwapBuffers() OVERRIDE; 34 virtual bool SwapBuffers() OVERRIDE;
35 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 35 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
36 virtual std::string GetExtensions() OVERRIDE; 36 virtual std::string GetExtensions() OVERRIDE;
37 virtual gfx::Size GetSize() OVERRIDE; 37 virtual gfx::Size GetSize() OVERRIDE;
38 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 38 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
39 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; 39 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
40 virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; 40 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE;
41 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
41 42
42 protected: 43 protected:
43 // ImageTransportSurface implementation 44 // ImageTransportSurface implementation
44 virtual void OnNewSurfaceACK(uint64 surface_handle, 45 virtual void OnNewSurfaceACK(uint64 surface_handle,
45 TransportDIB::Handle shm_handle) OVERRIDE; 46 TransportDIB::Handle shm_handle) OVERRIDE;
46 virtual void OnBuffersSwappedACK() OVERRIDE; 47 virtual void OnBuffersSwappedACK() OVERRIDE;
47 virtual void OnPostSubBufferACK() OVERRIDE; 48 virtual void OnPostSubBufferACK() OVERRIDE;
48 virtual void OnResizeViewACK() OVERRIDE; 49 virtual void OnResizeViewACK() OVERRIDE;
49 virtual void OnResize(gfx::Size size) OVERRIDE; 50 virtual void OnResize(gfx::Size size) OVERRIDE;
50 51
51 private: 52 private:
52 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; 53 virtual ~IOSurfaceImageTransportSurface() OVERRIDE;
53 54
54 void UnrefIOSurface(); 55 void UnrefIOSurface();
55 void CreateIOSurface(); 56 void CreateIOSurface();
57 void AdjustBufferAllocations();
56 58
57 BufferAllocationState buffer_allocation_state_; 59 // Tracks the current buffer allocation state.
60 bool backbuffer_suggested_allocation_;
61 bool frontbuffer_suggested_allocation_;
58 62
59 uint32 fbo_id_; 63 uint32 fbo_id_;
60 GLuint texture_id_; 64 GLuint texture_id_;
61 65
62 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; 66 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_;
63 67
64 // The id of |io_surface_| or 0 if that's NULL. 68 // The id of |io_surface_| or 0 if that's NULL.
65 uint64 io_surface_handle_; 69 uint64 io_surface_handle_;
66 70
67 // Weak pointer to the context that this was last made current to. 71 // Weak pointer to the context that this was last made current to.
(...skipping 22 matching lines...) Expand all
90 base::mac::ScopedCFTypeRef<CFNumberRef> number( 94 base::mac::ScopedCFTypeRef<CFNumberRef> number(
91 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); 95 CFNumberCreate(NULL, kCFNumberSInt32Type, &value));
92 CFDictionaryAddValue(dictionary, key, number.get()); 96 CFDictionaryAddValue(dictionary, key, number.get());
93 } 97 }
94 98
95 IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface( 99 IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface(
96 GpuChannelManager* manager, 100 GpuChannelManager* manager,
97 GpuCommandBufferStub* stub, 101 GpuCommandBufferStub* stub,
98 gfx::PluginWindowHandle handle) 102 gfx::PluginWindowHandle handle)
99 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), 103 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)),
100 buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK), 104 backbuffer_suggested_allocation_(true),
105 frontbuffer_suggested_allocation_(true),
101 fbo_id_(0), 106 fbo_id_(0),
102 texture_id_(0), 107 texture_id_(0),
103 io_surface_handle_(0), 108 io_surface_handle_(0),
104 context_(NULL), 109 context_(NULL),
105 made_current_(false) { 110 made_current_(false) {
106 helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); 111 helper_.reset(new ImageTransportHelper(this, manager, stub, handle));
107 } 112 }
108 113
109 IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() { 114 IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() {
110 Destroy(); 115 Destroy();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 OnResize(gfx::Size(1, 1)); 156 OnResize(gfx::Size(1, 1));
152 157
153 made_current_ = true; 158 made_current_ = true;
154 return true; 159 return true;
155 } 160 }
156 161
157 unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() { 162 unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() {
158 return fbo_id_; 163 return fbo_id_;
159 } 164 }
160 165
161 void IOSurfaceImageTransportSurface::SetBufferAllocation( 166 void IOSurfaceImageTransportSurface::SetBackbufferAllocation(bool allocation) {
162 BufferAllocationState state) { 167 if (backbuffer_suggested_allocation_ == allocation)
163 if (buffer_allocation_state_ == state)
164 return; 168 return;
165 buffer_allocation_state_ = state; 169 backbuffer_suggested_allocation_ = allocation;
170 AdjustBufferAllocations();
171 }
166 172
167 switch (state) { 173 void IOSurfaceImageTransportSurface::SetFrontbufferAllocation(bool allocation) {
168 case BUFFER_ALLOCATION_FRONT_AND_BACK: 174 if (frontbuffer_suggested_allocation_ == allocation)
169 CreateIOSurface(); 175 return;
170 break; 176 frontbuffer_suggested_allocation_ = allocation;
177 AdjustBufferAllocations();
178 }
171 179
172 case BUFFER_ALLOCATION_FRONT_ONLY: 180 void IOSurfaceImageTransportSurface::AdjustBufferAllocations() {
173 break; 181 if (backbuffer_suggested_allocation_) {
174 182 CreateIOSurface();
jonathan.backer 2012/05/10 21:37:48 Should only be called for BB allocation. AFAIK, th
175 case BUFFER_ALLOCATION_NONE: 183 } else if (!frontbuffer_suggested_allocation_) {
176 UnrefIOSurface(); 184 UnrefIOSurface();
jonathan.backer 2012/05/10 21:37:48 I think that we can unref for the BB dealloc.
177 helper_->Suspend(); 185 helper_->Suspend();
jonathan.backer 2012/05/10 21:37:48 AFAIK, this causes the browser to drop the front b
jonathan.backer 2012/05/10 21:37:48 I Think that this causes FB dealloc in the browser
178 break;
179
180 default:
181 NOTREACHED();
182 } 186 }
183 } 187 }
184 188
185 bool IOSurfaceImageTransportSurface::SwapBuffers() { 189 bool IOSurfaceImageTransportSurface::SwapBuffers() {
186 glFlush(); 190 glFlush();
187 191
188 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 192 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
189 params.surface_handle = io_surface_handle_; 193 params.surface_handle = io_surface_handle_;
190 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 194 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
191 195
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 NOTREACHED(); 370 NOTREACHED();
367 return NULL; 371 return NULL;
368 } 372 }
369 if (surface->Initialize()) 373 if (surface->Initialize())
370 return surface; 374 return surface;
371 else 375 else
372 return NULL; 376 return NULL;
373 } 377 }
374 378
375 #endif // defined(USE_GPU) 379 #endif // defined(USE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698