Changeset 192284 in webkit


Ignore:
Timestamp:
Nov 10, 2015 5:31:55 PM (8 years ago)
Author:
Simon Fraser
Message:

Use different pixel formats for displays that support them
https://bugs.webkit.org/show_bug.cgi?id=151122
rdar://problem/22846841

Reviewed by Tim Horton.
Source/WebCore:

Add new IOSurface format enum values, and set up the appropriate IOSurfaceCreate()
property dictionaries for them.

  • platform/graphics/cocoa/IOSurface.h:
  • platform/graphics/cocoa/IOSurface.mm:

(IOSurface::IOSurface):

  • platform/spi/cocoa/IOSurfaceSPI.h:

Source/WebKit2:

New the new IOSurface formats when appropriate for the properties of the
display.

  • Shared/mac/RemoteLayerBackingStore.mm:

(WebKit::bufferFormat):
(WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r192281 r192284  
     12015-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
    1172015-11-10  Brent Fulgham  <bfulgham@apple.com>
    218
  • trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h

    r190587 r192284  
    4141    enum class Format {
    4242        RGBA,
    43         YUV422
     43        YUV422,
     44        RGB10,
     45        RGB10A8,
    4446    };
    4547
  • trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm

    r192138 r192284  
    105105    unsigned bytesPerPixel;
    106106    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)
    111117        bytesPerPixel = 4;
    112118        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        };
    114157    } 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        };
    120207    }
    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   
    145209    m_surface = adoptCF(IOSurfaceCreate((CFDictionaryRef)options));
     210    if (!m_surface)
     211        NSLog(@"Surface creation failed for options %@", options);
    146212}
    147213
  • trunk/Source/WebCore/platform/spi/cocoa/IOSurfaceSPI.h

    r190587 r192284  
    5959extern const CFStringRef kIOSurfaceElementWidth;
    6060extern const CFStringRef kIOSurfaceElementHeight;
     61extern const CFStringRef kIOSurfacePlaneWidth;
     62extern const CFStringRef kIOSurfacePlaneHeight;
     63extern const CFStringRef kIOSurfacePlaneBytesPerRow;
     64extern const CFStringRef kIOSurfacePlaneOffset;
     65extern const CFStringRef kIOSurfacePlaneSize;
     66extern const CFStringRef kIOSurfacePlaneInfo;
    6167
    6268size_t IOSurfaceAlignProperty(CFStringRef property, size_t value);
  • trunk/Source/WebKit2/ChangeLog

    r192280 r192284  
     12015-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
    1162015-11-10  Tim Horton  <timothy_horton@apple.com>
    217
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm

    r192140 r192284  
    4646#endif
    4747
     48#if __has_include(<WebKitAdditions/RemoteLayerBackingStoreAdditions.mm>)
     49#import <WebKitAdditions/RemoteLayerBackingStoreAdditions.mm>
     50#else
     51
     52namespace WebKit {
     53
     54#if USE(IOSURFACE)
     55static 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
    4865using namespace WebCore;
    4966
     
    187204
    188205        if (!m_frontBuffer.surface)
    189             m_frontBuffer.surface = IOSurface::create(expandedScaledSize, ColorSpaceSRGB);
     206            m_frontBuffer.surface = IOSurface::create(expandedScaledSize, ColorSpaceSRGB, bufferFormat(m_isOpaque));
    190207
    191208        setBufferVolatility(BufferType::Front, false);
    192 
    193209        return;
    194210    }
Note: See TracChangeset for help on using the changeset viewer.