summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm')
-rw-r--r--WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm55
1 files changed, 39 insertions, 16 deletions
diff --git a/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm b/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm
index 0059b69..3967186 100644
--- a/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm
@@ -38,6 +38,7 @@
#include <wtf/Assertions.h>
#include <wtf/RefPtr.h>
+#import <WebKit/WebCoreStatistics.h>
#import <WebKit/WebDocumentPrivate.h>
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebKit.h>
@@ -104,21 +105,11 @@ void setupMainDisplayColorProfile()
signal(SIGTERM, restoreMainDisplayColorProfile);
}
-PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
+static PassRefPtr<BitmapContext> createBitmapContext(size_t pixelsWide, size_t pixelsHigh, size_t& rowBytes, void*& buffer)
{
- WebView* view = [mainFrame webView];
+ rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance
- // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path
- // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled.
- if ([view _isUsingAcceleratedCompositing])
- onscreen = YES;
-
- NSSize webViewSize = [view frame].size;
- size_t pixelsWide = static_cast<size_t>(webViewSize.width);
- size_t pixelsHigh = static_cast<size_t>(webViewSize.height);
- size_t rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance
-
- void *buffer = calloc(pixelsHigh, rowBytes);
+ buffer = calloc(pixelsHigh, rowBytes);
if (!buffer)
return 0;
@@ -140,9 +131,28 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc
return 0;
}
- // The BitmapContext keeps the CGContextRef and the pixel buffer alive
- RefPtr<BitmapContext> bitmapContext = BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
-
+ return BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
+}
+
+PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
+{
+ WebView* view = [mainFrame webView];
+
+ // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path
+ // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled.
+ if ([view _isUsingAcceleratedCompositing])
+ onscreen = YES;
+
+ NSSize webViewSize = [view frame].size;
+ size_t pixelsWide = static_cast<size_t>(webViewSize.width);
+ size_t pixelsHigh = static_cast<size_t>(webViewSize.height);
+ size_t rowBytes = 0;
+ void* buffer = 0;
+ RefPtr<BitmapContext> bitmapContext = createBitmapContext(pixelsWide, pixelsHigh, rowBytes, buffer);
+ if (!bitmapContext)
+ return 0;
+ CGContextRef context = bitmapContext->cgContext();
+
NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
ASSERT(nsContext);
@@ -254,3 +264,16 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc
return bitmapContext.release();
}
+
+PassRefPtr<BitmapContext> createPagedBitmapContext()
+{
+ int pageWidthInPixels = LayoutTestController::maxViewWidth;
+ int pageHeightInPixels = LayoutTestController::maxViewHeight;
+ int numberOfPages = [mainFrame numberOfPages:pageWidthInPixels:pageHeightInPixels];
+ size_t rowBytes = 0;
+ void* buffer = 0;
+
+ RefPtr<BitmapContext> bitmapContext = createBitmapContext(pageWidthInPixels, numberOfPages * (pageHeightInPixels + 1) - 1, rowBytes, buffer);
+ [mainFrame printToCGContext:bitmapContext->cgContext():pageWidthInPixels:pageHeightInPixels];
+ return bitmapContext.release();
+}