diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/mac')
-rw-r--r-- | Source/WebKit2/UIProcess/mac/BackingStoreMac.mm | 79 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebContextMac.mm | 3 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm | 6 |
3 files changed, 72 insertions, 16 deletions
diff --git a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm index 979f755..eacfefa 100644 --- a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm +++ b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm @@ -28,6 +28,7 @@ #include "CGUtilities.h" #include "ShareableBitmap.h" #include "UpdateInfo.h" +#include "WebPageProxy.h" #include <WebCore/GraphicsContext.h> using namespace WebCore; @@ -36,34 +37,70 @@ namespace WebKit { void BackingStore::paint(PlatformGraphicsContext context, const IntRect& rect) { - ASSERT(m_bitmapContext); + if (m_cgLayer) { + CGContextSaveGState(context); + CGContextClipToRect(context, rect); + + CGContextScaleCTM(context, 1, -1); + CGContextDrawLayerAtPoint(context, CGPointMake(0, -m_size.height()), m_cgLayer.get()); + + CGContextRestoreGState(context); + return; + } + ASSERT(m_bitmapContext); paintBitmapContext(context, m_bitmapContext.get(), rect.location(), rect); } -void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) +CGContextRef BackingStore::backingStoreContext() { - ASSERT(m_size == updateInfo.viewSize); + if (m_cgLayer) + return CGLayerGetContext(m_cgLayer.get()); - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle); - if (!bitmap) - return; + // Try to create a layer. + if (CGContextRef containingWindowContext = m_webPageProxy->containingWindowGraphicsContext()) { + m_cgLayer.adoptCF(CGLayerCreateWithContext(containingWindowContext, NSSizeToCGSize(m_size), 0)); + CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get()); + + CGContextSetBlendMode(layerContext, kCGBlendModeCopy); + + // We want the origin to be in the top left corner so flip the backing store context. + CGContextTranslateCTM(layerContext, 0, m_size.height()); + CGContextScaleCTM(layerContext, 1, -1); + + if (m_bitmapContext) { + // Paint the contents of the bitmap into the layer context. + paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height())); + m_bitmapContext = nullptr; + } + + return layerContext; + } if (!m_bitmapContext) { RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); m_bitmapContext.adoptCF(CGBitmapContextCreate(0, m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); - + + CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy); + // We want the origin to be in the top left corner so flip the backing store context. CGContextTranslateCTM(m_bitmapContext.get(), 0, m_size.height()); CGContextScaleCTM(m_bitmapContext.get(), 1, -1); } - scroll(updateInfo.scrollRect, updateInfo.scrollDelta); + return m_bitmapContext.get(); +} + +void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo) +{ + CGContextRef context = backingStoreContext(); + + scroll(updateInfo.scrollRect, updateInfo.scrollOffset); IntPoint updateRectLocation = updateInfo.updateRectBounds.location(); - GraphicsContext graphicsContext(m_bitmapContext.get()); + GraphicsContext graphicsContext(context); // Paint all update rects. for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) { @@ -75,18 +112,30 @@ void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) } } -void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { - if (scrollDelta.isZero()) + if (scrollOffset.isZero()) return; - CGContextSaveGState(m_bitmapContext.get()); + if (m_cgLayer) { + CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get()); - CGContextClipToRect(m_bitmapContext.get(), scrollRect); + // Scroll the layer by painting it into itself with the given offset. + CGContextSaveGState(layerContext); + CGContextClipToRect(layerContext, scrollRect); + CGContextScaleCTM(layerContext, 1, -1); + CGContextDrawLayerAtPoint(layerContext, CGPointMake(scrollOffset.width(), -m_size.height() - scrollOffset.height()), m_cgLayer.get()); + CGContextRestoreGState(layerContext); - CGPoint destination = CGPointMake(scrollRect.x() + scrollDelta.width(), scrollRect.y() + scrollDelta.height()); - paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect); + return; + } + + ASSERT(m_bitmapContext); + CGContextSaveGState(m_bitmapContext.get()); + CGContextClipToRect(m_bitmapContext.get(), scrollRect); + CGPoint destination = CGPointMake(scrollRect.x() + scrollOffset.width(), scrollRect.y() + scrollOffset.height()); + paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect); CGContextRestoreGState(m_bitmapContext.get()); } diff --git a/Source/WebKit2/UIProcess/mac/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm index ce4c3e6..4d1679f 100644 --- a/Source/WebKit2/UIProcess/mac/WebContextMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm @@ -74,7 +74,8 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para cachePath = reinterpret_cast<CFStringRef>(NSHomeDirectory()); NSURLCache *urlCache = [NSURLCache sharedURLCache]; - + + parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; parameters.nsURLCachePath = fileSystemRepresentation([(NSString *)cachePath.get() stringByStandardizingPath]); parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity]; parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity]; diff --git a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm index 36905fb..cd3e6f1 100644 --- a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm @@ -25,6 +25,7 @@ #include "WebPageProxy.h" +#include "PageClient.h" #include <WebCore/Language.h> #include <wtf/text/StringConcatenate.h> @@ -110,4 +111,9 @@ void WebPageProxy::stopSpeaking() [NSApp stopSpeaking:nil]; } +CGContextRef WebPageProxy::containingWindowGraphicsContext() +{ + return m_pageClient->containingWindowGraphicsContext(); +} + } // namespace WebKit |