Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/gfx/mac/io_surface.h" | 5 #include "ui/gfx/mac/io_surface.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); | 141 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); |
| 142 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); | 142 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); |
| 143 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); | 143 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); |
| 144 if (num_planes > 1) { | 144 if (num_planes > 1) { |
| 145 CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes); | 145 CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes); |
| 146 } else { | 146 } else { |
| 147 AddIntegerValue(properties, kIOSurfaceBytesPerElement, | 147 AddIntegerValue(properties, kIOSurfaceBytesPerElement, |
| 148 BytesPerElement(format, 0)); | 148 BytesPerElement(format, 0)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 return IOSurfaceCreate(properties); | 151 IOSurfaceRef surface = IOSurfaceCreate(properties); |
| 152 | |
| 153 // Zero-initialize the texture. | |
| 154 // https://code.google.com/p/chromium/issues/detail?id=584760#c17 | |
|
reveman
2016/02/17 18:37:37
This bug cannot be accessed outside google. Can we
erikchen
2016/02/17 18:51:15
Done.
| |
| 155 IOReturn r = IOSurfaceLock(surface, kIOSurfaceLockAvoidSync, NULL); | |
|
reveman
2016/02/17 18:37:37
I feel like I might have asked this before so sorr
erikchen
2016/02/17 18:51:15
Done.
| |
| 156 DCHECK(r == kIOReturnSuccess || r == kIOReturnCannotLock); | |
| 157 if (r == kIOReturnSuccess) { | |
| 158 IOSurfaceUnlock(surface, kIOSurfaceLockAvoidSync, NULL); | |
|
reveman
2016/02/17 18:37:37
nit: nullptr here and above
erikchen
2016/02/17 18:51:15
Done.
| |
| 159 } else { | |
| 160 r = IOSurfaceLock(surface, 0, nullptr); | |
| 161 DCHECK_EQ(kIOReturnSuccess, r); | |
| 162 r = IOSurfaceUnlock(surface, 0, nullptr); | |
| 163 DCHECK_EQ(kIOReturnSuccess, r); | |
| 164 } | |
| 165 | |
| 166 return surface; | |
| 152 } | 167 } |
| 153 | 168 |
| 154 } // namespace gfx | 169 } // namespace gfx |
| OLD | NEW |