| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/surface/accelerated_surface_mac.h" | 5 #include "app/surface/accelerated_surface_mac.h" |
| 6 | 6 |
| 7 #include "app/gfx/gl/gl_bindings.h" | 7 #include "app/gfx/gl/gl_bindings.h" |
| 8 #include "app/gfx/gl/gl_implementation.h" | 8 #include "app/gfx/gl/gl_implementation.h" |
| 9 #include "app/surface/io_surface_support_mac.h" | 9 #include "app/surface/io_surface_support_mac.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "gfx/rect.h" | 12 #include "gfx/rect.h" |
| 13 | 13 |
| 14 AcceleratedSurface::AcceleratedSurface() | 14 AcceleratedSurface::AcceleratedSurface() |
| 15 : allocate_fbo_(false), | 15 : io_surface_id_(0), |
| 16 allocate_fbo_(false), |
| 16 texture_(0), | 17 texture_(0), |
| 17 fbo_(0), | 18 fbo_(0), |
| 18 depth_stencil_renderbuffer_(0) { | 19 depth_stencil_renderbuffer_(0) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 bool AcceleratedSurface::Initialize(gfx::GLContext* share_context, | 22 bool AcceleratedSurface::Initialize(gfx::GLContext* share_context, |
| 22 bool allocate_fbo) { | 23 bool allocate_fbo) { |
| 23 allocate_fbo_ = allocate_fbo; | 24 allocate_fbo_ = allocate_fbo; |
| 24 | 25 |
| 25 // Ensure GL is initialized before trying to create an offscreen GL context. | 26 // Ensure GL is initialized before trying to create an offscreen GL context. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 260 } |
| 260 surface_size_ = size; | 261 surface_size_ = size; |
| 261 | 262 |
| 262 // Now send back an identifier for the IOSurface. We originally | 263 // Now send back an identifier for the IOSurface. We originally |
| 263 // intended to send back a mach port from IOSurfaceCreateMachPort | 264 // intended to send back a mach port from IOSurfaceCreateMachPort |
| 264 // but it looks like Chrome IPC would need to be modified to | 265 // but it looks like Chrome IPC would need to be modified to |
| 265 // properly send mach ports between processes. For the time being we | 266 // properly send mach ports between processes. For the time being we |
| 266 // make our IOSurfaces global and send back their identifiers. On | 267 // make our IOSurfaces global and send back their identifiers. On |
| 267 // the browser process side the identifier is reconstituted into an | 268 // the browser process side the identifier is reconstituted into an |
| 268 // IOSurface for on-screen rendering. | 269 // IOSurface for on-screen rendering. |
| 269 return io_surface_support->IOSurfaceGetID(io_surface_); | 270 io_surface_id_ = io_surface_support->IOSurfaceGetID(io_surface_); |
| 271 return io_surface_id_; |
| 272 } |
| 273 |
| 274 uint64 AcceleratedSurface::GetSurfaceId() { |
| 275 return io_surface_id_; |
| 270 } | 276 } |
| 271 | 277 |
| 272 TransportDIB::Handle AcceleratedSurface::SetTransportDIBSize( | 278 TransportDIB::Handle AcceleratedSurface::SetTransportDIBSize( |
| 273 const gfx::Size& size) { | 279 const gfx::Size& size) { |
| 274 if (surface_size_ == size) { | 280 if (surface_size_ == size) { |
| 275 // Return an invalid handle to indicate to the caller that no new backing | 281 // Return an invalid handle to indicate to the caller that no new backing |
| 276 // store allocation occurred. | 282 // store allocation occurred. |
| 277 return TransportDIB::DefaultHandleValue(); | 283 return TransportDIB::DefaultHandleValue(); |
| 278 } | 284 } |
| 279 surface_size_ = size; | 285 surface_size_ = size; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 327 } |
| 322 return transport_dib_->handle(); | 328 return transport_dib_->handle(); |
| 323 } | 329 } |
| 324 | 330 |
| 325 void AcceleratedSurface::SetTransportDIBAllocAndFree( | 331 void AcceleratedSurface::SetTransportDIBAllocAndFree( |
| 326 Callback2<size_t, TransportDIB::Handle*>::Type* allocator, | 332 Callback2<size_t, TransportDIB::Handle*>::Type* allocator, |
| 327 Callback1<TransportDIB::Id>::Type* deallocator) { | 333 Callback1<TransportDIB::Id>::Type* deallocator) { |
| 328 dib_alloc_callback_.reset(allocator); | 334 dib_alloc_callback_.reset(allocator); |
| 329 dib_free_callback_.reset(deallocator); | 335 dib_free_callback_.reset(deallocator); |
| 330 } | 336 } |
| OLD | NEW |