Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move extended color detection into Open Source
https://bugs.webkit.org/show_bug.cgi?id=155909
<rdar://problem/25369754>

Reviewed by Anders Carlsson.

The code for detecting extended color displays
was hidden while the iPad Pro 9.7" was in development.
Now it is public, move the detection to Open Source.

While doing this, add a new method to PlatformScreen
so that we have a more obvious way to detect such
displays.

Source/WebCore:

* platform/PlatformScreen.h: Add screenSupportsExtendedColor.

* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(PlatformCALayerCocoa::commonInit): Set the backing
store format to the RGBA10XR if we're on an extended
display.
* platform/ios/LegacyTileGridTile.mm:
(WebCore::LegacyTileGridTile::LegacyTileGridTile): Ditto.
(WebCore::setBackingStoreFormat): Deleted. Now set directly
in the constructor.

* platform/ios/PlatformScreenIOS.mm:
(WebCore::screenDepthPerComponent): Cleanup.
(WebCore::screenSupportsExtendedColor): Implement the
iOS version of this using MobileGestalt.

* platform/mac/PlatformScreenMac.mm:
(WebCore::displayFromWidget): Whitespace cleanup.
(WebCore::screenForWidget):
(WebCore::screenForWindow):
(WebCore::screenSupportsExtendedColor): Default implementation
returns false for all screens at the moment.

* platform/spi/cocoa/QuartzCoreSPI.h: New constant.
* platform/spi/ios/MobileGestaltSPI.h: Ditto.

Source/WebKit2:

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::bufferFormat): No need to use WebKitAdditions any
more.

Canonical link: https://commits.webkit.org/174023@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
grorg committed Mar 26, 2016
1 parent 598b62e commit 57c1cf7
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 41 deletions.
42 changes: 42 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,45 @@
2016-03-25 Dean Jackson <dino@apple.com>

Move extended color detection into Open Source
https://bugs.webkit.org/show_bug.cgi?id=155909
<rdar://problem/25369754>

Reviewed by Anders Carlsson.

The code for detecting extended color displays
was hidden while the iPad Pro 9.7" was in development.
Now it is public, move the detection to Open Source.

While doing this, add a new method to PlatformScreen
so that we have a more obvious way to detect such
displays.

* platform/PlatformScreen.h: Add screenSupportsExtendedColor.

* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(PlatformCALayerCocoa::commonInit): Set the backing
store format to the RGBA10XR if we're on an extended
display.
* platform/ios/LegacyTileGridTile.mm:
(WebCore::LegacyTileGridTile::LegacyTileGridTile): Ditto.
(WebCore::setBackingStoreFormat): Deleted. Now set directly
in the constructor.

* platform/ios/PlatformScreenIOS.mm:
(WebCore::screenDepthPerComponent): Cleanup.
(WebCore::screenSupportsExtendedColor): Implement the
iOS version of this using MobileGestalt.

* platform/mac/PlatformScreenMac.mm:
(WebCore::displayFromWidget): Whitespace cleanup.
(WebCore::screenForWidget):
(WebCore::screenForWindow):
(WebCore::screenSupportsExtendedColor): Default implementation
returns false for all screens at the moment.

* platform/spi/cocoa/QuartzCoreSPI.h: New constant.
* platform/spi/ios/MobileGestaltSPI.h: Ditto.

2016-03-26 Myles C. Maxfield <mmaxfield@apple.com>

[OS X] Layout sometimes flakily assumes overlay scrollbars when clicky-scroll-wheel-mouse is attached and system preference detects scrollbar mode
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/platform/PlatformScreen.h
Expand Up @@ -63,6 +63,8 @@ namespace WebCore {
FloatRect screenRect(Widget*);
FloatRect screenAvailableRect(Widget*);

WEBCORE_EXPORT bool screenSupportsExtendedColor();

#if PLATFORM(MAC)
NSScreen *screenForWindow(NSWindow *);
NSScreen *screenForDisplayID(PlatformDisplayID);
Expand Down
19 changes: 7 additions & 12 deletions Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
Expand Up @@ -33,6 +33,7 @@
#import "LengthFunctions.h"
#import "PlatformCAAnimationCocoa.h"
#import "PlatformCAFilters.h"
#import "PlatformScreen.h"
#import "QuartzCoreSPI.h"
#import "ScrollbarThemeMac.h"
#import "SoftLinking.h"
Expand All @@ -59,16 +60,6 @@
#import "ThemeMac.h"
#endif

#if USE(APPLE_INTERNAL_SDK)
#import <WebKitAdditions/LayerBackingStoreAdditions.mm>
#else
namespace WebCore {
static void setBackingStoreFormat(CALayer *)
{
}
} // namespace WebCore
#endif

SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)

SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
Expand Down Expand Up @@ -301,8 +292,12 @@ - (void)setOwner:(PlatformCALayer*)owner
else
[m_layer setDelegate:[WebActionDisablingCALayerDelegate shared]];

if (m_layerType == LayerTypeWebLayer || m_layerType == LayerTypeTiledBackingTileLayer)
setBackingStoreFormat(m_layer.get());
if (m_layerType == LayerTypeWebLayer || m_layerType == LayerTypeTiledBackingTileLayer) {
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
if (screenSupportsExtendedColor())
[m_layer setContentsFormat:kCAContentsFormatRGBA10XR];
#endif
}

// So that the scrolling thread's performance logging code can find all the tiles, mark this as being a tile.
if (m_layerType == LayerTypeTiledBackingTileLayer)
Expand Down
16 changes: 5 additions & 11 deletions Source/WebCore/platform/ios/LegacyTileGridTile.mm
Expand Up @@ -33,22 +33,13 @@
#include "LegacyTileGrid.h"
#include "LegacyTileLayer.h"
#include "LegacyTileLayerPool.h"
#include "PlatformScreen.h"
#include "QuartzCoreSPI.h"
#include "WAKWindow.h"
#include <algorithm>
#include <functional>
#include <wtf/NeverDestroyed.h>

#if USE(APPLE_INTERNAL_SDK)
#import <WebKitAdditions/LayerBackingStoreAdditions.mm>
#else
namespace WebCore {
static void setBackingStoreFormat(CALayer *)
{
}
} // namespace WebCore
#endif

namespace WebCore {

#if LOG_TILING
Expand All @@ -71,7 +62,10 @@ static void setBackingStoreFormat(CALayer *)
m_tileLayer = adoptNS([[LegacyTileLayer alloc] init]);
}
LegacyTileLayer* layer = m_tileLayer.get();
setBackingStoreFormat(layer);
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
if (screenSupportsExtendedColor())
layer.contentsFormat = kCAContentsFormatRGBA10XR;
#endif
[layer setTileGrid:tileGrid];
[layer setOpaque:m_tileGrid->tileCache().tilesOpaque()];
[layer setEdgeAntialiasingMask:0];
Expand Down
11 changes: 10 additions & 1 deletion Source/WebCore/platform/ios/PlatformScreenIOS.mm
Expand Up @@ -56,7 +56,7 @@ int screenDepth(Widget*)
int screenDepthPerComponent(Widget*)
{
// Assume the screen depth is evenly divided into four color components. See <rdar://problem/9378829>.
return screenDepth(0) / 4;
return screenDepth(nullptr) / 4;
}

bool screenIsMonochrome(Widget*)
Expand All @@ -69,6 +69,15 @@ bool screenHasInvertedColors()
return UIAccessibilityIsInvertColorsEnabled();
}

bool screenSupportsExtendedColor()
{
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
return MGGetBoolAnswer(kMGQHasExtendedColorDisplay);
#else
return false;
#endif
}

// These functions scale between screen and page coordinates because JavaScript/DOM operations
// assume that the screen and the page share the same coordinate system.
FloatRect screenRect(Widget* widget)
Expand Down
15 changes: 10 additions & 5 deletions Source/WebCore/platform/mac/PlatformScreenMac.mm
Expand Up @@ -49,7 +49,7 @@ static PlatformDisplayID displayFromWidget(Widget* widget)
{
if (!widget)
return 0;

FrameView* view = widget->root();
if (!view)
return 0;
Expand All @@ -62,11 +62,11 @@ static PlatformDisplayID displayFromWidget(Widget* widget)
// Widget is in an NSWindow, use its screen.
if (window)
return screenForWindow(window);

// Didn't get an NSWindow; probably WebKit2. Try using the Widget's display ID.
if (NSScreen *screen = screenForDisplayID(displayFromWidget(widget)))
return screen;

// Widget's window is offscreen, or no screens. Fall back to the first screen if available.
return screenForWindow(nil);
}
Expand Down Expand Up @@ -118,11 +118,11 @@ FloatRect screenAvailableRect(Widget* widget)
NSScreen *screen = [window screen]; // nil if the window is off-screen
if (screen)
return screen;

NSArray *screens = [NSScreen screens];
if ([screens count] > 0)
return [screens objectAtIndex:0]; // screen containing the menubar

return nil;
}

Expand All @@ -135,6 +135,11 @@ FloatRect screenAvailableRect(Widget* widget)
return nil;
}

bool screenSupportsExtendedColor()
{
return false; // FIXME: Update this to detect extended color screens.
}

FloatRect toUserSpace(const NSRect& rect, NSWindow *destination)
{
FloatRect userRect = rect;
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h
Expand Up @@ -186,6 +186,10 @@ extern NSString * const kCAContextDisplayName;
extern NSString * const kCAContextDisplayId;
extern NSString * const kCAContextIgnoresHitTest;

#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
extern NSString * const kCAContentsFormatRGBA10XR;
#endif

#if (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED < 100000) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED < 30000) \
|| (PLATFORM(IOS) && TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < 100000) \
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/spi/ios/MobileGestaltSPI.h
Expand Up @@ -44,6 +44,7 @@ static const CFStringRef kMGQMainScreenScale = CFSTR("main-screen-scale");
static const CFStringRef kMGQiPadCapability = CFSTR("ipad");
static const CFStringRef kMGQDeviceName = CFSTR("DeviceName");
static const CFStringRef kMGQDeviceClassNumber = CFSTR("DeviceClassNumber");
static const CFStringRef kMGQHasExtendedColorDisplay = CFSTR("HasExtendedColorDisplay");

typedef enum {
MGDeviceClassInvalid = -1,
Expand Down
20 changes: 20 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,23 @@
2016-03-25 Dean Jackson <dino@apple.com>

Move extended color detection into Open Source
https://bugs.webkit.org/show_bug.cgi?id=155909
<rdar://problem/25369754>

Reviewed by Anders Carlsson.

The code for detecting extended color displays
was hidden while the iPad Pro 9.7" was in development.
Now it is public, move the detection to Open Source.

While doing this, add a new method to PlatformScreen
so that we have a more obvious way to detect such
displays.

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::bufferFormat): No need to use WebKitAdditions any
more.

2016-03-26 Dan Bernstein <mitz@apple.com>

Treat SHA-1-signed certificates as insecure by default.
Expand Down
18 changes: 6 additions & 12 deletions Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
Expand Up @@ -38,34 +38,28 @@
#import <WebCore/IOSurface.h>
#import <WebCore/MachSendRight.h>
#import <WebCore/PlatformCALayerClient.h>
#import <WebCore/PlatformScreen.h>
#import <WebCore/QuartzCoreSPI.h>
#import <WebCore/WebLayer.h>

#if USE(IOSURFACE)
#import <mach/mach_port.h>
#endif

#if USE(APPLE_INTERNAL_SDK)
#import <WebKitAdditions/RemoteLayerBackingStoreAdditions.mm>
#else
using namespace WebCore;

namespace WebKit {

#if USE(IOSURFACE)
static WebCore::IOSurface::Format bufferFormat(bool)
static WebCore::IOSurface::Format bufferFormat(bool isOpaque)
{
if (screenSupportsExtendedColor())
return isOpaque ? WebCore::IOSurface::Format::RGB10 : WebCore::IOSurface::Format::RGB10A8;

return WebCore::IOSurface::Format::RGBA;
}
#endif // USE(IOSURFACE)

} // namespace WebKit

#endif

using namespace WebCore;

namespace WebKit {

RemoteLayerBackingStore::RemoteLayerBackingStore(PlatformCALayerRemote* layer)
: m_layer(layer)
, m_isOpaque(false)
Expand Down

0 comments on commit 57c1cf7

Please sign in to comment.