OLD | NEW |
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 #include "ui/surface/accelerated_surface_mac.h" | 5 #include "ui/surface/accelerated_surface_mac.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 static void AddBooleanValue(CFMutableDictionaryRef dictionary, | 109 static void AddBooleanValue(CFMutableDictionaryRef dictionary, |
110 const CFStringRef key, | 110 const CFStringRef key, |
111 bool value) { | 111 bool value) { |
112 CFDictionaryAddValue(dictionary, key, | 112 CFDictionaryAddValue(dictionary, key, |
113 (value ? kCFBooleanTrue : kCFBooleanFalse)); | 113 (value ? kCFBooleanTrue : kCFBooleanFalse)); |
114 } | 114 } |
115 | 115 |
116 static void AddIntegerValue(CFMutableDictionaryRef dictionary, | 116 static void AddIntegerValue(CFMutableDictionaryRef dictionary, |
117 const CFStringRef key, | 117 const CFStringRef key, |
118 int32 value) { | 118 int32 value) { |
119 base::mac::ScopedCFTypeRef<CFNumberRef> number( | 119 base::ScopedCFTypeRef<CFNumberRef> number( |
120 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); | 120 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); |
121 CFDictionaryAddValue(dictionary, key, number.get()); | 121 CFDictionaryAddValue(dictionary, key, number.get()); |
122 } | 122 } |
123 | 123 |
124 // Creates a new OpenGL texture object bound to the given texture target. | 124 // Creates a new OpenGL texture object bound to the given texture target. |
125 // Caller owns the returned texture. | 125 // Caller owns the returned texture. |
126 static GLuint CreateTexture(GLenum target) { | 126 static GLuint CreateTexture(GLenum target) { |
127 GLuint texture = 0; | 127 GLuint texture = 0; |
128 glGenTextures(1, &texture); | 128 glGenTextures(1, &texture); |
129 glBindTexture(target, texture); | 129 glBindTexture(target, texture); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 GLenum target = GL_TEXTURE_RECTANGLE_ARB; | 208 GLenum target = GL_TEXTURE_RECTANGLE_ARB; |
209 if (allocate_fbo_) { | 209 if (allocate_fbo_) { |
210 AllocateRenderBuffers(target, clamped_size); | 210 AllocateRenderBuffers(target, clamped_size); |
211 } else if (!texture_) { | 211 } else if (!texture_) { |
212 // Generate the texture object. | 212 // Generate the texture object. |
213 texture_ = CreateTexture(target); | 213 texture_ = CreateTexture(target); |
214 } | 214 } |
215 | 215 |
216 // Allocate a new IOSurface, which is the GPU resource that can be | 216 // Allocate a new IOSurface, which is the GPU resource that can be |
217 // shared across processes. | 217 // shared across processes. |
218 base::mac::ScopedCFTypeRef<CFMutableDictionaryRef> properties; | 218 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; |
219 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, | 219 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, |
220 0, | 220 0, |
221 &kCFTypeDictionaryKeyCallBacks, | 221 &kCFTypeDictionaryKeyCallBacks, |
222 &kCFTypeDictionaryValueCallBacks)); | 222 &kCFTypeDictionaryValueCallBacks)); |
223 AddIntegerValue(properties, | 223 AddIntegerValue(properties, |
224 io_surface_support->GetKIOSurfaceWidth(), | 224 io_surface_support->GetKIOSurfaceWidth(), |
225 clamped_size.width()); | 225 clamped_size.width()); |
226 AddIntegerValue(properties, | 226 AddIntegerValue(properties, |
227 io_surface_support->GetKIOSurfaceHeight(), | 227 io_surface_support->GetKIOSurfaceHeight(), |
228 clamped_size.height()); | 228 clamped_size.height()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // make our IOSurfaces global and send back their identifiers. On | 266 // make our IOSurfaces global and send back their identifiers. On |
267 // the browser process side the identifier is reconstituted into an | 267 // the browser process side the identifier is reconstituted into an |
268 // IOSurface for on-screen rendering. | 268 // IOSurface for on-screen rendering. |
269 io_surface_id_ = io_surface_support->IOSurfaceGetID(io_surface_); | 269 io_surface_id_ = io_surface_support->IOSurfaceGetID(io_surface_); |
270 return io_surface_id_; | 270 return io_surface_id_; |
271 } | 271 } |
272 | 272 |
273 uint32 AcceleratedSurface::GetSurfaceId() { | 273 uint32 AcceleratedSurface::GetSurfaceId() { |
274 return io_surface_id_; | 274 return io_surface_id_; |
275 } | 275 } |
OLD | NEW |