| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); | 157 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); |
| 158 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); | 158 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); |
| 159 if (num_planes > 1) { | 159 if (num_planes > 1) { |
| 160 CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes); | 160 CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes); |
| 161 } else { | 161 } else { |
| 162 AddIntegerValue(properties, kIOSurfaceBytesPerElement, | 162 AddIntegerValue(properties, kIOSurfaceBytesPerElement, |
| 163 BytesPerElement(format, 0)); | 163 BytesPerElement(format, 0)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 IOSurfaceRef surface = IOSurfaceCreate(properties); | 166 IOSurfaceRef surface = IOSurfaceCreate(properties); |
| 167 if (!surface) { |
| 168 LOG(ERROR) << "Failed to allocate IOSurface of size " << size.ToString() |
| 169 << "."; |
| 170 return nullptr; |
| 171 } |
| 167 | 172 |
| 168 // For unknown reasons, triggering this lock on OS X 10.9, on certain GPUs, | 173 // For unknown reasons, triggering this lock on OS X 10.9, on certain GPUs, |
| 169 // causes PDFs to render incorrectly. Hopefully this check can be removed once | 174 // causes PDFs to render incorrectly. Hopefully this check can be removed once |
| 170 // pdfium switches to a Skia backend on Mac. | 175 // pdfium switches to a Skia backend on Mac. |
| 171 // https://crbug.com/594343. | 176 // https://crbug.com/594343. |
| 172 // IOSurface clearing causes significant performance regression on about half | 177 // IOSurface clearing causes significant performance regression on about half |
| 173 // of all devices running Yosemite. https://crbug.com/606850#c22. | 178 // of all devices running Yosemite. https://crbug.com/606850#c22. |
| 174 bool should_clear = !base::mac::IsOS10_9() && !base::mac::IsOS10_10(); | 179 bool should_clear = !base::mac::IsOS10_9() && !base::mac::IsOS10_10(); |
| 175 | 180 |
| 176 if (should_clear) { | 181 if (should_clear) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // Note that nullptr is an acceptable input to IOSurfaceSetValue. | 214 // Note that nullptr is an acceptable input to IOSurfaceSetValue. |
| 210 IOSurfaceSetValue(surface, CFSTR("IOSurfaceColorSpace"), color_space_icc); | 215 IOSurfaceSetValue(surface, CFSTR("IOSurfaceColorSpace"), color_space_icc); |
| 211 } | 216 } |
| 212 | 217 |
| 213 UMA_HISTOGRAM_TIMES("GPU.IOSurface.CreateTime", | 218 UMA_HISTOGRAM_TIMES("GPU.IOSurface.CreateTime", |
| 214 base::TimeTicks::Now() - start_time); | 219 base::TimeTicks::Now() - start_time); |
| 215 return surface; | 220 return surface; |
| 216 } | 221 } |
| 217 | 222 |
| 218 } // namespace gfx | 223 } // namespace gfx |
| OLD | NEW |