Skip to content
Permalink
Browse files
Adopt CAMachPort-as-layer-contents
https://bugs.webkit.org/show_bug.cgi?id=141687
<rdar://problem/19393233>

Reviewed by Simon Fraser.

No new tests, just a performance bump.

* platform/cocoa/MachSendRight.h:
(WebCore::MachSendRight::operator bool):
Add an operator bool() that checks if the underlying port is nonnull.

* platform/spi/cocoa/QuartzCoreSPI.h:
Add some SPI.

* Shared/mac/RemoteLayerBackingStore.h:
* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::decode):
If we have CAMachPort, just keep the MachSendRight around.

(WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
If we have CAMachPort, make one and leak our send right into it. CAMachPort
will adopt the port and destroy it when needed.

(WebKit::RemoteLayerBackingStore::setBufferVolatility):
Tiny style fix.


Canonical link: https://commits.webkit.org/159710@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180203 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Feb 17, 2015
1 parent 66c7b93 commit 22fc0f99e7b0b593c483395ace8ba0c04db090ee
Showing 6 changed files with 64 additions and 4 deletions.
@@ -1,3 +1,20 @@
2015-02-16 Tim Horton <timothy_horton@apple.com>

Adopt CAMachPort-as-layer-contents
https://bugs.webkit.org/show_bug.cgi?id=141687
<rdar://problem/19393233>

Reviewed by Simon Fraser.

No new tests, just a performance bump.

* platform/cocoa/MachSendRight.h:
(WebCore::MachSendRight::operator bool):
Add an operator bool() that checks if the underlying port is nonnull.

* platform/spi/cocoa/QuartzCoreSPI.h:
Add some SPI.

2015-02-15 Sam Weinig <sam@webkit.org>

Add experimental <attachment> element support
@@ -50,6 +50,8 @@ class MachSendRight {
WEBCORE_EXPORT MachSendRight copySendRight() const;
WEBCORE_EXPORT mach_port_t leakSendRight() WARN_UNUSED_RETURN;

explicit operator bool() const { return m_port != MACH_PORT_NULL; }

private:
explicit MachSendRight(mach_port_t);

@@ -142,3 +142,9 @@ EXTERN_C NSString * const kCAFilterExclusionBlendMode;
EXTERN_C NSString * const kCAContextDisplayName;
EXTERN_C NSString * const kCAContextDisplayId;
EXTERN_C NSString * const kCAContextIgnoresHitTest;

// FIXME: These should move into the !USE(APPLE_INTERNAL_SDK) block once they are more readily available.
typedef struct _CAMachPort *CAMachPortRef;
extern "C" {
CAMachPortRef CAMachPortCreate(mach_port_t);
};
@@ -1,3 +1,23 @@
2015-02-16 Tim Horton <timothy_horton@apple.com>

Adopt CAMachPort-as-layer-contents
https://bugs.webkit.org/show_bug.cgi?id=141687
<rdar://problem/19393233>

Reviewed by Simon Fraser.

* Shared/mac/RemoteLayerBackingStore.h:
* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::decode):
If we have CAMachPort, just keep the MachSendRight around.

(WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
If we have CAMachPort, make one and leak our send right into it. CAMachPort
will adopt the port and destroy it when needed.

(WebKit::RemoteLayerBackingStore::setBufferVolatility):
Tiny style fix.

2015-02-15 Sam Weinig <sam@webkit.org>

Add experimental <attachment> element support
@@ -29,6 +29,7 @@
#include "ShareableBitmap.h"
#include <WebCore/FloatRect.h>
#include <WebCore/IOSurface.h>
#include <WebCore/MachSendRight.h>
#include <WebCore/Region.h>
#include <chrono>

@@ -133,6 +134,7 @@ class RemoteLayerBackingStore {
Buffer m_backBuffer;
#if USE(IOSURFACE)
Buffer m_secondaryBackBuffer;
WebCore::MachSendRight m_frontBufferSendRight;
#endif

RetainPtr<CGContextRef> m_frontContextPendingFlush;
@@ -37,14 +37,17 @@
#import <WebCore/GraphicsContextCG.h>
#import <WebCore/IOSurface.h>
#import <WebCore/IOSurfacePool.h>
#import <WebCore/MachSendRight.h>
#import <WebCore/QuartzCoreSPI.h>
#import <WebCore/SoftLinking.h>
#import <WebCore/WebLayer.h>

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

SOFT_LINK_FRAMEWORK(QuartzCore);
SOFT_LINK_MAY_FAIL(QuartzCore, CAMachPortCreate, CAMachPortRef, (mach_port_t port), (port));

using namespace WebCore;

namespace WebKit {
@@ -138,7 +141,12 @@
MachSendRight sendRight;
if (!decoder.decode(sendRight))
return false;
result.m_frontBuffer.surface = IOSurface::createFromSendRight(sendRight, ColorSpaceDeviceRGB);

if (canLoadCAMachPortCreate())
result.m_frontBufferSendRight = WTF::move(sendRight);
else
result.m_frontBuffer.surface = IOSurface::createFromSendRight(sendRight, ColorSpaceDeviceRGB);

return true;
}
#endif
@@ -375,7 +383,12 @@

#if USE(IOSURFACE)
if (acceleratesDrawing()) {
layer.contents = (id)m_frontBuffer.surface->surface();
if (canLoadCAMachPortCreate()) {
ASSERT(m_frontBufferSendRight);
RetainPtr<CAMachPortRef> port = adoptCF(CAMachPortCreate(m_frontBufferSendRight.leakSendRight()));
layer.contents = (id)port.get();
} else
layer.contents = (id)m_frontBuffer.surface->surface();
return;
}
#endif
@@ -392,7 +405,7 @@
#if USE(IOSURFACE)
bool RemoteLayerBackingStore::setBufferVolatility(BufferType type, bool isVolatile)
{
switch(type) {
switch (type) {
case BufferType::Front:
if (m_frontBuffer.surface && m_frontBuffer.isVolatile != isVolatile) {
if (isVolatile)

0 comments on commit 22fc0f9

Please sign in to comment.