Changeset 192284 in webkit
- Timestamp:
- Nov 10, 2015 5:31:55 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r192281 r192284 1 2015-11-10 Simon Fraser <simon.fraser@apple.com> 2 3 Use different pixel formats for displays that support them 4 https://bugs.webkit.org/show_bug.cgi?id=151122 5 rdar://problem/22846841 6 7 Reviewed by Tim Horton. 8 9 Add new IOSurface format enum values, and set up the appropriate IOSurfaceCreate() 10 property dictionaries for them. 11 12 * platform/graphics/cocoa/IOSurface.h: 13 * platform/graphics/cocoa/IOSurface.mm: 14 (IOSurface::IOSurface): 15 * platform/spi/cocoa/IOSurfaceSPI.h: 16 1 17 2015-11-10 Brent Fulgham <bfulgham@apple.com> 2 18 -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h
r190587 r192284 41 41 enum class Format { 42 42 RGBA, 43 YUV422 43 YUV422, 44 RGB10, 45 RGB10A8, 44 46 }; 45 47 -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm
r192138 r192284 105 105 unsigned bytesPerPixel; 106 106 unsigned bytesPerElement; 107 unsigned elementWidth; 108 109 if (format == Format::RGBA) { 110 pixelFormat = 'BGRA'; 107 108 int width = size.width(); 109 int height = size.height(); 110 111 NSDictionary *options; 112 113 if (format == Format::RGB10A8) { 114 pixelFormat = 'b3a8'; 115 116 // RGB plane (10-10-10) 111 117 bytesPerPixel = 4; 112 118 bytesPerElement = 4; 113 elementWidth = 1; 119 120 size_t rgbPlaneBytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement); 121 size_t rgbPlaneTotalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * rgbPlaneBytesPerRow); 122 123 // Alpha plane (8) 124 bytesPerElement = 1; 125 size_t alphaPlaneBytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement); 126 size_t alphaPlaneTotalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * alphaPlaneBytesPerRow); 127 128 m_totalBytes = rgbPlaneTotalBytes + alphaPlaneTotalBytes; 129 130 NSArray *planeInfo = @[ 131 @{ 132 (id)kIOSurfacePlaneWidth: @(width), 133 (id)kIOSurfacePlaneHeight: @(height), 134 (id)kIOSurfacePlaneBytesPerRow: @(rgbPlaneBytesPerRow), 135 (id)kIOSurfacePlaneOffset: @(0), 136 (id)kIOSurfacePlaneSize: @(rgbPlaneTotalBytes) 137 }, 138 @{ 139 (id)kIOSurfacePlaneWidth: @(width), 140 (id)kIOSurfacePlaneHeight: @(height), 141 (id)kIOSurfacePlaneBytesPerRow: @(alphaPlaneBytesPerRow), 142 (id)kIOSurfacePlaneOffset: @(rgbPlaneTotalBytes), 143 (id)kIOSurfacePlaneSize: @(alphaPlaneTotalBytes) 144 } 145 ]; 146 147 options = @{ 148 (id)kIOSurfaceWidth: @(width), 149 (id)kIOSurfaceHeight: @(height), 150 (id)kIOSurfacePixelFormat: @(pixelFormat), 151 (id)kIOSurfaceAllocSize: @(m_totalBytes), 152 #if PLATFORM(IOS) 153 (id)kIOSurfaceCacheMode: @(kIOMapWriteCombineCache), 154 #endif 155 (id)kIOSurfacePlaneInfo: planeInfo, 156 }; 114 157 } else { 115 ASSERT(format == Format::YUV422); 116 pixelFormat = 'yuvf'; 117 bytesPerPixel = 2; 118 elementWidth = 2; 119 bytesPerElement = 4; 158 unsigned elementWidth; 159 160 switch (format) { 161 case Format::RGBA: 162 pixelFormat = 'BGRA'; 163 bytesPerPixel = 4; 164 bytesPerElement = 4; 165 elementWidth = 1; 166 break; 167 case Format::YUV422: 168 pixelFormat = 'yuvf'; 169 bytesPerPixel = 2; 170 bytesPerElement = 4; 171 elementWidth = 2; 172 break; 173 case Format::RGB10: 174 pixelFormat = 'w30r'; 175 bytesPerPixel = 4; 176 bytesPerElement = 4; 177 elementWidth = 1; 178 break; 179 case Format::RGB10A8: 180 ASSERT_NOT_REACHED(); 181 pixelFormat = 'b3a8'; 182 bytesPerPixel = 1; 183 bytesPerElement = 1; 184 elementWidth = 1; 185 break; 186 } 187 188 size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerPixel); 189 ASSERT(bytesPerRow); 190 191 m_totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow); 192 ASSERT(m_totalBytes); 193 194 options = @{ 195 (id)kIOSurfaceWidth: @(width), 196 (id)kIOSurfaceHeight: @(height), 197 (id)kIOSurfacePixelFormat: @(pixelFormat), 198 (id)kIOSurfaceBytesPerElement: @(bytesPerElement), 199 (id)kIOSurfaceBytesPerRow: @(bytesPerRow), 200 (id)kIOSurfaceAllocSize: @(m_totalBytes), 201 #if PLATFORM(IOS) 202 (id)kIOSurfaceCacheMode: @(kIOMapWriteCombineCache), 203 #endif 204 (id)kIOSurfaceElementWidth: @(elementWidth), 205 (id)kIOSurfaceElementHeight: @(1) 206 }; 120 207 } 121 122 int width = size.width(); 123 int height = size.height(); 124 125 size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerPixel); 126 ASSERT(bytesPerRow); 127 128 m_totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow); 129 ASSERT(m_totalBytes); 130 131 NSDictionary *options = @{ 132 (id)kIOSurfaceWidth: @(width), 133 (id)kIOSurfaceHeight: @(height), 134 (id)kIOSurfacePixelFormat: @(pixelFormat), 135 (id)kIOSurfaceBytesPerElement: @(bytesPerElement), 136 (id)kIOSurfaceBytesPerRow: @(bytesPerRow), 137 (id)kIOSurfaceAllocSize: @(m_totalBytes), 138 #if PLATFORM(IOS) 139 (id)kIOSurfaceCacheMode: @(kIOMapWriteCombineCache), 140 #endif 141 (id)kIOSurfaceElementWidth: @(elementWidth), 142 (id)kIOSurfaceElementHeight: @(1) 143 }; 144 208 145 209 m_surface = adoptCF(IOSurfaceCreate((CFDictionaryRef)options)); 210 if (!m_surface) 211 NSLog(@"Surface creation failed for options %@", options); 146 212 } 147 213 -
trunk/Source/WebCore/platform/spi/cocoa/IOSurfaceSPI.h
r190587 r192284 59 59 extern const CFStringRef kIOSurfaceElementWidth; 60 60 extern const CFStringRef kIOSurfaceElementHeight; 61 extern const CFStringRef kIOSurfacePlaneWidth; 62 extern const CFStringRef kIOSurfacePlaneHeight; 63 extern const CFStringRef kIOSurfacePlaneBytesPerRow; 64 extern const CFStringRef kIOSurfacePlaneOffset; 65 extern const CFStringRef kIOSurfacePlaneSize; 66 extern const CFStringRef kIOSurfacePlaneInfo; 61 67 62 68 size_t IOSurfaceAlignProperty(CFStringRef property, size_t value); -
trunk/Source/WebKit2/ChangeLog
r192280 r192284 1 2015-11-10 Simon Fraser <simon.fraser@apple.com> 2 3 Use different pixel formats for displays that support them 4 https://bugs.webkit.org/show_bug.cgi?id=151122 5 rdar://problem/22846841 6 7 Reviewed by Tim Horton. 8 9 New the new IOSurface formats when appropriate for the properties of the 10 display. 11 12 * Shared/mac/RemoteLayerBackingStore.mm: 13 (WebKit::bufferFormat): 14 (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer): 15 1 16 2015-11-10 Tim Horton <timothy_horton@apple.com> 2 17 -
trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
r192140 r192284 46 46 #endif 47 47 48 #if __has_include(<WebKitAdditions/RemoteLayerBackingStoreAdditions.mm>) 49 #import <WebKitAdditions/RemoteLayerBackingStoreAdditions.mm> 50 #else 51 52 namespace WebKit { 53 54 #if USE(IOSURFACE) 55 static WebCore::IOSurface::Format bufferFormat(bool) 56 { 57 return WebCore::IOSurface::Format::RGBA; 58 } 59 #endif // USE(IOSURFACE) 60 61 } // namespace WebKit 62 63 #endif 64 48 65 using namespace WebCore; 49 66 … … 187 204 188 205 if (!m_frontBuffer.surface) 189 m_frontBuffer.surface = IOSurface::create(expandedScaledSize, ColorSpaceSRGB );206 m_frontBuffer.surface = IOSurface::create(expandedScaledSize, ColorSpaceSRGB, bufferFormat(m_isOpaque)); 190 207 191 208 setBufferVolatility(BufferType::Front, false); 192 193 209 return; 194 210 }
Note: See TracChangeset
for help on using the changeset viewer.