Index: ui/gfx/mac/io_surface.cc |
diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc |
index 8c748bca1846623b73902095adf8688df99598e8..bcf197591616f4ee1ad9f9ba5b6b42e42097b111 100644 |
--- a/ui/gfx/mac/io_surface.cc |
+++ b/ui/gfx/mac/io_surface.cc |
@@ -148,7 +148,22 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, gfx::BufferFormat format) { |
BytesPerElement(format, 0)); |
} |
- return IOSurfaceCreate(properties); |
+ IOSurfaceRef surface = IOSurfaceCreate(properties); |
+ |
+ // Zero-initialize the texture. |
+ // 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.
|
+ 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.
|
+ DCHECK(r == kIOReturnSuccess || r == kIOReturnCannotLock); |
+ if (r == kIOReturnSuccess) { |
+ IOSurfaceUnlock(surface, kIOSurfaceLockAvoidSync, NULL); |
reveman
2016/02/17 18:37:37
nit: nullptr here and above
erikchen
2016/02/17 18:51:15
Done.
|
+ } else { |
+ r = IOSurfaceLock(surface, 0, nullptr); |
+ DCHECK_EQ(kIOReturnSuccess, r); |
+ r = IOSurfaceUnlock(surface, 0, nullptr); |
+ DCHECK_EQ(kIOReturnSuccess, r); |
+ } |
+ |
+ return surface; |
} |
} // namespace gfx |