Diff
Modified: trunk/Source/WebKit2/ChangeLog (90197 => 90198)
--- trunk/Source/WebKit2/ChangeLog 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/ChangeLog 2011-07-01 03:06:44 UTC (rev 90198)
@@ -1,3 +1,56 @@
+2011-06-30 Darin Adler <[email protected]>
+
+ Reviewed by Anders Carlsson.
+
+ [WebKit2] Consider scale factor when allocating backing store
+ https://bugs.webkit.org/show_bug.cgi?id=63766
+
+ This is the first step in considering scale factor. It considers
+ scale factor for the primary backing store, not graphics layers,
+ and for CG only.
+
+ * Platform/cg/CGUtilities.cpp:
+ (WebKit::paintImage): Added a scale factor argument.
+ (WebKit::paintBitmapContext): Pass 1 for scale factor.
+ * Platform/cg/CGUtilities.h: Updated for above.
+
+ * Shared/ShareableBitmap.h: Added an overload of paint that can handle
+ a scale factor.
+
+ * Shared/UpdateInfo.cpp:
+ (WebKit::UpdateInfo::encode): Encode scale factor.
+ (WebKit::UpdateInfo::decode): Decode scale factor.
+ * Shared/UpdateInfo.h: Added scale factor.
+
+ * Shared/cg/ShareableBitmapCG.cpp:
+ (WebKit::ShareableBitmap::paint): Added the overload that can handle
+ a scale factor.
+
+ * UIProcess/BackingStore.cpp:
+ (WebKit::BackingStore::create): Take a scale factor.
+ (WebKit::BackingStore::BackingStore): Store the scale factor.
+ (WebKit::BackingStore::incorporateUpdate): Consider the scale factor
+ when asserting the size is correct.
+
+ * UIProcess/BackingStore.h: Add a scale factor.
+
+ * UIProcess/DrawingAreaProxyImpl.cpp:
+ (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Check the
+ scale factor too when deciding whether to reuse a backing store.
+ (WebKit::DrawingAreaProxyImpl::incorporateUpdate): Pass in the scale
+ factor when creating a backing store.
+
+ * UIProcess/mac/BackingStoreMac.mm:
+ (WebKit::BackingStore::incorporateUpdate): Take the scale factor into
+ account when painting.
+
+ * WebProcess/WebPage/DrawingAreaImpl.cpp:
+ (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): Put the
+ scale factor into the UpdateInfo.
+ (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Ditto.
+ (WebKit::DrawingAreaImpl::display): Take the scale factor into account
+ when allocating the bitmap and creating a graphics context for it.
+
2011-06-30 Mark Rowe <[email protected]>
Fix the Windows build.
Modified: trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp (90197 => 90198)
--- trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/Platform/cg/CGUtilities.cpp 2011-07-01 03:06:44 UTC (rev 90198)
@@ -30,28 +30,28 @@
namespace WebKit {
-void paintImage(CGContextRef context, CGImageRef image, CGPoint destination, CGRect source)
+void paintImage(CGContextRef context, CGImageRef image, CGFloat scaleFactor, CGPoint destination, CGRect source)
{
CGContextSaveGState(context);
CGContextClipToRect(context, CGRectMake(destination.x, destination.y, source.size.width, source.size.height));
CGContextScaleCTM(context, 1, -1);
- size_t imageHeight = CGImageGetHeight(image);
- size_t imageWidth = CGImageGetWidth(image);
+ CGFloat imageHeight = CGImageGetHeight(image) / scaleFactor;
+ CGFloat imageWidth = CGImageGetWidth(image) / scaleFactor;
CGFloat destX = destination.x - source.origin.x;
- CGFloat destY = -static_cast<CGFloat>(imageHeight) - destination.y + source.origin.y;
+ CGFloat destY = -imageHeight - destination.y + source.origin.y;
CGContextDrawImage(context, CGRectMake(destX, destY, imageWidth, imageHeight), image);
+
CGContextRestoreGState(context);
}
void paintBitmapContext(CGContextRef context, CGContextRef bitmapContext, CGPoint destination, CGRect source)
{
RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
- paintImage(context, image.get(), destination, source);
+ paintImage(context, image.get(), 1, destination, source);
}
} // namespace WebKit
-
Modified: trunk/Source/WebKit2/Platform/cg/CGUtilities.h (90197 => 90198)
--- trunk/Source/WebKit2/Platform/cg/CGUtilities.h 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/Platform/cg/CGUtilities.h 2011-07-01 03:06:44 UTC (rev 90198)
@@ -28,7 +28,7 @@
namespace WebKit {
-void paintImage(CGContextRef, CGImageRef, CGPoint destination, CGRect source);
+void paintImage(CGContextRef, CGImageRef, CGFloat scaleFactor, CGPoint destination, CGRect source);
void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source);
} // namespace WebKit
Modified: trunk/Source/WebKit2/Shared/ShareableBitmap.h (90197 => 90198)
--- trunk/Source/WebKit2/Shared/ShareableBitmap.h 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/Shared/ShareableBitmap.h 2011-07-01 03:06:44 UTC (rev 90198)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -103,7 +103,8 @@
PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext();
// Paint the backing store into the given context.
- void paint(WebCore::GraphicsContext&, const WebCore::IntPoint& dstPoint, const WebCore::IntRect& srcRect);
+ void paint(WebCore::GraphicsContext&, const WebCore::IntPoint& destination, const WebCore::IntRect& source);
+ void paint(WebCore::GraphicsContext&, float scaleFactor, const WebCore::IntPoint& destination, const WebCore::IntRect& source);
bool isBackedBySharedMemory() const { return m_sharedMemory; }
@@ -158,6 +159,7 @@
// If the shareable bitmap is backed by fastMalloced memory, this points to the data.
void* m_data;
+
#if PLATFORM(WIN)
mutable OwnPtr<HDC> m_windowsContext;
mutable OwnPtr<HBITMAP> m_windowsBitmap;
Modified: trunk/Source/WebKit2/Shared/UpdateInfo.cpp (90197 => 90198)
--- trunk/Source/WebKit2/Shared/UpdateInfo.cpp 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/Shared/UpdateInfo.cpp 2011-07-01 03:06:44 UTC (rev 90198)
@@ -33,6 +33,7 @@
void UpdateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const
{
encoder->encode(viewSize);
+ encoder->encode(scaleFactor);
encoder->encode(scrollRect);
encoder->encode(scrollOffset);
encoder->encode(updateRectBounds);
@@ -44,6 +45,8 @@
{
if (!decoder->decode(result.viewSize))
return false;
+ if (!decoder->decode(result.scaleFactor))
+ return false;
if (!decoder->decode(result.scrollRect))
return false;
if (!decoder->decode(result.scrollOffset))
Modified: trunk/Source/WebKit2/Shared/UpdateInfo.h (90197 => 90198)
--- trunk/Source/WebKit2/Shared/UpdateInfo.h 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/Shared/UpdateInfo.h 2011-07-01 03:06:44 UTC (rev 90198)
@@ -48,6 +48,7 @@
// The size of the web view.
WebCore::IntSize viewSize;
+ float scaleFactor;
// The rect and delta to be scrolled.
WebCore::IntRect scrollRect;
Modified: trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp (90197 => 90198)
--- trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp 2011-07-01 03:06:44 UTC (rev 90198)
@@ -62,11 +62,16 @@
return adoptPtr(new GraphicsContext(bitmapContext.get()));
}
-void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect)
+void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& destination, const IntRect& source)
{
- paintImage(context.platformContext(), makeCGImageCopy().get(), dstPoint, srcRect);
+ paintImage(context.platformContext(), makeCGImageCopy().get(), 1, destination, source);
}
+void ShareableBitmap::paint(WebCore::GraphicsContext& context, float scaleFactor, const IntPoint& destination, const IntRect& source)
+{
+ paintImage(context.platformContext(), makeCGImageCopy().get(), scaleFactor, destination, source);
+}
+
#if !PLATFORM(WIN)
RetainPtr<CGImageRef> ShareableBitmap::makeCGImageCopy()
{
Modified: trunk/Source/WebKit2/UIProcess/BackingStore.cpp (90197 => 90198)
--- trunk/Source/WebKit2/UIProcess/BackingStore.cpp 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/UIProcess/BackingStore.cpp 2011-07-01 03:06:44 UTC (rev 90198)
@@ -33,13 +33,14 @@
namespace WebKit {
-PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, WebPageProxy* webPageProxy)
+PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, float scaleFactor, WebPageProxy* webPageProxy)
{
- return adoptPtr(new BackingStore(size, webPageProxy));
+ return adoptPtr(new BackingStore(size, scaleFactor, webPageProxy));
}
-BackingStore::BackingStore(const IntSize& size, WebPageProxy* webPageProxy)
+BackingStore::BackingStore(const IntSize& size, float scaleFactor, WebPageProxy* webPageProxy)
: m_size(size)
+ , m_scaleFactor(scaleFactor)
, m_webPageProxy(webPageProxy)
{
ASSERT(!m_size.isEmpty());
@@ -56,7 +57,12 @@
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
if (!bitmap)
return;
- ASSERT(bitmap->size() == updateInfo.updateRectBounds.size());
+
+#if !ASSERT_DISABLED
+ IntSize updateSize = updateInfo.updateRectBounds.size();
+ updateSize.scale(m_scaleFactor);
+ ASSERT(bitmap->size() == updateSize);
+#endif
incorporateUpdate(bitmap.get(), updateInfo);
}
Modified: trunk/Source/WebKit2/UIProcess/BackingStore.h (90197 => 90198)
--- trunk/Source/WebKit2/UIProcess/BackingStore.h 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/UIProcess/BackingStore.h 2011-07-01 03:06:44 UTC (rev 90198)
@@ -60,10 +60,11 @@
WTF_MAKE_NONCOPYABLE(BackingStore);
public:
- static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, WebPageProxy*);
+ static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, float scaleFactor, WebPageProxy*);
~BackingStore();
const WebCore::IntSize& size() const { return m_size; }
+ float scaleFactor() const { return m_scaleFactor; }
#if PLATFORM(MAC)
typedef CGContextRef PlatformGraphicsContext;
@@ -79,12 +80,13 @@
void incorporateUpdate(const UpdateInfo&);
private:
- BackingStore(const WebCore::IntSize&, WebPageProxy*);
+ BackingStore(const WebCore::IntSize&, float scaleFactor, WebPageProxy*);
void incorporateUpdate(ShareableBitmap*, const UpdateInfo&);
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
WebCore::IntSize m_size;
+ float m_scaleFactor;
WebPageProxy* m_webPageProxy;
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp (90197 => 90198)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp 2011-07-01 03:06:44 UTC (rev 90198)
@@ -205,7 +205,7 @@
#endif
// If we have a backing store the right size, reuse it.
- if (m_backingStore && m_backingStore->size() != updateInfo.viewSize)
+ if (m_backingStore && (m_backingStore->size() != updateInfo.viewSize || m_backingStore->scaleFactor() != updateInfo.scaleFactor))
m_backingStore = nullptr;
incorporateUpdate(updateInfo);
}
@@ -242,7 +242,7 @@
return;
if (!m_backingStore)
- m_backingStore = BackingStore::create(updateInfo.viewSize, m_webPageProxy);
+ m_backingStore = BackingStore::create(updateInfo.viewSize, updateInfo.scaleFactor, m_webPageProxy);
m_backingStore->incorporateUpdate(updateInfo);
Modified: trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm (90197 => 90198)
--- trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm 2011-07-01 03:06:44 UTC (rev 90198)
@@ -109,7 +109,7 @@
IntRect srcRect = updateRect;
srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
- bitmap->paint(graphicsContext, updateRect.location(), srcRect);
+ bitmap->paint(graphicsContext, updateInfo.scaleFactor, updateRect.location(), srcRect);
}
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (90197 => 90198)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp 2011-07-01 02:59:43 UTC (rev 90197)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp 2011-07-01 03:06:44 UTC (rev 90198)
@@ -357,6 +357,7 @@
if (m_isPaintingSuspended || m_layerTreeHost) {
updateInfo.viewSize = m_webPage->size();
+ updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor();
if (m_layerTreeHost) {
layerTreeContext = m_layerTreeHost->layerTreeContext();
@@ -461,9 +462,10 @@
}
UpdateInfo updateInfo;
- if (m_isPaintingSuspended)
+ if (m_isPaintingSuspended) {
updateInfo.viewSize = m_webPage->size();
- else
+ updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor();
+ } else
display(updateInfo);
#if USE(ACCELERATED_COMPOSITING)
@@ -613,11 +615,14 @@
return;
updateInfo.viewSize = m_webPage->size();
+ updateInfo.scaleFactor = m_webPage->userSpaceScaleFactor();
IntRect bounds = m_dirtyRegion.bounds();
ASSERT(m_webPage->bounds().contains(bounds));
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha);
+ IntSize bitmapSize = bounds.size();
+ bitmapSize.scale(m_webPage->userSpaceScaleFactor());
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
if (!bitmap)
return;
@@ -639,6 +644,7 @@
m_scrollOffset = IntSize();
OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get());
+ graphicsContext->scale(FloatSize(m_webPage->userSpaceScaleFactor(), m_webPage->userSpaceScaleFactor()));
updateInfo.updateRectBounds = bounds;