Changeset 232535 in webkit
- Timestamp:
- Jun 5, 2018 9:35:12 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232534 r232535 1 2018-06-05 Per Arne Vollan <pvollan@apple.com> 2 3 Move OpenGL display mask to screen data struct. 4 https://bugs.webkit.org/show_bug.cgi?id=186198 5 <rdar://problem/40724854> 6 7 Reviewed by Brent Fulgham. 8 9 Currently, the OpenGL display mask is a global in the WebContent process. This is not correct in all cases, since 10 it is possible to have two Web views in the same WebContent process, displayed on different displays. This can be 11 resolved by moving the OpenGL display mask to a new ScreenData struct, containing information specific to each 12 display. The display ID of the host window is used to find the OpenGL display mask when needed. This patch makes 13 the host window available when creating an IOSurface, in order to find the right OpenGL display mask. If no host 14 window is available, the OpenGL display mask of the main display is used. 15 16 No new tests, since testing this requires two Web views in the same WebContent process, displayed on 17 two different monitors. 18 19 * html/HTMLCanvasElement.cpp: 20 (WebCore::HTMLCanvasElement::createImageBuffer const): 21 * platform/PlatformScreen.h: 22 * platform/ScreenProperties.h: 23 (WebCore::ScreenProperties::encode const): 24 (WebCore::ScreenProperties::decode): 25 (WebCore::ScreenData::encode const): 26 (WebCore::ScreenData::decode): 27 * platform/graphics/GraphicsContext3D.h: 28 * platform/graphics/ImageBuffer.cpp: 29 (WebCore::ImageBuffer::create): 30 * platform/graphics/ImageBuffer.h: 31 * platform/graphics/cg/ImageBufferCG.cpp: 32 (WebCore::ImageBuffer::createCompatibleBuffer): 33 (WebCore::ImageBuffer::ImageBuffer): 34 * platform/graphics/cocoa/GraphicsContext3DCocoa.mm: 35 (WebCore::GraphicsContext3D::GraphicsContext3D): 36 (WebCore::GraphicsContext3D::allowOfflineRenderers const): 37 (WebCore::GraphicsContext3D::setOpenGLDisplayMask): Deleted. 38 (WebCore::GraphicsContext3D::getOpenGLDisplayMask): Deleted. 39 * platform/graphics/cocoa/IOSurface.h: 40 * platform/graphics/cocoa/IOSurface.mm: 41 (WebCore::IOSurface::ensurePlatformContext): 42 * platform/mac/PlatformScreenMac.mm: 43 (WebCore::screenProperties): 44 (WebCore::collectScreenProperties): 45 (WebCore::setScreenProperties): 46 (WebCore::screenData): 47 (WebCore::primaryOpenGLDisplayMask): 48 (WebCore::displayMaskForDisplay): 49 (WebCore::getScreenProperties): 50 (WebCore::screenIsMonochrome): 51 (WebCore::screenHasInvertedColors): 52 (WebCore::screenDepth): 53 (WebCore::screenDepthPerComponent): 54 (WebCore::screenRectForDisplay): 55 (WebCore::screenRect): 56 (WebCore::screenAvailableRect): 57 (WebCore::screenColorSpace): 58 (WebCore::screenSupportsExtendedColor): 59 1 60 2018-06-05 Jer Noble <jer.noble@apple.com> 2 61 -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r232113 r232535 914 914 RenderingMode renderingMode = shouldAccelerate(size()) ? Accelerated : Unaccelerated; 915 915 916 setImageBuffer(ImageBuffer::create(size(), renderingMode)); 916 auto hostWindow = (document().view() && document().view()->root()) ? document().view()->root()->hostWindow() : nullptr; 917 setImageBuffer(ImageBuffer::create(size(), renderingMode, 1, ColorSpaceSRGB, hostWindow)); 917 918 if (!m_imageBuffer) 918 919 return; -
trunk/Source/WebCore/platform/PlatformScreen.h
r232375 r232535 96 96 NSPoint flipScreenPoint(const NSPoint&, NSScreen *); 97 97 98 typedef HashMap<PlatformDisplayID, ScreenProperties> ScreenPropertiesMap; 98 WEBCORE_EXPORT ScreenProperties collectScreenProperties(); 99 WEBCORE_EXPORT void setScreenProperties(const ScreenProperties&); 99 100 100 WEBCORE_EXPORT std::pair<PlatformDisplayID, ScreenPropertiesMap> getScreenProperties(); 101 WEBCORE_EXPORT void setScreenProperties(PlatformDisplayID primaryScreenID, const ScreenPropertiesMap&); 102 ScreenProperties screenProperties(PlatformDisplayID); 103 101 uint32_t primaryOpenGLDisplayMask(); 102 uint32_t displayMaskForDisplay(PlatformDisplayID); 104 103 #endif 105 104 -
trunk/Source/WebCore/platform/ScreenProperties.h
r230356 r232535 29 29 30 30 #include "FloatRect.h" 31 #include "PlatformScreen.h" 31 32 #include <wtf/RetainPtr.h> 32 33 #include <wtf/text/WTFString.h> … … 36 37 namespace WebCore { 37 38 38 struct Screen Properties{39 struct ScreenData { 39 40 FloatRect screenAvailableRect; 40 41 FloatRect screenRect; … … 45 46 bool screenHasInvertedColors { false }; 46 47 bool screenIsMonochrome { false }; 48 uint32_t displayMask { 0 }; 47 49 48 50 enum EncodedColorSpaceDataType { … … 53 55 54 56 template<class Encoder> void encode(Encoder&) const; 57 template<class Decoder> static std::optional<ScreenData> decode(Decoder&); 58 }; 59 60 typedef HashMap<PlatformDisplayID, ScreenData> ScreenDataMap; 61 62 struct ScreenProperties { 63 PlatformDisplayID primaryDisplayID { 0 }; 64 ScreenDataMap screenDataMap; 65 66 template<class Encoder> void encode(Encoder&) const; 55 67 template<class Decoder> static std::optional<ScreenProperties> decode(Decoder&); 56 68 }; … … 59 71 void ScreenProperties::encode(Encoder& encoder) const 60 72 { 61 encoder << screenAvailableRect << screenRect << screenDepth << screenDepthPerComponent << screenSupportsExtendedColor << screenHasInvertedColors << screenIsMonochrome; 73 encoder << primaryDisplayID; 74 encoder << screenDataMap; 75 } 76 77 template<class Decoder> 78 std::optional<ScreenProperties> ScreenProperties::decode(Decoder& decoder) 79 { 80 std::optional<PlatformDisplayID> primaryDisplayID; 81 decoder >> primaryDisplayID; 82 if (!primaryDisplayID) 83 return std::nullopt; 84 85 std::optional<ScreenDataMap> screenDataMap; 86 decoder >> screenDataMap; 87 if (!screenDataMap) 88 return std::nullopt; 89 90 return { { *primaryDisplayID, WTFMove(*screenDataMap) } }; 91 } 92 93 template<class Encoder> 94 void ScreenData::encode(Encoder& encoder) const 95 { 96 encoder << screenAvailableRect << screenRect << screenDepth << screenDepthPerComponent << screenSupportsExtendedColor << screenHasInvertedColors << screenIsMonochrome << displayMask; 62 97 63 98 if (colorSpace) { … … 86 121 87 122 template<class Decoder> 88 std::optional<Screen Properties> ScreenProperties::decode(Decoder& decoder)123 std::optional<ScreenData> ScreenData::decode(Decoder& decoder) 89 124 { 90 125 std::optional<FloatRect> screenAvailableRect; … … 123 158 return std::nullopt; 124 159 160 std::optional<uint32_t> displayMask; 161 decoder >> displayMask; 162 if (!displayMask) 163 return std::nullopt; 164 125 165 EncodedColorSpaceDataType dataType; 126 166 if (!decoder.decodeEnum(dataType)) … … 158 198 } 159 199 160 return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect), WTFMove(cgColorSpace), WTFMove(*screenDepth), WTFMove(*screenDepthPerComponent), WTFMove(*screenSupportsExtendedColor), WTFMove(*screenHasInvertedColors), WTFMove(*screenIsMonochrome) } };200 return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect), WTFMove(cgColorSpace), WTFMove(*screenDepth), WTFMove(*screenDepthPerComponent), WTFMove(*screenSupportsExtendedColor), WTFMove(*screenHasInvertedColors), WTFMove(*screenIsMonochrome), WTFMove(*displayMask) } }; 161 201 } 162 202 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r230278 r232535 1283 1283 unsigned textureSeed(GC3Duint texture) { return m_state.textureSeedCount.count(texture); } 1284 1284 1285 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)1286 WEBCORE_EXPORT static void setOpenGLDisplayMask(CGOpenGLDisplayMask);1287 WEBCORE_EXPORT static CGOpenGLDisplayMask getOpenGLDisplayMask();1288 #endif1289 1290 1285 private: 1291 1286 GraphicsContext3D(GraphicsContext3DAttributes, HostWindow*, RenderStyle = RenderOffscreen, GraphicsContext3D* sharedContext = nullptr); … … 1502 1497 Platform3DObject m_vao { 0 }; 1503 1498 #endif 1504 1505 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)1506 static std::optional<CGOpenGLDisplayMask> m_displayMask;1507 #endif1508 1499 }; 1509 1500 -
trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp
r231638 r232535 39 39 static const float MaxClampedArea = MaxClampedLength * MaxClampedLength; 40 40 41 std::unique_ptr<ImageBuffer> ImageBuffer::create(const FloatSize& size, RenderingMode renderingMode, float resolutionScale, ColorSpace colorSpace )41 std::unique_ptr<ImageBuffer> ImageBuffer::create(const FloatSize& size, RenderingMode renderingMode, float resolutionScale, ColorSpace colorSpace, const HostWindow* hostWindow) 42 42 { 43 43 bool success = false; 44 std::unique_ptr<ImageBuffer> buffer(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, success));44 std::unique_ptr<ImageBuffer> buffer(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, hostWindow, success)); 45 45 if (!success) 46 46 return nullptr; -
trunk/Source/WebCore/platform/graphics/ImageBuffer.h
r228218 r232535 50 50 class IntPoint; 51 51 class IntRect; 52 52 class HostWindow; 53 53 54 enum BackingStoreCopy { 54 55 CopyBackingStore, // Guarantee subsequent draws don't affect the copy. … … 66 67 public: 67 68 // Will return a null pointer on allocation failure. 68 WEBCORE_EXPORT static std::unique_ptr<ImageBuffer> create(const FloatSize&, RenderingMode, float resolutionScale = 1, ColorSpace = ColorSpaceSRGB );69 WEBCORE_EXPORT static std::unique_ptr<ImageBuffer> create(const FloatSize&, RenderingMode, float resolutionScale = 1, ColorSpace = ColorSpaceSRGB, const HostWindow* = nullptr); 69 70 #if USE(DIRECT2D) 70 71 WEBCORE_EXPORT static std::unique_ptr<ImageBuffer> create(const FloatSize&, RenderingMode, const GraphicsContext*, float resolutionScale = 1, ColorSpace = ColorSpaceSRGB); … … 165 166 // This constructor will place its success into the given out-variable 166 167 // so that create() knows when it should return failure. 167 WEBCORE_EXPORT ImageBuffer(const FloatSize&, float resolutionScale, ColorSpace, RenderingMode, bool& success);168 WEBCORE_EXPORT ImageBuffer(const FloatSize&, float resolutionScale, ColorSpace, RenderingMode, const HostWindow*, bool& success); 168 169 #if USE(CG) 169 ImageBuffer(const FloatSize&, float resolutionScale, CGColorSpaceRef, RenderingMode, bool& success);170 ImageBuffer(const FloatSize&, float resolutionScale, CGColorSpaceRef, RenderingMode, const HostWindow*, bool& success); 170 171 RetainPtr<CFDataRef> toCFData(const String& mimeType, std::optional<double> quality, PreserveResolution) const; 171 172 #elif USE(DIRECT2D) -
trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r230702 r232535 205 205 #endif 206 206 207 ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, bool& success)207 ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, const HostWindow*, bool& success) 208 208 : m_data(IntSize(size), renderingMode) 209 209 , m_logicalSize(size) -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
r231638 r232535 97 97 IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context); 98 98 bool success = false; 99 std::unique_ptr<ImageBuffer> buffer(new ImageBuffer(scaledSize, 1, colorSpace.get(), renderingMode, success));99 std::unique_ptr<ImageBuffer> buffer(new ImageBuffer(scaledSize, 1, colorSpace.get(), renderingMode, nullptr, success)); 100 100 101 101 if (!success) … … 107 107 } 108 108 109 ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, CGColorSpaceRef colorSpace, RenderingMode renderingMode, bool& success)109 ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, CGColorSpaceRef colorSpace, RenderingMode renderingMode, const HostWindow* hostWindow, bool& success) 110 110 : m_logicalSize(size) 111 111 , m_resolutionScale(resolutionScale) … … 153 153 m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), colorSpace); 154 154 if (m_data.surface) { 155 cgContext = m_data.surface->ensurePlatformContext( );155 cgContext = m_data.surface->ensurePlatformContext(hostWindow); 156 156 if (cgContext) 157 157 CGContextClearRect(cgContext.get(), FloatRect(FloatPoint(), userBounds)); … … 159 159 m_data.surface = nullptr; 160 160 } 161 #else 162 UNUSED_PARAM(hostWindow); 161 163 #endif 162 164 if (!cgContext) … … 194 196 } 195 197 196 ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool& success)197 : ImageBuffer(size, resolutionScale, cachedCGColorSpace(imageColorSpace), renderingMode, success)198 ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, const HostWindow* hostWindow, bool& success) 199 : ImageBuffer(size, resolutionScale, cachedCGColorSpace(imageColorSpace), renderingMode, hostWindow, success) 198 200 { 199 201 } -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm
r230278 r232535 37 37 #import "GraphicsContext.h" 38 38 #import "HTMLCanvasElement.h" 39 #import "HostWindow.h" 39 40 #import "ImageBuffer.h" 40 41 #import "Logging.h" … … 61 62 #endif 62 63 64 #if PLATFORM(MAC) 65 #import "ScreenProperties.h" 66 #endif 67 63 68 namespace WebCore { 64 69 65 70 static const unsigned statusCheckThreshold = 5; 66 67 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)68 std::optional<CGOpenGLDisplayMask> GraphicsContext3D::m_displayMask;69 #endif70 71 71 72 #if HAVE(APPLE_GRAPHICS_CONTROL) … … 425 426 #endif 426 427 427 GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWindow* , GraphicsContext3D::RenderStyle, GraphicsContext3D* sharedContext)428 GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle, GraphicsContext3D* sharedContext) 428 429 : m_attrs(attrs) 429 430 #if PLATFORM(IOS) … … 433 434 { 434 435 #if USE(OPENGL_ES) 436 UNUSED_PARAM(hostWindow); 435 437 EAGLRenderingAPI api = m_attrs.useGLES3 ? kEAGLRenderingAPIOpenGLES3 : kEAGLRenderingAPIOpenGLES2; 436 438 if (!sharedContext) … … 493 495 494 496 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 495 if (m_displayMask.has_value()) 496 identifyAndSetCurrentGPU(pixelFormatObj, numPixelFormats, m_displayMask.value(), m_contextObj); 497 if (auto displayMask = primaryOpenGLDisplayMask()) { 498 if (hostWindow && hostWindow->displayID()) 499 displayMask = displayMaskForDisplay(hostWindow->displayID()); 500 identifyAndSetCurrentGPU(pixelFormatObj, numPixelFormats, displayMask, m_contextObj); 501 } 502 #else 503 UNUSED_PARAM(hostWindow); 497 504 #endif 498 505 … … 790 797 } 791 798 792 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)793 void GraphicsContext3D::setOpenGLDisplayMask(CGOpenGLDisplayMask displayMask)794 {795 m_displayMask = displayMask;796 }797 798 CGOpenGLDisplayMask GraphicsContext3D::getOpenGLDisplayMask()799 {800 if (m_displayMask.has_value())801 return m_displayMask.value();802 return 0;803 }804 #endif805 806 799 bool GraphicsContext3D::allowOfflineRenderers() const 807 800 { … … 813 806 // In WebKit legacy, there will still be a WindowServer connection, and 814 807 // m_displayMask will not be set in this case. 815 if ( m_displayMask.has_value())808 if (primaryOpenGLDisplayMask()) 816 809 return true; 817 810 #endif -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h
r232501 r232535 39 39 namespace WebCore { 40 40 41 class HostWindow; 42 41 43 class IOSurface final { 42 44 WTF_MAKE_FAST_ALLOCATED; … … 108 110 IOSurfaceRef surface() const { return m_surface.get(); } 109 111 WEBCORE_EXPORT GraphicsContext& ensureGraphicsContext(); 110 WEBCORE_EXPORT CGContextRef ensurePlatformContext( );112 WEBCORE_EXPORT CGContextRef ensurePlatformContext(const HostWindow* = nullptr); 111 113 112 114 enum class SurfaceState { -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm
r230278 r232535 273 273 } 274 274 275 CGContextRef IOSurface::ensurePlatformContext( )275 CGContextRef IOSurface::ensurePlatformContext(const HostWindow* hostWindow) 276 276 { 277 277 if (m_cgContext) … … 302 302 303 303 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 304 if (uint32_t mask = GraphicsContext3D::getOpenGLDisplayMask()) 305 CGIOSurfaceContextSetDisplayMask(m_cgContext.get(), mask); 304 if (auto displayMask = primaryOpenGLDisplayMask()) { 305 if (hostWindow && hostWindow->displayID()) 306 displayMask = displayMaskForDisplay(hostWindow->displayID()); 307 CGIOSurfaceContextSetDisplayMask(m_cgContext.get(), displayMask); 308 } 309 #else 310 UNUSED_PARAM(hostWindow); 306 311 #endif 307 312 -
trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm
r232375 r232535 97 97 } 98 98 99 static ScreenProperties Map& screenProperties()100 { 101 static NeverDestroyed<ScreenProperties Map> screenProperties;99 static ScreenProperties& screenProperties() 100 { 101 static NeverDestroyed<ScreenProperties> screenProperties; 102 102 return screenProperties; 103 103 } … … 109 109 } 110 110 111 std::pair<PlatformDisplayID, ScreenPropertiesMap> getScreenProperties() 112 { 113 ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 114 115 ScreenPropertiesMap screenProperties; 116 std::optional<PlatformDisplayID> firstScreen; 111 ScreenProperties collectScreenProperties() 112 { 113 ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 114 115 ScreenProperties screenProperties; 117 116 118 117 for (NSScreen *screen in [NSScreen screens]) { … … 129 128 bool screenHasInvertedColors = CGDisplayUsesInvertedPolarity(); 130 129 bool screenIsMonochrome = CGDisplayUsesForceToGray(); 131 132 screenProperties.set(displayID, ScreenProperties { screenAvailableRect, screenRect, colorSpace, screenDepth, screenDepthPerComponent, screenSupportsExtendedColor, screenHasInvertedColors, screenIsMonochrome }); 133 134 if (!firstScreen) 135 firstScreen = displayID;136 }137 138 return { WTFMove(*firstScreen), WTFMove(screenProperties) }; 139 } 140 141 void setScreenProperties(PlatformDisplayID primaryScreenID, const ScreenPropertiesMap& properties) 142 { 143 primaryScreenDisplayID() = primaryScreenID; 130 uint32_t displayMask = CGDisplayIDToOpenGLDisplayMask(displayID); 131 132 screenProperties.screenDataMap.set(displayID, ScreenData { screenAvailableRect, screenRect, colorSpace, screenDepth, screenDepthPerComponent, screenSupportsExtendedColor, screenHasInvertedColors, screenIsMonochrome, displayMask }); 133 134 if (!screenProperties.primaryDisplayID) 135 screenProperties.primaryDisplayID = displayID; 136 } 137 138 return screenProperties; 139 } 140 141 void setScreenProperties(const ScreenProperties& properties) 142 { 144 143 screenProperties() = properties; 145 144 } 146 145 147 ScreenProperties screenProperties(PlatformDisplayID screendisplayID)148 { 149 RELEASE_ASSERT(!screenProperties(). isEmpty());146 static ScreenData screenData(PlatformDisplayID screendisplayID) 147 { 148 RELEASE_ASSERT(!screenProperties().screenDataMap.isEmpty()); 150 149 151 150 // Return property of the first screen if the screen is not found in the map. 152 151 auto displayID = screendisplayID ? screendisplayID : primaryScreenDisplayID(); 153 152 if (displayID) { 154 auto screenPropertiesForDisplay = screenProperties(). find(displayID);155 if (screenPropertiesForDisplay != screenProperties(). end())153 auto screenPropertiesForDisplay = screenProperties().screenDataMap.find(displayID); 154 if (screenPropertiesForDisplay != screenProperties().screenDataMap.end()) 156 155 return screenPropertiesForDisplay->value; 157 156 } 158 157 159 158 // Last resort: use the first item in the screen list. 160 return screenProperties().begin()->value; 161 } 162 163 static ScreenProperties getScreenProperties(Widget* widget) 164 { 165 return screenProperties(displayID(widget)); 159 return screenProperties().screenDataMap.begin()->value; 160 } 161 162 uint32_t primaryOpenGLDisplayMask() 163 { 164 if (!screenProperties().screenDataMap.isEmpty()) 165 return screenData(primaryScreenDisplayID()).displayMask; 166 167 return 0; 168 } 169 170 uint32_t displayMaskForDisplay(PlatformDisplayID displayID) 171 { 172 if (!screenProperties().screenDataMap.isEmpty()) 173 return screenData(displayID).displayMask; 174 175 ASSERT_NOT_REACHED(); 176 return 0; 177 } 178 179 static ScreenData getScreenProperties(Widget* widget) 180 { 181 return screenData(displayID(widget)); 166 182 } 167 183 168 184 bool screenIsMonochrome(Widget* widget) 169 185 { 170 if (!screenProperties(). isEmpty())186 if (!screenProperties().screenDataMap.isEmpty()) 171 187 return getScreenProperties(widget).screenIsMonochrome; 172 188 … … 178 194 bool screenHasInvertedColors() 179 195 { 180 if (!screenProperties(). isEmpty())181 return screen Properties(primaryScreenDisplayID()).screenHasInvertedColors;196 if (!screenProperties().screenDataMap.isEmpty()) 197 return screenData(primaryScreenDisplayID()).screenHasInvertedColors; 182 198 183 199 // This is a system-wide accessibility setting, same on all screens. … … 188 204 int screenDepth(Widget* widget) 189 205 { 190 if (!screenProperties(). isEmpty()) {206 if (!screenProperties().screenDataMap.isEmpty()) { 191 207 auto screenDepth = getScreenProperties(widget).screenDepth; 192 208 ASSERT(screenDepth); … … 200 216 int screenDepthPerComponent(Widget* widget) 201 217 { 202 if (!screenProperties(). isEmpty()) {218 if (!screenProperties().screenDataMap.isEmpty()) { 203 219 auto depthPerComponent = getScreenProperties(widget).screenDepthPerComponent; 204 220 ASSERT(depthPerComponent); … … 212 228 FloatRect screenRectForDisplay(PlatformDisplayID displayID) 213 229 { 214 if (!screenProperties(). isEmpty()) {215 auto screenRect = screen Properties(displayID).screenRect;230 if (!screenProperties().screenDataMap.isEmpty()) { 231 auto screenRect = screenData(displayID).screenRect; 216 232 ASSERT(!screenRect.isEmpty()); 217 233 return screenRect; … … 229 245 FloatRect screenRect(Widget* widget) 230 246 { 231 if (!screenProperties(). isEmpty())247 if (!screenProperties().screenDataMap.isEmpty()) 232 248 return getScreenProperties(widget).screenRect; 233 249 … … 238 254 FloatRect screenAvailableRect(Widget* widget) 239 255 { 240 if (!screenProperties(). isEmpty())256 if (!screenProperties().screenDataMap.isEmpty()) 241 257 return getScreenProperties(widget).screenAvailableRect; 242 258 … … 263 279 CGColorSpaceRef screenColorSpace(Widget* widget) 264 280 { 265 if (!screenProperties(). isEmpty())281 if (!screenProperties().screenDataMap.isEmpty()) 266 282 return getScreenProperties(widget).colorSpace.get(); 267 283 … … 272 288 bool screenSupportsExtendedColor(Widget* widget) 273 289 { 274 if (!screenProperties(). isEmpty())290 if (!screenProperties().screenDataMap.isEmpty()) 275 291 return getScreenProperties(widget).screenSupportsExtendedColor; 276 292 -
trunk/Source/WebKit/ChangeLog
r232531 r232535 1 2018-06-05 Per Arne Vollan <pvollan@apple.com> 2 3 Move OpenGL display mask to screen data struct. 4 https://bugs.webkit.org/show_bug.cgi?id=186198 5 <rdar://problem/40724854> 6 7 Reviewed by Brent Fulgham. 8 9 Currently, the OpenGL display mask is a global in the WebContent process. This is not correct in all cases, since 10 it is possible to have two Web views in the same WebContent process, displayed on different displays. This can be 11 resolved by moving the OpenGL display mask to a new ScreenData struct, containing information specific to each 12 display. The display ID of the host window is used to find the OpenGL display mask when needed. This patch makes 13 the host window available when creating an IOSurface, in order to find the right OpenGL display mask. If no host 14 window is available, the OpenGL display mask of the main display is used. 15 16 * Shared/WebPageCreationParameters.cpp: 17 (WebKit::WebPageCreationParameters::encode const): 18 (WebKit::WebPageCreationParameters::decode): 19 * Shared/WebPageCreationParameters.h: 20 * Shared/WebProcessCreationParameters.cpp: 21 (WebKit::WebProcessCreationParameters::encode const): 22 (WebKit::WebProcessCreationParameters::decode): 23 * Shared/WebProcessCreationParameters.h: 24 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 25 (WebKit::WebProcessPool::platformInitializeWebProcess): 26 * UIProcess/WebPageProxy.cpp: 27 (WebKit::WebPageProxy::windowScreenDidChange): 28 (WebKit::WebPageProxy::creationParameters): 29 * UIProcess/WebProcessPool.cpp: 30 (WebKit::WebProcessPool::screenPropertiesStateChanged): 31 (WebKit::displayReconfigurationCallBack): 32 * WebProcess/WebPage/WebPage.cpp: 33 (WebKit::m_credentialsMessenger): 34 * WebProcess/WebPage/WebPage.h: 35 * WebProcess/WebPage/WebPage.messages.in: 36 * WebProcess/WebPage/mac/WebPageMac.mm: 37 (WebKit::WebPage::openGLDisplayMaskChanged): Deleted. 38 * WebProcess/WebProcess.cpp: 39 (WebKit::WebProcess::setScreenProperties): 40 * WebProcess/WebProcess.h: 41 * WebProcess/WebProcess.messages.in: 42 * WebProcess/cocoa/WebProcessCocoa.mm: 43 (WebKit::WebProcess::platformInitializeWebProcess): 44 1 45 2018-06-05 Keith Rollin <krollin@apple.com> 2 46 -
trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp
r232375 r232535 120 120 encoder << contentRuleLists; 121 121 #endif 122 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)123 encoder << displayMask;124 #endif125 122 } 126 123 … … 347 344 #endif 348 345 349 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)350 if (!decoder.decode(parameters.displayMask))351 return std::nullopt;352 #endif353 354 346 return WTFMove(parameters); 355 347 } -
trunk/Source/WebKit/Shared/WebPageCreationParameters.h
r232375 r232535 186 186 Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists; 187 187 #endif 188 189 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)190 CGOpenGLDisplayMask displayMask { 0 };191 #endif192 188 }; 193 189 -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp
r232277 r232535 157 157 158 158 #if PLATFORM(MAC) 159 encoder << primaryDisplayID; 160 encoder << screenPropertiesMap; 159 encoder << screenProperties; 161 160 #endif 162 161 } … … 408 407 409 408 #if PLATFORM(MAC) 410 if (!decoder.decode(parameters.primaryDisplayID)) 411 return false; 412 413 std::optional<WebCore::ScreenPropertiesMap> screenPropertiesMap; 414 decoder >> screenPropertiesMap; 415 if (!screenPropertiesMap) 416 return false; 417 parameters.screenPropertiesMap = WTFMove(*screenPropertiesMap); 409 std::optional<WebCore::ScreenProperties> screenProperties; 410 decoder >> screenProperties; 411 if (!screenProperties) 412 return false; 413 parameters.screenProperties = WTFMove(*screenProperties); 418 414 #endif 419 415 -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.h
r232277 r232535 196 196 197 197 #if PLATFORM(MAC) 198 WebCore::PlatformDisplayID primaryDisplayID { 0 }; 199 WebCore::ScreenPropertiesMap screenPropertiesMap; 198 WebCore::ScreenProperties screenProperties; 200 199 #endif 201 200 }; -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r232520 r232535 283 283 284 284 #if PLATFORM(MAC) 285 auto screenProperties = WebCore::getScreenProperties(); 286 parameters.primaryDisplayID = screenProperties.first; 287 parameters.screenPropertiesMap = WTFMove(screenProperties.second); 285 auto screenProperties = WebCore::collectScreenProperties(); 286 parameters.screenProperties = WTFMove(screenProperties); 288 287 #endif 289 288 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r232437 r232535 2779 2779 2780 2780 m_process->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID); 2781 2782 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)2783 auto currentDisplaymask = CGDisplayIDToOpenGLDisplayMask(displayID);2784 m_process->send(Messages::WebPage::OpenGLDisplayMaskChanged(currentDisplaymask), m_pageID);2785 #endif2786 2781 } 2787 2782 … … 6175 6170 #endif 6176 6171 6177 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)6178 auto screen = WebCore::screen(m_pageClient.platformWindow());6179 auto displayID = WebCore::displayID(screen);6180 parameters.displayMask = CGDisplayIDToOpenGLDisplayMask(displayID);6181 #endif6182 6183 6172 m_process->addWebUserContentControllerProxy(m_userContentController, parameters); 6184 6173 -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r232531 r232535 440 440 { 441 441 #if PLATFORM(MAC) 442 auto screenProperties = WebCore:: getScreenProperties();443 sendToAllProcesses(Messages::WebProcess::SetScreenProperties(screenProperties .first, screenProperties.second));442 auto screenProperties = WebCore::collectScreenProperties(); 443 sendToAllProcesses(Messages::WebProcess::SetScreenProperties(screenProperties)); 444 444 #endif 445 445 } … … 811 811 static void displayReconfigurationCallBack(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) 812 812 { 813 auto screenProperties = WebCore:: getScreenProperties();813 auto screenProperties = WebCore::collectScreenProperties(); 814 814 for (auto& processPool : WebProcessPool::allProcessPools()) 815 processPool->sendToAllProcesses(Messages::WebProcess::SetScreenProperties(screenProperties .first, screenProperties.second));815 processPool->sendToAllProcesses(Messages::WebProcess::SetScreenProperties(screenProperties)); 816 816 } 817 817 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r232499 r232535 619 619 setMaximumUnobscuredSize(parameters.maximumUnobscuredSize); 620 620 #endif 621 622 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)623 GraphicsContext3D::setOpenGLDisplayMask(parameters.displayMask);624 #endif625 621 } 626 622 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r232301 r232535 1074 1074 #endif 1075 1075 1076 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)1077 void openGLDisplayMaskChanged(uint32_t displayMask);1078 #endif1079 1080 1076 UserContentControllerIdentifier userContentControllerIdentifier() const { return m_userContentController->identifier(); } 1081 1077 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r232280 r232535 515 515 #endif 516 516 517 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)518 OpenGLDisplayMaskChanged(uint32_t displayMask)519 #endif520 521 517 SetDefersLoading(bool defersLoading) 522 518 } -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r232520 r232535 1148 1148 #endif 1149 1149 1150 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)1151 void WebPage::openGLDisplayMaskChanged(uint32_t displayMask)1152 {1153 GraphicsContext3D::setOpenGLDisplayMask(displayMask);1154 }1155 #endif1156 1157 1150 } // namespace WebKit 1158 1151 -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r232516 r232535 1686 1686 1687 1687 #if PLATFORM(MAC) 1688 void WebProcess::setScreenProperties( uint32_t primaryScreenID, const HashMap<uint32_t, WebCore::ScreenProperties>& properties)1689 { 1690 WebCore::setScreenProperties(pr imaryScreenID, properties);1688 void WebProcess::setScreenProperties(const WebCore::ScreenProperties& properties) 1689 { 1690 WebCore::setScreenProperties(properties); 1691 1691 } 1692 1692 #endif -
trunk/Source/WebKit/WebProcess/WebProcess.h
r232263 r232535 372 372 373 373 #if PLATFORM(MAC) 374 void setScreenProperties( uint32_t primaryScreenID, const HashMap<uint32_t, WebCore::ScreenProperties>&);374 void setScreenProperties(const WebCore::ScreenProperties&); 375 375 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 376 376 void scrollerStylePreferenceChanged(bool useOverlayScrollbars); -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r232136 r232535 131 131 132 132 #if PLATFORM(MAC) 133 SetScreenProperties( uint32_t primaryScreenID, HashMap<uint32_t, WebCore::ScreenProperties>screenProperties)133 SetScreenProperties(struct WebCore::ScreenProperties screenProperties) 134 134 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 135 135 ScrollerStylePreferenceChanged(bool useOvelayScrollbars) -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r232260 r232535 194 194 195 195 #if PLATFORM(MAC) 196 WebCore::setScreenProperties(parameters. primaryDisplayID, parameters.screenPropertiesMap);196 WebCore::setScreenProperties(parameters.screenProperties); 197 197 #endif 198 198 }
Note: See TracChangeset
for help on using the changeset viewer.