Changeset 268756 in webkit
- Timestamp:
- Oct 20, 2020, 1:11:16 PM (6 years ago)
- Location:
- branches/safari-611.1.4-branch/Source
- Files:
-
- 2 deleted
- 11 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (6 diffs)
-
WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (modified) (3 diffs)
-
WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h (deleted)
-
WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm (modified) (7 diffs)
-
WebCore/platform/graphics/cocoa/WebGLLayer.h (modified) (1 diff)
-
WebCore/platform/graphics/cocoa/WebGLLayer.mm (modified) (4 diffs)
-
WebCore/platform/graphics/cocoa/WebGLLayerClient.h (deleted)
-
WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h (modified) (7 diffs)
-
WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebPage/WebPage.cpp (modified) (1 diff)
-
WebKit/WebProcess/WebPage/mac/WebPageMac.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-611.1.4-branch/Source/WebCore/ChangeLog
r268755 r268756 1 2020-10-20 Alan Coon <alancoon@apple.com> 2 3 Revert r268386. rdar://problem/70497386 4 1 5 2020-10-20 Alan Coon <alancoon@apple.com> 2 6 -
branches/safari-611.1.4-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r268755 r268756 2219 2219 7AF9B20D18CFB5F400C64BEF /* JSVTTRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20918CFB5F200C64BEF /* JSVTTRegion.h */; }; 2220 2220 7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; }; 2221 7BB34A152534579100029D08 /* WebGLLayerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A132534579100029D08 /* WebGLLayerClient.h */; };2222 7BB34A1725345CB200029D08 /* GraphicsContextGLANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */; };2223 2221 7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; }; 2224 2222 7C029C6E2493C8F800268204 /* ColorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C029C6D2493C8F800268204 /* ColorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 10074 10072 7AF9B20A18CFB5F300C64BEF /* JSVTTRegionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTRegionList.cpp; sourceTree = "<group>"; }; 10075 10073 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegionList.h; sourceTree = "<group>"; }; 10076 7BB34A132534579100029D08 /* WebGLLayerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLLayerClient.h; sourceTree = "<group>"; };10077 7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLANGLEUtilities.h; sourceTree = "<group>"; };10078 10074 7C011F3D24FAD360005BEF10 /* Settings.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = Settings.cpp.erb; sourceTree = "<group>"; }; 10079 10075 7C011F3E24FAD360005BEF10 /* InternalSettingsGenerated.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = InternalSettingsGenerated.cpp.erb; sourceTree = "<group>"; }; … … 21895 21891 6E27F244229C9F8D00F1F632 /* ExtensionsGLANGLE.h */, 21896 21892 6E27F2422298CE4B00F1F632 /* GraphicsContextGLANGLE.cpp */, 21897 7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */,21898 21893 6E290861229DB950000986E2 /* TemporaryANGLESetting.cpp */, 21899 21894 6E290863229DB970000986E2 /* TemporaryANGLESetting.h */, … … 26447 26442 49FFBF3D11C93EE3006A7118 /* WebGLLayer.h */, 26448 26443 49FFBF3E11C93EE3006A7118 /* WebGLLayer.mm */, 26449 7BB34A132534579100029D08 /* WebGLLayerClient.h */,26450 26444 318436DB21B9DAA000ED383E /* WebGPULayer.h */, 26451 26445 318436DD21B9DAA000ED383E /* WebGPULayer.mm */, … … 31641 31635 934907E4125BBBC8007F23A0 /* GraphicsContextCG.h in Headers */, 31642 31636 313DE87023A96973008FC47B /* GraphicsContextGL.h in Headers */, 31643 7BB34A1725345CB200029D08 /* GraphicsContextGLANGLEUtilities.h in Headers */,31644 31637 7C330A021DF8FAC600D3395C /* GraphicsContextGLAttributes.h in Headers */, 31645 31638 49C7B9FC1042D3650009D447 /* GraphicsContextGLOpenGL.h in Headers */, … … 34644 34637 49C7B9CF1042D32F0009D447 /* WebGLFramebuffer.h in Headers */, 34645 34638 49FFBF3F11C93EE3006A7118 /* WebGLLayer.h in Headers */, 34646 7BB34A152534579100029D08 /* WebGLLayerClient.h in Headers */,34647 34639 93F1D5BB12D532C400832BEC /* WebGLLoseContext.h in Headers */, 34648 34640 49C7B9D51042D32F0009D447 /* WebGLObject.h in Headers */, -
branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp
r268755 r268756 210 210 211 211 #if PLATFORM(COCOA) 212 if (! reshapeDisplayBufferBacking()) {212 if (!allocateIOSurfaceBackingStore(size)) { 213 213 RELEASE_LOG(WebGL, "Fatal: Unable to allocate backing store of size %d x %d", width, height); 214 214 forceContextLost(); 215 215 return true; 216 216 } 217 updateFramebufferTextureBackingStoreFromLayer(); 217 218 if (m_preserveDrawingBufferTexture) { 218 219 // The context requires the use of an intermediate texture in order to implement … … 520 521 521 522 makeContextCurrent(); 522 prepareTextureImpl();523 }524 525 void GraphicsContextGLOpenGL::prepareTextureImpl()526 {527 ASSERT(!m_layerComposited);528 523 529 524 if (contextAttributes().antialias) … … 561 556 gl::BindFramebuffer(GL_FRAMEBUFFER, m_state.boundDrawFBO); 562 557 } 558 gl::Flush(); 563 559 #endif 564 560 } -
branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm
r268753 r268756 30 30 31 31 #import "ExtensionsGLANGLE.h" 32 #import "GraphicsContextGLANGLEUtilities.h"33 32 #import "GraphicsContextGLOpenGLManager.h" 34 33 #import "HostWindow.h" … … 41 40 #import <wtf/BlockObjCExceptions.h> 42 41 #import <wtf/text/CString.h> 42 43 #define EGL_EGL_PROTOTYPES 0 44 // Skip the inclusion of ANGLE's explicit context entry points for now. 45 #define GL_ANGLE_explicit_context 46 #define GL_ANGLE_explicit_context_gles1 47 typedef void* GLeglContext; 48 #import <ANGLE/egl.h> 49 #import <ANGLE/eglext.h> 50 #import <ANGLE/eglext_angle.h> 51 #import <ANGLE/entry_points_egl.h> 52 #import <ANGLE/entry_points_egl_ext.h> 53 #import <ANGLE/entry_points_gles_2_0_autogen.h> 54 #import <ANGLE/entry_points_gles_ext_autogen.h> 55 #import <ANGLE/gl2ext.h> 56 #import <ANGLE/gl2ext_angle.h> 43 57 44 58 #if PLATFORM(MAC) … … 335 349 // Create the WebGLLayer 336 350 BEGIN_BLOCK_OBJC_EXCEPTIONS 337 m_webGLLayer = adoptNS([[WebGLLayer alloc] initWith Client:this devicePixelRatio:attrs.devicePixelRatio]);351 m_webGLLayer = adoptNS([[WebGLLayer alloc] initWithGraphicsContextGL:this]); 338 352 #ifndef NDEBUG 339 353 [m_webGLLayer setName:@"WebGL Layer"]; 340 354 #endif 355 [m_webGLLayer setEGLDisplay:m_displayObj config:m_configObj]; 341 356 END_BLOCK_OBJC_EXCEPTIONS 342 357 … … 410 425 gl::DeleteFramebuffers(1, &m_preserveDrawingBufferFBO); 411 426 412 if (m_displayBufferPbuffer) { 413 EGL_ReleaseTexImage(m_displayObj, m_displayBufferPbuffer, EGL_BACK_BUFFER); 414 EGL_DestroySurface(m_displayObj, m_displayBufferPbuffer); 415 } 416 auto recycledBuffer = [m_webGLLayer recycleBuffer]; 417 if (recycledBuffer.handle) 418 EGL_DestroySurface(m_displayObj, recycledBuffer.handle); 419 auto contentsHandle = [m_webGLLayer detachClient]; 420 if (contentsHandle) 421 EGL_DestroySurface(m_displayObj, contentsHandle); 422 427 [m_webGLLayer releaseGLResources]; 423 428 EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 424 429 EGL_DestroyContext(m_displayObj, m_contextObj); 430 [m_webGLLayer setContext:nullptr]; 425 431 } 426 432 … … 471 477 if (!m_contextObj) 472 478 return false; 473 // If there is no drawing buffer, we failed to allocate one during preparing for display.474 // The exception is the case when the context is used before reshaping.475 if (!m_displayBufferBacking && !getInternalFramebufferSize().isEmpty())476 return false;477 479 // ANGLE has an early out for case where nothing changes. Calling MakeCurrent 478 480 // is important to set volatile platform context. See InitializeEGLDisplay(). … … 570 572 #endif 571 573 572 bool GraphicsContextGLOpenGL::reshapeDisplayBufferBacking() 573 { 574 ASSERT(!getInternalFramebufferSize().isEmpty()); 575 // Reset the current backbuffer now before allocating a new one in order to slightly reduce memory pressure. 576 if (m_displayBufferBacking) { 577 m_displayBufferBacking.reset(); 578 EGL_ReleaseTexImage(m_displayObj, m_displayBufferPbuffer, EGL_BACK_BUFFER); 579 EGL_DestroySurface(m_displayObj, m_displayBufferPbuffer); 580 m_displayBufferPbuffer = EGL_NO_SURFACE; 581 } 582 // Reset the future recycled buffer now, because it most likely will not be reusable at the time it will be reused. 583 auto recycledBuffer = [m_webGLLayer recycleBuffer]; 584 if (recycledBuffer.handle) 585 EGL_DestroySurface(m_displayObj, recycledBuffer.handle); 586 recycledBuffer.surface.reset(); 587 588 auto backing = WebCore::IOSurface::create(getInternalFramebufferSize(), WebCore::sRGBColorSpaceRef()); 589 if (!backing) 590 return false; 591 592 backing->migrateColorSpaceToProperties(); 593 594 const bool usingAlpha = contextAttributes().alpha; 595 const auto size = getInternalFramebufferSize(); 596 const EGLint surfaceAttributes[] = { 597 EGL_WIDTH, size.width(), 598 EGL_HEIGHT, size.height(), 599 EGL_IOSURFACE_PLANE_ANGLE, 0, 600 EGL_TEXTURE_TARGET, WebCore::GraphicsContextGLOpenGL::EGLIOSurfaceTextureTarget(), 601 EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, usingAlpha ? GL_BGRA_EXT : GL_RGB, 602 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, 603 EGL_TEXTURE_TYPE_ANGLE, GL_UNSIGNED_BYTE, 604 // Only has an effect on the iOS Simulator. 605 EGL_IOSURFACE_USAGE_HINT_ANGLE, EGL_IOSURFACE_WRITE_HINT_ANGLE, 606 EGL_NONE, EGL_NONE 607 }; 608 EGLSurface pbuffer = EGL_CreatePbufferFromClientBuffer(m_displayObj, EGL_IOSURFACE_ANGLE, backing->surface(), m_configObj, surfaceAttributes); 609 if (!pbuffer) 610 return false; 611 return bindDisplayBufferBacking(WTFMove(backing), pbuffer); 612 } 613 614 bool GraphicsContextGLOpenGL::bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer) 615 { 616 GCGLenum textureTarget = IOSurfaceTextureTarget(); 617 ScopedRestoreTextureBinding restoreBinding(IOSurfaceTextureTargetQuery(), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB); 618 gl::BindTexture(textureTarget, m_texture); 619 if (!EGL_BindTexImage(m_displayObj, pbuffer, EGL_BACK_BUFFER)) { 620 EGL_DestroySurface(m_displayObj, pbuffer); 621 return false; 622 } 623 m_displayBufferPbuffer = pbuffer; 624 m_displayBufferBacking = WTFMove(backing); 625 return true; 574 bool GraphicsContextGLOpenGL::allocateIOSurfaceBackingStore(IntSize size) 575 { 576 LOG(WebGL, "GraphicsContextGLOpenGL::allocateIOSurfaceBackingStore at %d x %d. (%p)", size.width(), size.height(), this); 577 return [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:contextAttributes().alpha]; 578 } 579 580 void GraphicsContextGLOpenGL::updateFramebufferTextureBackingStoreFromLayer() 581 { 582 LOG(WebGL, "GraphicsContextGLOpenGL::updateFramebufferTextureBackingStoreFromLayer(). (%p)", this); 583 [m_webGLLayer bindFramebufferToNextAvailableSurface]; 626 584 } 627 585 … … 680 638 void GraphicsContextGLOpenGL::prepareForDisplay() 681 639 { 682 if (m_layerComposited) 683 return; 684 if (!makeContextCurrent()) 685 return; 686 prepareTextureImpl(); 687 688 // The IOSurface will be used from other graphics subsystem, so flush GL commands. 689 gl::Flush(); 690 691 auto recycledBuffer = [m_webGLLayer recycleBuffer]; 692 693 EGL_ReleaseTexImage(m_displayObj, m_displayBufferPbuffer, EGL_BACK_BUFFER); 694 [m_webGLLayer prepareForDisplayWithContents: {WTFMove(m_displayBufferBacking), m_displayBufferPbuffer}]; 695 m_displayBufferPbuffer = EGL_NO_SURFACE; 696 697 if (recycledBuffer.surface && recycledBuffer.surface->size() == getInternalFramebufferSize()) { 698 if (bindDisplayBufferBacking(WTFMove(recycledBuffer.surface), recycledBuffer.handle)) 699 return; 700 } 701 recycledBuffer.surface.reset(); 702 if (recycledBuffer.handle) 703 EGL_DestroySurface(m_displayObj, recycledBuffer.handle); 704 // Error will be handled by next call to makeContextCurrent() which will notice lack of display buffer. 705 reshapeDisplayBufferBacking(); 706 } 707 708 void GraphicsContextGLOpenGL::didDisplay() 709 { 710 markLayerComposited(); 640 [m_webGLLayer prepareForDisplay]; 711 641 } 712 642 -
branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/cocoa/WebGLLayer.h
r268753 r268756 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 26 #import "IOSurface.h" 27 #import "IntSize.h" 27 28 #import <QuartzCore/QuartzCore.h> 28 29 #import <wtf/NakedPtr.h> 29 30 30 31 namespace WebCore { 31 class WebGLLayerClient; 32 struct WebGLLayerBuffer { 33 std::unique_ptr<WebCore::IOSurface> surface; // The actual contents. 34 void* handle { nullptr }; // Client specific metadata handle (such as EGLSurface). 35 }; 32 class GraphicsLayer; 33 class GraphicsContextGLOpenGL; 36 34 } 37 35 38 36 ALLOW_DEPRECATED_DECLARATIONS_BEGIN 39 37 40 // A layer class implementing front buffer management of a 3-buffering swap41 // chain of IOSurfaces.42 // The layer will own the IOSurfaces it uses for display.43 // The client may attach metadata to each IOSurface and will receive the metadata44 // back once the IOSurface has been displayed. However, the client may not neccessarily45 // be able to obtain the IOSurface itself for reuse.46 // Example use of the metadata is to use EGLSurface binding as the metadata. This way47 // when the WebGLLayer is done with the IOSurface display, the client can continue using48 // the existing binding obtained through the buffer recycle logic.49 38 @interface WebGLLayer : CALayer 50 39 51 - (id)initWithClient:(NakedPtr<WebCore::WebGLLayerClient>)client devicePixelRatio:(float)devicePixelRatio; 40 @property (nonatomic) NakedPtr<WebCore::GraphicsContextGLOpenGL> context; 41 42 - (id)initWithGraphicsContextGL:(NakedPtr<WebCore::GraphicsContextGLOpenGL>)context; 52 43 53 44 - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace; 54 45 55 // Returns the metadata handle of last unused contents buffer. 56 // Client may recieve back also the ownership of the contents surface, in case it is available at the 57 // time of the call. 58 // Returns either: 59 // - Empty buffer if no buffer has been submitted. 60 // - Buffer with empty surface and non-empty metadata handle if the recycled buffer was available 61 // but the surface is still in use. 62 // - Surface and handle. 63 - (WebCore::WebGLLayerBuffer)recycleBuffer; 46 - (void)prepareForDisplay; 64 47 65 // Prepares the layer for display with a contents buffer. 66 // Client transfers the ownership of the IOSurface surface in the `buffer`. 67 - (void)prepareForDisplayWithContents:(WebCore::WebGLLayerBuffer)buffer; 68 69 // Detaches the client and returns the current contents buffer metadata handle. 70 // The if multiple buffers have been submitted, recycleBuffer must have been called before calling 71 // this. 72 // The client will not receive `WebGLLayerClient` notifications after calling this. 73 - (void*)detachClient; 48 - (bool)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha; 49 - (void)bindFramebufferToNextAvailableSurface; 50 - (void)setEGLDisplay:(void*)eglDisplay config:(void*)eglConfig; 51 - (void)releaseGLResources; 74 52 75 53 @end -
branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm
r268753 r268756 29 29 #import "WebGLLayer.h" 30 30 31 #import "GraphicsContextCG.h" 32 #import "GraphicsContextGLOpenGL.h" 31 33 #import "GraphicsLayer.h" 32 34 #import "GraphicsLayerCA.h" 35 #import "ImageBufferUtilitiesCG.h" 36 #import "NotImplemented.h" 33 37 #import "PlatformCALayer.h" 34 #import "WebGLLayerClient.h"35 38 #import <pal/spi/cocoa/QuartzCoreSPI.h> 39 #import <wtf/FastMalloc.h> 36 40 #import <wtf/RetainPtr.h> 37 41 42 #define EGL_EGL_PROTOTYPES 0 43 #import <ANGLE/egl.h> 44 #import <ANGLE/eglext.h> 45 #import <ANGLE/eglext_angle.h> 46 #import <ANGLE/entry_points_egl.h> 47 #import <ANGLE/entry_points_gles_2_0_autogen.h> 48 // Skip the inclusion of ANGLE's explicit context entry points for now. 49 #define GL_ANGLE_explicit_context 50 #import <ANGLE/gl2ext.h> 51 #import <ANGLE/gl2ext_angle.h> 52 53 namespace { 54 class ScopedRestoreTextureBinding { 55 WTF_MAKE_NONCOPYABLE(ScopedRestoreTextureBinding); 56 public: 57 ScopedRestoreTextureBinding(GLenum bindingPointQuery, GLenum bindingPoint) 58 : m_bindingPoint(bindingPoint) 59 { 60 gl::GetIntegerv(bindingPointQuery, &m_bindingValue); 61 } 62 63 ~ScopedRestoreTextureBinding() 64 { 65 gl::BindTexture(m_bindingPoint, m_bindingValue); 66 } 67 68 private: 69 GLint m_bindingPoint { 0 }; 70 GLint m_bindingValue { 0 }; 71 }; 72 } 73 38 74 @implementation WebGLLayer { 39 NakedPtr<WebCore::WebGLLayerClient> _client; 40 WebCore::WebGLLayerBuffer _contentsBuffer; 41 WebCore::WebGLLayerBuffer _spareBuffer; 42 75 float _devicePixelRatio; 76 std::unique_ptr<WebCore::IOSurface> _contentsBuffer; 77 std::unique_ptr<WebCore::IOSurface> _drawingBuffer; 78 std::unique_ptr<WebCore::IOSurface> _spareBuffer; 79 WebCore::IntSize _bufferSize; 80 BOOL _usingAlpha; 81 void* _eglDisplay; 82 void* _eglConfig; 83 void* _contentsPbuffer; 84 void* _drawingPbuffer; 85 void* _sparePbuffer; 86 void* _latchedPbuffer; 43 87 BOOL _preparedForDisplay; 44 88 } 45 89 46 - (id)initWith Client:(NakedPtr<WebCore::WebGLLayerClient>)client devicePixelRatio:(float)devicePixelRatio47 { 48 _c lient = client;90 - (id)initWithGraphicsContextGL:(NakedPtr<WebCore::GraphicsContextGLOpenGL>)context 91 { 92 _context = context; 49 93 self = [super init]; 94 auto attributes = context->contextAttributes(); 95 _devicePixelRatio = attributes.devicePixelRatio; 96 self.contentsOpaque = !attributes.alpha; 50 97 self.transform = CATransform3DIdentity; 51 self.contentsScale = devicePixelRatio;98 self.contentsScale = _devicePixelRatio; 52 99 return self; 53 100 } … … 71 118 - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace 72 119 { 120 if (!_context) 121 return nullptr; 73 122 // FIXME: implement. https://bugs.webkit.org/show_bug.cgi?id=217377 74 // When implementing, remember to use self.contentsScale.75 123 UNUSED_PARAM(colorSpace); 76 124 return nullptr; 77 125 } 78 126 79 - (WebCore::WebGLLayerBuffer) recycleBuffer 80 { 81 if (_spareBuffer.surface) { 82 if (_spareBuffer.surface->isInUse()) 83 _spareBuffer.surface.reset(); 84 return WTFMove(_spareBuffer); 85 } 86 return { }; 87 } 88 89 - (void)prepareForDisplayWithContents:(WebCore::WebGLLayerBuffer) buffer 90 { 91 ASSERT(!_spareBuffer.surface); 92 _spareBuffer = WTFMove(_contentsBuffer); 93 _contentsBuffer = WTFMove(buffer); 127 - (void)prepareForDisplay 128 { 129 if (!_context) 130 return; 131 132 // To avoid running any OpenGL code in `display`, this method should be called 133 // at the end of the rendering task. We will flush all painting commands 134 // leaving the buffers ready to composite. 135 136 if (!_context->makeContextCurrent()) { 137 // Context is likely being torn down. 138 return; 139 } 140 _context->prepareTexture(); 141 if (_drawingBuffer) { 142 if (_latchedPbuffer) { 143 WTF::Optional<ScopedRestoreTextureBinding> restoreBinding; 144 GCGLenum textureTarget = WebCore::GraphicsContextGLOpenGL::IOSurfaceTextureTarget(); 145 // We don't need to restore GL_TEXTURE_RECTANGLE because it's not accessible from user code. 146 if (textureTarget != WebCore::GraphicsContextGL::TEXTURE_RECTANGLE_ARB) 147 restoreBinding.emplace(WebCore::GraphicsContextGLOpenGL::IOSurfaceTextureTargetQuery(), textureTarget); 148 GCGLenum texture = _context->platformTexture(); 149 gl::BindTexture(textureTarget, texture); 150 if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) { 151 // FIXME: report error. 152 notImplemented(); 153 } 154 _latchedPbuffer = nullptr; 155 } 156 157 std::swap(_contentsBuffer, _drawingBuffer); 158 std::swap(_contentsPbuffer, _drawingPbuffer); 159 [self bindFramebufferToNextAvailableSurface]; 160 } 94 161 [self setNeedsDisplay]; 95 162 _preparedForDisplay = YES; … … 98 165 - (void)display 99 166 { 100 if (_contentsBuffer.surface && _preparedForDisplay) { 101 self.contents = _contentsBuffer.surface->asLayerContents(); 167 if (!_context) 168 return; 169 170 // At this point we've painted into the _drawingBuffer and swapped it with the old _contentsBuffer, 171 // so all we need to do here is tickle the CALayer to let it know it has new contents. 172 // This avoids running any OpenGL code in this method. 173 174 if (_contentsBuffer && _preparedForDisplay) { 175 self.contents = _contentsBuffer->asLayerContents(); 102 176 [self reloadValueForKeyPath:@"contents"]; 103 177 } 104 if (_client) 105 _client->didDisplay();178 179 _context->markLayerComposited(); 106 180 auto layer = WebCore::PlatformCALayer::platformCALayerForLayer((__bridge void*)self); 107 181 if (layer && layer->owner()) … … 111 185 } 112 186 113 - (void*) detachClient 114 { 115 ASSERT(!_spareBuffer.surface); 116 _client = nil; 117 void* result = _contentsBuffer.handle; 118 _contentsBuffer.handle = nullptr; 119 return result; 120 } 187 - (void)setEGLDisplay:(void*)display config:(void*)config 188 { 189 _eglDisplay = display; 190 _eglConfig = config; 191 } 192 193 - (void)releaseGLResources 194 { 195 if (!_context) 196 return; 197 198 if (_context->makeContextCurrent() && _latchedPbuffer) { 199 EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER); 200 _latchedPbuffer = nullptr; 201 } 202 203 EGL_DestroySurface(_eglDisplay, _contentsPbuffer); 204 EGL_DestroySurface(_eglDisplay, _drawingPbuffer); 205 EGL_DestroySurface(_eglDisplay, _sparePbuffer); 206 } 207 208 - (bool)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha 209 { 210 _bufferSize = size; 211 _usingAlpha = usingAlpha; 212 _contentsBuffer = WebCore::IOSurface::create(size, WebCore::sRGBColorSpaceRef()); 213 _drawingBuffer = WebCore::IOSurface::create(size, WebCore::sRGBColorSpaceRef()); 214 _spareBuffer = WebCore::IOSurface::create(size, WebCore::sRGBColorSpaceRef()); 215 216 if (!_contentsBuffer || !_drawingBuffer || !_spareBuffer) 217 return false; 218 219 _contentsBuffer->migrateColorSpaceToProperties(); 220 _drawingBuffer->migrateColorSpaceToProperties(); 221 _spareBuffer->migrateColorSpaceToProperties(); 222 const EGLint surfaceAttributes[] = { 223 EGL_WIDTH, size.width(), 224 EGL_HEIGHT, size.height(), 225 EGL_IOSURFACE_PLANE_ANGLE, 0, 226 EGL_TEXTURE_TARGET, WebCore::GraphicsContextGLOpenGL::EGLIOSurfaceTextureTarget(), 227 EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, usingAlpha ? GL_BGRA_EXT : GL_RGB, 228 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, 229 EGL_TEXTURE_TYPE_ANGLE, GL_UNSIGNED_BYTE, 230 // Only has an effect on the iOS Simulator. 231 EGL_IOSURFACE_USAGE_HINT_ANGLE, EGL_IOSURFACE_WRITE_HINT_ANGLE, 232 EGL_NONE, EGL_NONE 233 }; 234 235 _contentsPbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _contentsBuffer->surface(), _eglConfig, surfaceAttributes); 236 _drawingPbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _drawingBuffer->surface(), _eglConfig, surfaceAttributes); 237 _sparePbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _spareBuffer->surface(), _eglConfig, surfaceAttributes); 238 239 if (!_contentsPbuffer || !_drawingPbuffer || !_sparePbuffer) 240 return false; 241 242 return true; 243 } 244 245 - (void)bindFramebufferToNextAvailableSurface 246 { 247 WTF::Optional<ScopedRestoreTextureBinding> restoreBinding; 248 GCGLenum textureTarget = WebCore::GraphicsContextGLOpenGL::IOSurfaceTextureTarget(); 249 // We don't need to restore GL_TEXTURE_RECTANGLE because it's not accessible from user code. 250 if (textureTarget != WebCore::GraphicsContextGL::TEXTURE_RECTANGLE_ARB) 251 restoreBinding.emplace(WebCore::GraphicsContextGLOpenGL::IOSurfaceTextureTargetQuery(), textureTarget); 252 253 GCGLenum texture = _context->platformTexture(); 254 gl::BindTexture(textureTarget, texture); 255 256 if (_latchedPbuffer) { 257 if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) { 258 // FIXME: report error. 259 notImplemented(); 260 } 261 _latchedPbuffer = nullptr; 262 } 263 264 if (_drawingBuffer && _drawingBuffer->isInUse()) { 265 std::swap(_drawingBuffer, _spareBuffer); 266 std::swap(_drawingPbuffer, _sparePbuffer); 267 } 268 269 // Link the IOSurface to the texture via the previously-created pbuffer. 270 if (!EGL_BindTexImage(_eglDisplay, _drawingPbuffer, EGL_BACK_BUFFER)) { 271 // FIXME: report error. 272 notImplemented(); 273 } 274 _latchedPbuffer = _drawingPbuffer; 275 } 276 121 277 @end 122 278 -
branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h
r268755 r268756 36 36 #include <wtf/UniqueArray.h> 37 37 38 #if PLATFORM(COCOA)39 #include "IOSurface.h"40 #include "WebGLLayerClient.h"41 #endif42 43 38 #if USE(CA) 44 39 #include "PlatformCALayer.h" … … 60 55 OBJC_CLASS CALayer; 61 56 OBJC_CLASS WebGLLayer; 57 typedef struct __IOSurface* IOSurfaceRef; 62 58 #endif // PLATFORM(COCOA) 63 59 … … 88 84 class GraphicsContextGLOpenGLPrivate; 89 85 90 class GraphicsContextGLOpenGL : public GraphicsContextGL 91 #if PLATFORM(COCOA) 92 , private WebGLLayerClient 93 #endif 94 { 86 class GraphicsContextGLOpenGL : public GraphicsContextGL { 95 87 public: 96 88 class Client { … … 552 544 553 545 #if PLATFORM(COCOA) 554 bool reshapeDisplayBufferBacking();555 bool bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer);546 bool allocateIOSurfaceBackingStore(IntSize); 547 void updateFramebufferTextureBackingStoreFromLayer(); 556 548 #if PLATFORM(MAC) 557 549 void updateCGLContext(); … … 690 682 691 683 bool reshapeFBOs(const IntSize&); 692 void prepareTextureImpl();693 684 void resolveMultisamplingIfNecessary(const IntRect& = IntRect()); 694 685 void attachDepthAndStencilBufferIfNeeded(GCGLuint internalDepthStencilFormat, int width, int height); … … 696 687 #if PLATFORM(COCOA) 697 688 bool allowOfflineRenderers() const; 698 // WebGLLayerClient overrides.699 void didDisplay() override;700 689 #endif 701 690 … … 902 891 903 892 #if PLATFORM(COCOA) 904 // Backing store for the the buffer which is eventually used for display.905 // When preserveDrawingBuffer == false, this is the drawing buffer backing store.906 // When preserveDrawingBuffer == true, this is blitted to during display prepare.907 std::unique_ptr<IOSurface> m_displayBufferBacking;908 void* m_displayBufferPbuffer { nullptr };909 910 893 bool m_hasSwitchedToHighPerformanceGPU { false }; 911 894 #endif -
branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp
r268386 r268756 165 165 return true; 166 166 } 167 updateFramebufferTextureBackingStoreFromLayer(); 167 168 ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, m_texture, 0); 168 169 #endif // !USE(OPENGL_ES)) -
branches/safari-611.1.4-branch/Source/WebKit/ChangeLog
r268649 r268756 1 2020-10-20 Alan Coon <alancoon@apple.com> 2 3 Revert r268386. rdar://problem/70497386 4 1 5 2020-10-17 David Kilzer <ddkilzer@apple.com> 2 6 -
branches/safari-611.1.4-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r268499 r268756 176 176 #include <WebCore/FrameView.h> 177 177 #include <WebCore/FullscreenManager.h> 178 #include <WebCore/GraphicsContextGLOpenGL.h> 178 179 #include <WebCore/HTMLAttachmentElement.h> 179 180 #include <WebCore/HTMLFormElement.h> -
branches/safari-611.1.4-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r268386 r268756 72 72 #import <WebCore/FrameView.h> 73 73 #import <WebCore/GraphicsContext.h> 74 #import <WebCore/GraphicsContextGLOpenGL.h> 74 75 #import <WebCore/HTMLConverter.h> 75 76 #import <WebCore/HTMLPlugInImageElement.h>
Note:
See TracChangeset
for help on using the changeset viewer.