OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/common/gpu/image_transport_surface_fbo_mac.h" | 5 #include "content/common/gpu/image_transport_surface_fbo_mac.h" |
6 | 6 |
7 #include "content/common/gpu/gpu_messages.h" | 7 #include "content/common/gpu/gpu_messages.h" |
| 8 #include "content/common/gpu/image_transport_surface_calayer_mac.h" |
8 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" | 9 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" |
9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
10 #include "ui/gl/gl_context.h" | 11 #include "ui/gl/gl_context.h" |
11 #include "ui/gl/gl_implementation.h" | 12 #include "ui/gl/gl_implementation.h" |
12 #include "ui/gl/gl_surface_osmesa.h" | 13 #include "ui/gl/gl_surface_osmesa.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 ImageTransportSurfaceFBO::ImageTransportSurfaceFBO( | 17 ImageTransportSurfaceFBO::ImageTransportSurfaceFBO( |
17 StorageProvider* storage_provider, | |
18 GpuChannelManager* manager, | 18 GpuChannelManager* manager, |
19 GpuCommandBufferStub* stub, | 19 GpuCommandBufferStub* stub, |
20 gfx::PluginWindowHandle handle) | 20 gfx::PluginWindowHandle handle) |
21 : storage_provider_(storage_provider), | 21 : backbuffer_suggested_allocation_(true), |
22 backbuffer_suggested_allocation_(true), | |
23 frontbuffer_suggested_allocation_(true), | 22 frontbuffer_suggested_allocation_(true), |
24 fbo_id_(0), | 23 fbo_id_(0), |
25 texture_id_(0), | 24 texture_id_(0), |
26 depth_stencil_renderbuffer_id_(0), | 25 depth_stencil_renderbuffer_id_(0), |
27 has_complete_framebuffer_(false), | 26 has_complete_framebuffer_(false), |
28 context_(NULL), | 27 context_(NULL), |
29 scale_factor_(1.f), | 28 scale_factor_(1.f), |
30 made_current_(false), | 29 made_current_(false), |
31 is_swap_buffers_pending_(false), | 30 is_swap_buffers_pending_(false), |
32 did_unschedule_(false) { | 31 did_unschedule_(false) { |
| 32 // TODO(ccameron): If the remote layer API is supported on this system, |
| 33 // use a CALayerStorageProvider instead of an IOSurfaceStorageProvider. |
| 34 storage_provider_.reset(new IOSurfaceStorageProvider(this)); |
33 helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); | 35 helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); |
34 } | 36 } |
35 | 37 |
36 ImageTransportSurfaceFBO::~ImageTransportSurfaceFBO() { | 38 ImageTransportSurfaceFBO::~ImageTransportSurfaceFBO() { |
37 } | 39 } |
38 | 40 |
39 bool ImageTransportSurfaceFBO::Initialize() { | 41 bool ImageTransportSurfaceFBO::Initialize() { |
40 // Only support IOSurfaces if the GL implementation is the native desktop GL. | 42 // Only support IOSurfaces if the GL implementation is the native desktop GL. |
41 // IO surfaces will not work with, for example, OSMesa software renderer | 43 // IO surfaces will not work with, for example, OSMesa software renderer |
42 // GL contexts. | 44 // GL contexts. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 137 |
136 DCHECK(!is_swap_buffers_pending_); | 138 DCHECK(!is_swap_buffers_pending_); |
137 is_swap_buffers_pending_ = true; | 139 is_swap_buffers_pending_ = true; |
138 | 140 |
139 storage_provider_->WillSwapBuffers(); | 141 storage_provider_->WillSwapBuffers(); |
140 return true; | 142 return true; |
141 } | 143 } |
142 | 144 |
143 bool ImageTransportSurfaceFBO::PostSubBuffer( | 145 bool ImageTransportSurfaceFBO::PostSubBuffer( |
144 int x, int y, int width, int height) { | 146 int x, int y, int width, int height) { |
145 DCHECK(backbuffer_suggested_allocation_); | 147 // Mac does not support sub-buffer swaps. |
146 if (!frontbuffer_suggested_allocation_) | 148 NOTREACHED(); |
147 return true; | 149 return false; |
148 glFlush(); | |
149 | |
150 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | |
151 params.surface_handle = storage_provider_->GetSurfaceHandle(); | |
152 params.x = x; | |
153 params.y = y; | |
154 params.width = width; | |
155 params.height = height; | |
156 params.surface_size = GetSize(); | |
157 params.surface_scale_factor = scale_factor_; | |
158 params.latency_info.swap(latency_info_); | |
159 helper_->SendAcceleratedSurfacePostSubBuffer(params); | |
160 | |
161 DCHECK(!is_swap_buffers_pending_); | |
162 is_swap_buffers_pending_ = true; | |
163 | |
164 storage_provider_->WillSwapBuffers(); | |
165 return true; | |
166 } | 150 } |
167 | 151 |
168 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { | 152 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { |
169 return true; | 153 return true; |
170 } | 154 } |
171 | 155 |
172 gfx::Size ImageTransportSurfaceFBO::GetSize() { | 156 gfx::Size ImageTransportSurfaceFBO::GetSize() { |
173 return size_; | 157 return size_; |
174 } | 158 } |
175 | 159 |
176 void* ImageTransportSurfaceFBO::GetHandle() { | 160 void* ImageTransportSurfaceFBO::GetHandle() { |
177 return NULL; | 161 return NULL; |
178 } | 162 } |
179 | 163 |
180 void* ImageTransportSurfaceFBO::GetDisplay() { | 164 void* ImageTransportSurfaceFBO::GetDisplay() { |
181 return NULL; | 165 return NULL; |
182 } | 166 } |
183 | 167 |
184 void ImageTransportSurfaceFBO::OnBufferPresented( | 168 void ImageTransportSurfaceFBO::OnBufferPresented( |
185 const AcceleratedSurfaceMsg_BufferPresented_Params& params) { | 169 const AcceleratedSurfaceMsg_BufferPresented_Params& params) { |
| 170 context_->share_group()->SetRendererID(params.renderer_id); |
| 171 storage_provider_->CanFreeSwappedBuffer(); |
| 172 } |
| 173 |
| 174 void ImageTransportSurfaceFBO::UnblockContextAfterPendingSwap() { |
186 DCHECK(is_swap_buffers_pending_); | 175 DCHECK(is_swap_buffers_pending_); |
187 | |
188 context_->share_group()->SetRendererID(params.renderer_id); | |
189 is_swap_buffers_pending_ = false; | 176 is_swap_buffers_pending_ = false; |
190 if (did_unschedule_) { | 177 if (did_unschedule_) { |
191 did_unschedule_ = false; | 178 did_unschedule_ = false; |
192 helper_->SetScheduled(true); | 179 helper_->SetScheduled(true); |
193 } | 180 } |
194 } | 181 } |
195 | 182 |
196 void ImageTransportSurfaceFBO::OnResize(gfx::Size size, | 183 void ImageTransportSurfaceFBO::OnResize(gfx::Size size, |
197 float scale_factor) { | 184 float scale_factor) { |
198 // This trace event is used in gpu_feature_browsertest.cc - the test will need | 185 // This trace event is used in gpu_feature_browsertest.cc - the test will need |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 return; | 327 return; |
341 } | 328 } |
342 | 329 |
343 has_complete_framebuffer_ = true; | 330 has_complete_framebuffer_ = true; |
344 | 331 |
345 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id); | 332 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id); |
346 // The FBO remains bound for this GL context. | 333 // The FBO remains bound for this GL context. |
347 } | 334 } |
348 | 335 |
349 } // namespace content | 336 } // namespace content |
OLD | NEW |