| 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" | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 117 } | 117 } | 
| 118 | 118 | 
| 119 void AcceleratedSurface::AllocateRenderBuffers(GLenum target, | 119 void AcceleratedSurface::AllocateRenderBuffers(GLenum target, | 
| 120                                                const gfx::Size& size) { | 120                                                const gfx::Size& size) { | 
| 121   if (!texture_) { | 121   if (!texture_) { | 
| 122     // Generate the texture object. | 122     // Generate the texture object. | 
| 123     glGenTextures(1, &texture_); | 123     glGenTextures(1, &texture_); | 
| 124     glBindTexture(target, texture_); | 124     glBindTexture(target, texture_); | 
| 125     glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 125     glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 
| 126     glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 126     glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 
|  | 127     glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 
|  | 128     glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 
| 127     // Generate and bind the framebuffer object. | 129     // Generate and bind the framebuffer object. | 
| 128     glGenFramebuffersEXT(1, &fbo_); | 130     glGenFramebuffersEXT(1, &fbo_); | 
| 129     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_); | 131     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_); | 
| 130     // Generate (but don't bind) the depth buffer -- we don't need | 132     // Generate (but don't bind) the depth buffer -- we don't need | 
| 131     // this bound in order to do offscreen rendering. | 133     // this bound in order to do offscreen rendering. | 
| 132     glGenRenderbuffersEXT(1, &depth_stencil_renderbuffer_); | 134     glGenRenderbuffersEXT(1, &depth_stencil_renderbuffer_); | 
| 133   } | 135   } | 
| 134 | 136 | 
| 135   // Reallocate the depth buffer. | 137   // Reallocate the depth buffer. | 
| 136   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_stencil_renderbuffer_); | 138   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_stencil_renderbuffer_); | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213   // Mac OS X and is required for IOSurface interoperability. | 215   // Mac OS X and is required for IOSurface interoperability. | 
| 214   GLenum target = GL_TEXTURE_RECTANGLE_ARB; | 216   GLenum target = GL_TEXTURE_RECTANGLE_ARB; | 
| 215   if (allocate_fbo_) { | 217   if (allocate_fbo_) { | 
| 216     AllocateRenderBuffers(target, size); | 218     AllocateRenderBuffers(target, size); | 
| 217   } else if (!texture_) { | 219   } else if (!texture_) { | 
| 218     // Generate the texture object. | 220     // Generate the texture object. | 
| 219     glGenTextures(1, &texture_); | 221     glGenTextures(1, &texture_); | 
| 220     glBindTexture(target, texture_); | 222     glBindTexture(target, texture_); | 
| 221     glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 223     glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 
| 222     glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 224     glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 
|  | 225     glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 
|  | 226     glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 
| 223   } | 227   } | 
| 224 | 228 | 
| 225   // Allocate a new IOSurface, which is the GPU resource that can be | 229   // Allocate a new IOSurface, which is the GPU resource that can be | 
| 226   // shared across processes. | 230   // shared across processes. | 
| 227   base::mac::ScopedCFTypeRef<CFMutableDictionaryRef> properties; | 231   base::mac::ScopedCFTypeRef<CFMutableDictionaryRef> properties; | 
| 228   properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, | 232   properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, | 
| 229                                              0, | 233                                              0, | 
| 230                                              &kCFTypeDictionaryKeyCallBacks, | 234                                              &kCFTypeDictionaryKeyCallBacks, | 
| 231                                              &kCFTypeDictionaryValueCallBacks)); | 235                                              &kCFTypeDictionaryValueCallBacks)); | 
| 232   AddIntegerValue(properties, | 236   AddIntegerValue(properties, | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 327   } | 331   } | 
| 328   return transport_dib_->handle(); | 332   return transport_dib_->handle(); | 
| 329 } | 333 } | 
| 330 | 334 | 
| 331 void AcceleratedSurface::SetTransportDIBAllocAndFree( | 335 void AcceleratedSurface::SetTransportDIBAllocAndFree( | 
| 332     Callback2<size_t, TransportDIB::Handle*>::Type* allocator, | 336     Callback2<size_t, TransportDIB::Handle*>::Type* allocator, | 
| 333     Callback1<TransportDIB::Id>::Type* deallocator) { | 337     Callback1<TransportDIB::Id>::Type* deallocator) { | 
| 334   dib_alloc_callback_.reset(allocator); | 338   dib_alloc_callback_.reset(allocator); | 
| 335   dib_free_callback_.reset(deallocator); | 339   dib_free_callback_.reset(deallocator); | 
| 336 } | 340 } | 
| OLD | NEW | 
|---|